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
6920a01b
Commit
6920a01b
authored
Jan 14, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split load_and_store and we have load.cc and store.cc in debug
parent
e103d88e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
840 additions
and
105 deletions
+840
-105
load.cc
debug/load.cc
+725
-0
store.cc
debug/store.cc
+1
-105
store.hh
debug/store.hh
+114
-0
No files found.
debug/load.cc
0 → 100644
View file @
6920a01b
This diff is collapsed.
Click to expand it.
debug/
load_and_
store.cc
→
debug/store.cc
View file @
6920a01b
#include "debug/
load_and_
store.hh"
#include "debug/store.hh"
/*for each field, convert the format to transField*/
/*for each field, convert the format to transField*/
static
std
::
vector
<
transField
>
getTransField
(
std
::
vector
<
FieldMeta
*>
pfms
){
static
std
::
vector
<
transField
>
getTransField
(
std
::
vector
<
FieldMeta
*>
pfms
){
...
@@ -23,79 +23,6 @@ static std::vector<transField> getTransField(std::vector<FieldMeta *> pfms){
...
@@ -23,79 +23,6 @@ static std::vector<transField> getTransField(std::vector<FieldMeta *> pfms){
}
}
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
function
<
DBMeta
*
(
DBMeta
*
const
)
>
loadChildren
=
[
&
loadChildren
,
&
e_conn
](
DBMeta
*
const
parent
)
{
auto
kids
=
parent
->
fetchChildren
(
e_conn
);
for
(
auto
it
:
kids
)
{
loadChildren
(
it
);
}
return
parent
;
};
//load all metadata and then store it in schema
loadChildren
(
schema
.
get
());
Analysis
analysis
(
std
::
string
(
"student"
),
*
schema
,
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
))),
SECURITY_RATING
::
SENSITIVE
);
return
schema
;
}
static
void
addToReturn
(
ReturnMeta
*
const
rm
,
int
pos
,
const
OLK
&
constr
,
bool
has_salt
,
const
std
::
string
&
name
)
{
const
bool
test
=
static_cast
<
unsigned
int
>
(
pos
)
==
rm
->
rfmeta
.
size
();
TEST_TextMessageError
(
test
,
"ReturnMeta has badly ordered"
" ReturnFields!"
);
const
int
salt_pos
=
has_salt
?
pos
+
1
:
-
1
;
std
::
pair
<
int
,
ReturnField
>
pair
(
pos
,
ReturnField
(
false
,
name
,
constr
,
salt_pos
));
rm
->
rfmeta
.
insert
(
pair
);
}
static
void
addSaltToReturn
(
ReturnMeta
*
const
rm
,
int
pos
)
{
const
bool
test
=
static_cast
<
unsigned
int
>
(
pos
)
==
rm
->
rfmeta
.
size
();
TEST_TextMessageError
(
test
,
"ReturnMeta has badly ordered"
" ReturnFields!"
);
std
::
pair
<
int
,
ReturnField
>
pair
(
pos
,
ReturnField
(
true
,
""
,
OLK
::
invalidOLK
(),
-
1
));
rm
->
rfmeta
.
insert
(
pair
);
}
//get returnMeta
//for each filed, we have a fieldmeta. we can chosse one onion under that field to construct a return meta.
//in fact, a returnmeta can contain many fields.
static
std
::
shared_ptr
<
ReturnMeta
>
getReturnMeta
(
std
::
vector
<
FieldMeta
*>
fms
,
std
::
vector
<
transField
>
&
tfds
){
assert
(
fms
.
size
()
==
tfds
.
size
());
std
::
shared_ptr
<
ReturnMeta
>
myReturnMeta
=
std
::
make_shared
<
ReturnMeta
>
();
int
pos
=
0
;
//construct OLK
for
(
auto
i
=
0u
;
i
<
tfds
.
size
();
i
++
){
OLK
curOLK
(
tfds
[
i
].
onions
[
tfds
[
i
].
onionIndex
],
tfds
[
i
].
originalOm
[
tfds
[
i
].
onionIndex
]
->
getSecLevel
(),
tfds
[
i
].
originalFm
);
addToReturn
(
myReturnMeta
.
get
(),
pos
++
,
curOLK
,
true
,
tfds
[
i
].
originalFm
->
getFieldName
());
addSaltToReturn
(
myReturnMeta
.
get
(),
pos
++
);
}
return
myReturnMeta
;
}
//query for testing purposes
//query for testing purposes
static
static
std
::
string
getTestQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
getTestQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
...
@@ -188,37 +115,6 @@ static void write_meta(rawMySQLReturnValue& resraw,string db,string table){
...
@@ -188,37 +115,6 @@ static void write_meta(rawMySQLReturnValue& resraw,string db,string table){
fclose
(
localmeta
);
fclose
(
localmeta
);
}
}
struct
meta_file
{
string
db
,
table
;
int
num_of_fields
;
vector
<
string
>
field_types
;
vector
<
int
>
field_lengths
;
vector
<
string
>
field_names
;
vector
<
int
>
choosen_onions
;
void
show
(){
cout
<<
db
<<
endl
;
cout
<<
table
<<
endl
;
cout
<<
num_of_fields
<<
endl
;
for
(
auto
item
:
field_types
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
field_lengths
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
field_names
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
choosen_onions
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
}
};
static
void
write_row_data
(
rawMySQLReturnValue
&
resraw
,
string
db
,
string
table
){
static
void
write_row_data
(
rawMySQLReturnValue
&
resraw
,
string
db
,
string
table
){
vector
<
FILE
*>
data_files
;
vector
<
FILE
*>
data_files
;
...
...
debug/
load_and_
store.hh
→
debug/store.hh
View file @
6920a01b
...
@@ -214,3 +214,117 @@ getFieldMeta(SchemaInfo &schema,
...
@@ -214,3 +214,117 @@ getFieldMeta(SchemaInfo &schema,
return
std
::
vector
<
FieldMeta
*>
();
return
std
::
vector
<
FieldMeta
*>
();
}
}
}
}
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
function
<
DBMeta
*
(
DBMeta
*
const
)
>
loadChildren
=
[
&
loadChildren
,
&
e_conn
](
DBMeta
*
const
parent
)
{
auto
kids
=
parent
->
fetchChildren
(
e_conn
);
for
(
auto
it
:
kids
)
{
loadChildren
(
it
);
}
return
parent
;
};
//load all metadata and then store it in schema
loadChildren
(
schema
.
get
());
Analysis
analysis
(
std
::
string
(
"student"
),
*
schema
,
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
))),
SECURITY_RATING
::
SENSITIVE
);
return
schema
;
}
static
void
addToReturn
(
ReturnMeta
*
const
rm
,
int
pos
,
const
OLK
&
constr
,
bool
has_salt
,
const
std
::
string
&
name
)
{
const
bool
test
=
static_cast
<
unsigned
int
>
(
pos
)
==
rm
->
rfmeta
.
size
();
TEST_TextMessageError
(
test
,
"ReturnMeta has badly ordered"
" ReturnFields!"
);
const
int
salt_pos
=
has_salt
?
pos
+
1
:
-
1
;
std
::
pair
<
int
,
ReturnField
>
pair
(
pos
,
ReturnField
(
false
,
name
,
constr
,
salt_pos
));
rm
->
rfmeta
.
insert
(
pair
);
}
static
void
addSaltToReturn
(
ReturnMeta
*
const
rm
,
int
pos
)
{
const
bool
test
=
static_cast
<
unsigned
int
>
(
pos
)
==
rm
->
rfmeta
.
size
();
TEST_TextMessageError
(
test
,
"ReturnMeta has badly ordered"
" ReturnFields!"
);
std
::
pair
<
int
,
ReturnField
>
pair
(
pos
,
ReturnField
(
true
,
""
,
OLK
::
invalidOLK
(),
-
1
));
rm
->
rfmeta
.
insert
(
pair
);
}
//get returnMeta
//for each filed, we have a fieldmeta. we can chosse one onion under that field to construct a return meta.
//in fact, a returnmeta can contain many fields.
static
std
::
shared_ptr
<
ReturnMeta
>
getReturnMeta
(
std
::
vector
<
FieldMeta
*>
fms
,
std
::
vector
<
transField
>
&
tfds
){
assert
(
fms
.
size
()
==
tfds
.
size
());
std
::
shared_ptr
<
ReturnMeta
>
myReturnMeta
=
std
::
make_shared
<
ReturnMeta
>
();
int
pos
=
0
;
//construct OLK
for
(
auto
i
=
0u
;
i
<
tfds
.
size
();
i
++
){
OLK
curOLK
(
tfds
[
i
].
onions
[
tfds
[
i
].
onionIndex
],
tfds
[
i
].
originalOm
[
tfds
[
i
].
onionIndex
]
->
getSecLevel
(),
tfds
[
i
].
originalFm
);
addToReturn
(
myReturnMeta
.
get
(),
pos
++
,
curOLK
,
true
,
tfds
[
i
].
originalFm
->
getFieldName
());
addSaltToReturn
(
myReturnMeta
.
get
(),
pos
++
);
}
return
myReturnMeta
;
}
struct
meta_file
{
string
db
,
table
;
int
num_of_fields
;
vector
<
string
>
field_types
;
vector
<
int
>
field_lengths
;
vector
<
string
>
field_names
;
vector
<
int
>
choosen_onions
;
void
show
(){
cout
<<
db
<<
endl
;
cout
<<
table
<<
endl
;
cout
<<
num_of_fields
<<
endl
;
for
(
auto
item
:
field_types
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
field_lengths
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
field_names
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
for
(
auto
item
:
choosen_onions
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
}
};
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