Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
0fa3f2a9
Commit
0fa3f2a9
authored
May 19, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more global constants
parent
1f128066
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
4 deletions
+124
-4
global.constant
conf/global.constant
+4
-0
simple_store_new.cc
tools/simple_store_new.cc
+10
-2
constants.cc
util/constants.cc
+47
-1
constants.hh
util/constants.hh
+3
-0
common.cc
wrapper/common.cc
+59
-1
common.hh
wrapper/common.hh
+1
-0
No files found.
conf/global.constant
View file @
0fa3f2a9
...
@@ -6,4 +6,8 @@ useOPE:false
...
@@ -6,4 +6,8 @@ useOPE:false
useSWP:true
useSWP:true
useDET:true
useDET:true
useSalt:true
useSalt:true
#NA,MIN,MIDEAN,FULL
BS_STR:MIN
BS_IA:MIN
BS_IH:MIN
other:1
other:1
tools/simple_store_new.cc
View file @
0fa3f2a9
...
@@ -85,6 +85,15 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
...
@@ -85,6 +85,15 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
}
}
}
}
}
}
static
void
write_meta_new
(
std
::
vector
<
FieldMetaTrans
>
&
res
,
string
db
,
string
table
){
std
::
string
filename
=
std
::
string
(
"data/"
)
+
db
+
"/"
+
table
+
"/metadata.data"
;
TableMetaTrans
mf
(
db
,
table
,
res
);
mf
.
set_db_table
(
db
,
table
);
mf
.
serializeNew
(
filename
);
}
static
static
std
::
string
std
::
string
getSelectField
(
SchemaInfo
&
schema
,
FieldMetaTrans
&
tf
,
std
::
string
db
,
std
::
string
table
){
getSelectField
(
SchemaInfo
&
schema
,
FieldMetaTrans
&
tf
,
std
::
string
db
,
std
::
string
table
){
...
@@ -161,11 +170,10 @@ static void store(std::string db, std::string table){
...
@@ -161,11 +170,10 @@ static void store(std::string db, std::string table){
tf
.
setSaltLength
(
slength
);
tf
.
setSaltLength
(
slength
);
write_field_data_to_files
(
resraw
,
tf
,
db
,
table
,
tf
.
getOriginalFieldMeta
()
->
getFieldName
());
write_field_data_to_files
(
resraw
,
tf
,
db
,
table
,
tf
.
getOriginalFieldMeta
()
->
getFieldName
());
}
}
write_meta_new
(
res
,
db
,
table
);
//generate the backup query and then fetch the tuples
//generate the backup query and then fetch the tuples
(
void
)
getSelectQuery
;
(
void
)
getSelectQuery
;
(
void
)
getSelectField
;
(
void
)
getSelectField
;
/*
/*
write_raw_data_to_files(resraw,res,db,table);
write_raw_data_to_files(resraw,res,db,table);
*/
*/
...
...
util/constants.cc
View file @
0fa3f2a9
#include "util/constants.hh"
#include "util/constants.hh"
#include "util/util.hh"
#include <string>
#include <string>
#include <fstream>
#include <fstream>
...
@@ -19,6 +20,8 @@ globalConstants initGlobalConstants(){
...
@@ -19,6 +20,8 @@ globalConstants initGlobalConstants(){
globalConstants
res
;
globalConstants
res
;
std
::
string
line
;
std
::
string
line
;
while
(
std
::
getline
(
infile
,
line
))
{
while
(
std
::
getline
(
infile
,
line
))
{
if
(
line
.
size
()
==
0
)
continue
;
if
(
line
[
0
]
==
'#'
)
continue
;
int
index
=
line
.
find
(
":"
);
int
index
=
line
.
find
(
":"
);
std
::
string
head
=
line
.
substr
(
0
,
index
);
std
::
string
head
=
line
.
substr
(
0
,
index
);
if
(
head
==
"loadCount"
)
{
if
(
head
==
"loadCount"
)
{
...
@@ -63,7 +66,50 @@ globalConstants initGlobalConstants(){
...
@@ -63,7 +66,50 @@ globalConstants initGlobalConstants(){
}
}
}
else
if
(
head
==
"other"
)
{
}
else
if
(
head
==
"other"
)
{
;
;
}
else
{
}
else
if
(
head
==
"BS_STR"
){
std
::
string
sub
=
line
.
substr
(
index
+
1
);
if
(
sub
==
"NA"
){
res
.
BS_STR
=
0
;
}
else
if
(
sub
==
"MIN"
){
res
.
BS_STR
=
1
;
}
else
if
(
sub
==
"MIDEAN"
){
res
.
BS_STR
=
2
;
}
else
if
(
sub
==
"FULL"
){
res
.
BS_STR
=
3
;
}
else
{
POINT
assert
(
0
);
}
}
else
if
(
head
==
"BS_IA"
){
std
::
string
sub
=
line
.
substr
(
index
+
1
);
if
(
sub
==
"NA"
){
res
.
BS_IA
=
0
;
}
else
if
(
sub
==
"MIN"
){
res
.
BS_IA
=
1
;
}
else
if
(
sub
==
"MIDEAN"
){
res
.
BS_IA
=
2
;
}
else
if
(
sub
==
"FULL"
){
res
.
BS_IA
=
3
;
}
else
{
POINT
assert
(
0
);
}
}
else
if
(
head
==
"BS_IH"
){
std
::
string
sub
=
line
.
substr
(
index
+
1
);
if
(
sub
==
"NA"
){
res
.
BS_IH
=
0
;
}
else
if
(
sub
==
"MIN"
){
res
.
BS_IH
=
1
;
}
else
if
(
sub
==
"MIDEAN"
){
res
.
BS_IH
=
2
;
}
else
if
(
sub
==
"FULL"
){
res
.
BS_IH
=
3
;
}
else
{
POINT
assert
(
0
);
}
}
else
{
POINT
assert
(
0
);
assert
(
0
);
}
}
}
}
...
...
util/constants.hh
View file @
0fa3f2a9
...
@@ -18,6 +18,9 @@ struct globalConstants{
...
@@ -18,6 +18,9 @@ struct globalConstants{
bool
useSWP
;
bool
useSWP
;
bool
useDET
;
bool
useDET
;
bool
useSalt
;
bool
useSalt
;
int
BS_STR
;
int
BS_IA
;
int
BS_IH
;
std
::
string
logFile
;
/*file name for log*/
std
::
string
logFile
;
/*file name for log*/
};
};
...
...
wrapper/common.cc
View file @
0fa3f2a9
...
@@ -196,7 +196,6 @@ string TableMetaTrans::serialize_vec_str(string s,vector<string> vec_str){
...
@@ -196,7 +196,6 @@ string TableMetaTrans::serialize_vec_str(string s,vector<string> vec_str){
return
s
;
return
s
;
}
}
vector
<
string
>
TableMetaTrans
::
string_to_vec_str
(
string
line
){
vector
<
string
>
TableMetaTrans
::
string_to_vec_str
(
string
line
){
int
start
=
0
,
next
=
0
;
int
start
=
0
,
next
=
0
;
vector
<
string
>
tmp
;
vector
<
string
>
tmp
;
...
@@ -244,6 +243,65 @@ bool TableMetaTrans::make_path(string directory){
...
@@ -244,6 +243,65 @@ bool TableMetaTrans::make_path(string directory){
return
true
;
return
true
;
}
}
void
TableMetaTrans
::
serializeNew
(
std
::
string
fullpath
){
FILE
*
localmeta
=
NULL
;
localmeta
=
fopen
((
fullpath
).
c_str
(),
"w"
);
string
s
=
string
(
"database:"
)
+
db
;
s
+=
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
s
=
string
(
"table:"
)
+
table
;
s
+=
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
for
(
unsigned
int
i
=
0u
;
i
<
fts
.
size
();
i
++
)
{
//serilize every field
s
=
string
(
"INDEX:"
)
+
fts
[
i
].
getFieldPlainName
()
+
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
//then for each index, that is, for each plain field
s
=
serialize_vec_str
(
"ChoosenOnionName"
,
fts
[
i
].
getChoosenOnionName
());
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
std
::
vector
<
int
>
tmp
;
for
(
auto
item
:
fts
[
i
].
getChoosenOnionO
()){
tmp
.
push_back
(
static_cast
<
int
>
(
item
));
}
s
=
serialize_vec_int
(
"choosenOnionO"
,
tmp
);
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
if
(
fts
[
i
].
getHasSalt
()){
s
=
std
::
string
(
"hasSalt:true
\n
"
);
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
s
=
std
::
string
(
"saltName:"
)
+
fts
[
i
].
getSaltName
()
+
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
s
=
std
::
string
(
"saltType:"
)
+
std
::
to_string
(
fts
[
i
].
getSaltType
())
+
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
s
=
std
::
string
(
"saltLength:"
)
+
std
::
to_string
(
fts
[
i
].
getSaltLength
())
+
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
}
else
{
s
=
std
::
string
(
"hasSalt:false
\n
"
);
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
}
s
=
serialize_vec_int
(
"choosenFieldTypes"
,
fts
[
i
].
getChoosenFieldTypes
());
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
s
=
serialize_vec_int
(
"choosenFieldLengths"
,
fts
[
i
].
getChoosenFieldLengths
());
FieldMetaTrans
::
FILEFORMAT
fmf
=
fts
[
i
].
getFeidlStoreFormat
();
if
(
fmf
==
FieldMetaTrans
::
FILEFORMAT
::
ESP_STRING
){
s
+=
"fieldFileFormat:ESP_STRING
\n
"
;
}
else
if
(
fmf
==
FieldMetaTrans
::
FILEFORMAT
::
NUM_STRING
){
s
+=
"fieldFileFormat:NUM_STRING
\n
"
;
}
else
if
(
fmf
==
FieldMetaTrans
::
FILEFORMAT
::
NUM_BINARY
){
s
+=
"fieldFileFormat:NUM_BINARY
\n
"
;
}
else
{
s
+=
"fieldFileFormat:NA
\n
"
;
}
s
+=
"
\n
"
;
fwrite
(
s
.
c_str
(),
1
,
s
.
size
(),
localmeta
);
}
fwrite
(
"**********************************************************************
\n
"
,
1
,
71
,
localmeta
);
fclose
(
localmeta
);
}
void
TableMetaTrans
::
serialize
(
std
::
string
filename
,
std
::
string
prefix
){
void
TableMetaTrans
::
serialize
(
std
::
string
filename
,
std
::
string
prefix
){
FILE
*
localmeta
=
NULL
;
FILE
*
localmeta
=
NULL
;
...
...
wrapper/common.hh
View file @
0fa3f2a9
...
@@ -87,6 +87,7 @@ public:
...
@@ -87,6 +87,7 @@ public:
void
set_db_table
(
string
idb
,
string
itable
){
db
=
idb
;
table
=
itable
;}
void
set_db_table
(
string
idb
,
string
itable
){
db
=
idb
;
table
=
itable
;}
void
serialize
(
std
::
string
filename
=
"metadata.data"
,
std
::
string
prefix
=
"data/"
);
void
serialize
(
std
::
string
filename
=
"metadata.data"
,
std
::
string
prefix
=
"data/"
);
void
serializeNew
(
std
::
string
fullpath
);
void
deserialize
(
std
::
string
filename
=
"metadata.data"
,
std
::
string
prefix
=
"data/"
);
void
deserialize
(
std
::
string
filename
=
"metadata.data"
,
std
::
string
prefix
=
"data/"
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment