File tree Expand file tree Collapse file tree 7 files changed +120
-5
lines changed Expand file tree Collapse file tree 7 files changed +120
-5
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ BLOB_STAMPER_OBJ = blobstamper/blob.o \
10
10
blobstamper/helpers.o \
11
11
blobstamper/stamp.o \
12
12
blobstamper/stamp_atomic.o \
13
- blobstamper/stamp_pg_type_geo .o \
13
+ blobstamper/stamp_dict .o \
14
14
blobstamper/galley.o \
15
15
blobstamper/dict.o \
16
+ blobstamper/stamp_pg_type_geo.o \
17
+
16
18
17
19
WRAPPERS_OBJ = pg_op_wrappers.o
18
20
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ ALL_OBJS = blob.o \
3
3
helpers.o \
4
4
stamp.o \
5
5
stamp_atomic.o \
6
- stamp_pg_type_geo .o \
6
+ stamp_dict .o \
7
7
galley.o \
8
- dict.o
8
+ dict.o \
9
+ stamp_pg_type_geo.o \
10
+
9
11
10
12
11
13
% .o : % .cpp $(DEPS )
Original file line number Diff line number Diff line change 2
2
#include "blob.h"
3
3
#include "stamp.h"
4
4
#include "stamp_atomic.h"
5
- #include "stamp_pg_type_geo .h"
5
+ #include "stamp_dict .h"
6
6
#include "dict.h"
7
7
#include "galley.h"
8
+ #include "stamp_pg_type_geo.h"
8
9
9
10
Original file line number Diff line number Diff line change
1
+ #ifndef DICT_H
2
+ #define DICT_H
3
+
4
+
1
5
#include < string>
2
6
#include < vector>
3
7
@@ -16,4 +20,6 @@ class DictLCAlphaSmall : public DictBase
16
20
{
17
21
public:
18
22
DictLCAlphaSmall ();
19
- };
23
+ };
24
+
25
+ #endif /* DICT_H */
Original file line number Diff line number Diff line change
1
+
2
+ #include " blob.h"
3
+ #include " stamp.h"
4
+ #include " stamp_atomic.h"
5
+ #include " stamp_dict.h"
6
+
7
+ StampGeneric&
8
+ StampDict::GuessStamp (DictBase & dict)
9
+ {
10
+ if (dict.size ()<= UCHAR_MAX+1 )
11
+ {
12
+ stamp_max_value = UCHAR_MAX;
13
+ return stamp8;
14
+ }
15
+ if (dict.size ()<= USHRT_MAX+1 )
16
+ {
17
+ stamp_max_value = USHRT_MAX;
18
+ return stamp16;
19
+ }
20
+ if (dict.size ()<= UINT_MAX+1 )
21
+ {
22
+ stamp_max_value = UINT_MAX;
23
+ return stamp32;
24
+ }
25
+ stamp_max_value = ULONG_MAX;
26
+ return stamp64;
27
+ }
28
+
29
+ std::string
30
+ StampDict::ExtractStr (Blob &blob)
31
+ {
32
+ unsigned long long index_oracle;
33
+
34
+ /* Shifting index oracle according to size of dictionary index variable*/
35
+ switch (stamp.minSize ())
36
+ {
37
+ case 1 :
38
+ {
39
+ unsigned char * i = (unsigned char *) blob.ShiftSingleStampBin (stamp);
40
+ index_oracle = * i;
41
+ free (i);
42
+ break ;
43
+ }
44
+ case 2 :
45
+ {
46
+ unsigned short int * i = (unsigned short int *) blob.ShiftSingleStampBin (stamp);
47
+ index_oracle = * i;
48
+ free (i);
49
+ break ;
50
+ }
51
+ case 4 :
52
+ {
53
+ unsigned int * i = ( unsigned int *) blob.ShiftSingleStampBin (stamp);
54
+ index_oracle = * i;
55
+ free (i);
56
+ break ;
57
+ }
58
+
59
+ case 8 :
60
+ {
61
+ unsigned long long * i = ( unsigned long long *) blob.ShiftSingleStampBin (stamp);
62
+ index_oracle = * i;
63
+ free (i);
64
+ break ;
65
+ }
66
+ default :
67
+ printf (" StampDict::ExtractStr: Something is really wrong\n " );
68
+ exit (1 );
69
+ }
70
+ long long actual_index = ((double ) index_oracle) / stamp_max_value * dict.size ();
71
+ if ( actual_index == dict.size ()) actual_index--; /* If we hit the boundary step inside a bit*/
72
+ return dict.get (actual_index);
73
+ }
Original file line number Diff line number Diff line change
1
+
2
+ #ifndef STAMP_DICT_H
3
+ #define STAMP_DICT_H
4
+
5
+ #include < limits.h>
6
+
7
+ #include " dict.h"
8
+
9
+ class StampDict : public StampGeneric
10
+ {
11
+ protected:
12
+ StampBinChar stamp8;
13
+ StampBinInt16 stamp16;
14
+ StampBinInt32 stamp32;
15
+ StampBinInt64 stamp64;
16
+ StampGeneric& stamp;
17
+ DictBase& dict;
18
+ unsigned long long stamp_max_value;
19
+
20
+ StampGeneric& GuessStamp (DictBase & dict);
21
+
22
+ public:
23
+ StampDict (DictBase & dict_arg) : dict{dict_arg}, stamp{GuessStamp (dict_arg)} {};
24
+ std::string ExtractStr (Blob &blob) override ;
25
+ bool isFixedSize () override {return true ;}
26
+ int minSize () override {return stamp.minSize ();}
27
+ int maxSize () override {return stamp.maxSize ();}
28
+ };
29
+
30
+ #endif /* STAMP_DICT_H */
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ BLOB_STAMPER_OBJ = ../blobstamper/blob.o \
18
18
../blobstamper/dict.o \
19
19
../blobstamper/stamp.o \
20
20
../blobstamper/stamp_atomic.o \
21
+ ../blobstamper/stamp_dict.o \
21
22
../blobstamper/galley.o \
22
23
../blobstamper/stamp_pg_type_geo.o \
23
24
../pg_op_wrappers.o \
You can’t perform that action at this time.
0 commit comments