Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f3fe32

Browse files
Add stamp_dict stamp
1 parente0faa4c commit2f3fe32

File tree

7 files changed

+120
-5
lines changed

7 files changed

+120
-5
lines changed

‎Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ BLOB_STAMPER_OBJ = blobstamper/blob.o \
1010
blobstamper/helpers.o\
1111
blobstamper/stamp.o\
1212
blobstamper/stamp_atomic.o\
13-
blobstamper/stamp_pg_type_geo.o\
13+
blobstamper/stamp_dict.o\
1414
blobstamper/galley.o\
1515
blobstamper/dict.o\
16+
blobstamper/stamp_pg_type_geo.o\
17+
1618

1719
WRAPPERS_OBJ = pg_op_wrappers.o
1820

‎blobstamper/Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ ALL_OBJS = blob.o \
33
helpers.o\
44
stamp.o\
55
stamp_atomic.o\
6-
stamp_pg_type_geo.o\
6+
stamp_dict.o\
77
galley.o\
8-
dict.o
8+
dict.o\
9+
stamp_pg_type_geo.o\
10+
911

1012

1113
%.o:%.cpp$(DEPS)

‎blobstamper/blobstamper.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#include"blob.h"
33
#include"stamp.h"
44
#include"stamp_atomic.h"
5-
#include"stamp_pg_type_geo.h"
5+
#include"stamp_dict.h"
66
#include"dict.h"
77
#include"galley.h"
8+
#include"stamp_pg_type_geo.h"
89

910

‎blobstamper/dict.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#ifndef DICT_H
2+
#defineDICT_H
3+
4+
15
#include<string>
26
#include<vector>
37

@@ -16,4 +20,6 @@ class DictLCAlphaSmall : public DictBase
1620
{
1721
public:
1822
DictLCAlphaSmall();
19-
};
23+
};
24+
25+
#endif/* DICT_H*/

‎blobstamper/stamp_dict.cpp‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
unsignedlonglong index_oracle;
33+
34+
/* Shifting index oracle according to size of dictionary index variable*/
35+
switch (stamp.minSize())
36+
{
37+
case1:
38+
{
39+
unsignedchar * i = (unsignedchar *) blob.ShiftSingleStampBin(stamp);
40+
index_oracle = * i;
41+
free(i);
42+
break;
43+
}
44+
case2:
45+
{
46+
unsignedshortint * i = (unsignedshortint *) blob.ShiftSingleStampBin(stamp);
47+
index_oracle = * i;
48+
free(i);
49+
break;
50+
}
51+
case4:
52+
{
53+
unsignedint * i = (unsignedint *) blob.ShiftSingleStampBin(stamp);
54+
index_oracle = * i;
55+
free(i);
56+
break;
57+
}
58+
59+
case8:
60+
{
61+
unsignedlonglong * i = (unsignedlonglong *) 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+
longlong 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+
}

‎blobstamper/stamp_dict.h‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
#ifndef STAMP_DICT_H
3+
#defineSTAMP_DICT_H
4+
5+
#include<limits.h>
6+
7+
#include"dict.h"
8+
9+
classStampDict:publicStampGeneric
10+
{
11+
protected:
12+
StampBinChar stamp8;
13+
StampBinInt16 stamp16;
14+
StampBinInt32 stamp32;
15+
StampBinInt64 stamp64;
16+
StampGeneric& stamp;
17+
DictBase& dict;
18+
unsignedlonglong 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::stringExtractStr(Blob &blob)override;
25+
boolisFixedSize()override {returntrue;}
26+
intminSize()override {return stamp.minSize();}
27+
intmaxSize()override {return stamp.maxSize();}
28+
};
29+
30+
#endif/* STAMP_DICT_H*/

‎t/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ BLOB_STAMPER_OBJ = ../blobstamper/blob.o \
1818
../blobstamper/dict.o\
1919
../blobstamper/stamp.o\
2020
../blobstamper/stamp_atomic.o\
21+
../blobstamper/stamp_dict.o\
2122
../blobstamper/galley.o\
2223
../blobstamper/stamp_pg_type_geo.o\
2324
../pg_op_wrappers.o\

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp