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
2e881054
Commit
2e881054
authored
Apr 22, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tools/test_global_insert
parent
27906858
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
208 additions
and
1 deletion
+208
-1
try_insert.cc
debug/try_insert.cc
+0
-1
.multi_fast_insert.cc.swp
tools/.multi_fast_insert.cc.swp
+0
-0
README.md
tools/README.md
+1
-0
multi_fast_insert.cc
tools/multi_fast_insert.cc
+54
-0
test_global_insert.cc
tools/test_global_insert.cc
+153
-0
test_insert.cc
tools/test_insert.cc
+0
-0
No files found.
debug/try_insert.cc
View file @
2e881054
...
...
@@ -87,7 +87,6 @@ static std::string getInsertResults(Analysis a,LEX* lex){
return
lexToQuery
(
*
new_lex
);
}
static
void
testInsertHandler
(
std
::
string
query
){
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
...
...
tools/.multi_fast_insert.cc.swp
0 → 100644
View file @
2e881054
File added
tools/README.md
0 → 100644
View file @
2e881054
tools for experiments
tools/multi_fast_insert.cc
0 → 100644
View file @
2e881054
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <vector>
#include "redisbio/zmalloc.h"
#include "redisbio/adlist.h"
#include "redisbio/bio.h"
//return 0 to continue, return 1 to exit.
static
int
work
(
unsigned
long
id
,
void
*
input
){
struct
bio_job
*
task
=
(
struct
bio_job
*
)
input
;
if
(
task
->
stop
==
1
)
return
1
;
char
*
query
=
(
char
*
)(
task
->
arg1
);
(
void
)
query
;
printf
(
"id=%lu %s
\n
"
,
id
,
query
);
return
0
;
}
int
main
(){
userFunction
=
work
;
bioInit
();
std
::
vector
<
std
::
string
>
input
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
};
int
type
=
0
;
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
bioCreateBackgroundJob
(
type
,(
input
[
i
%
10
].
c_str
()),
NULL
,
0
);
type
+=
1
;
type
%=
10
;
}
//Only ten threads
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
bioCreateBackgroundJob
(
type
,
NULL
,
NULL
,
1
);
type
+=
1
;
type
%=
10
;
}
printf
(
"tobe joined
\n
"
);
bioKillThreads
();
return
0
;
}
tools/test_global_insert.cc
0 → 100644
View file @
2e881054
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <functional>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <main/Connect.hh>
#include <main/rewrite_util.hh>
#include <main/sql_handler.hh>
#include <main/dml_handler.hh>
#include <main/ddl_handler.hh>
#include <main/CryptoHandlers.hh>
#include <main/rewrite_main.hh>
#include "util/util.hh"
#include "redisbio/zmalloc.h"
#include "redisbio/adlist.h"
#include "redisbio/bio.h"
extern
CItemTypesDir
itemTypes
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
//expand the item
template
<
typename
ContainerType
>
void
myRewriteInsertHelper
(
const
Item
&
i
,
const
FieldMeta
&
fm
,
Analysis
&
a
,
ContainerType
*
const
append_list
){
std
::
vector
<
Item
*>
l
;
itemTypes
.
do_rewrite_insert
(
i
,
fm
,
a
,
&
l
);
for
(
auto
it
:
l
)
{
append_list
->
push_back
(
it
);
}
}
static
std
::
string
getInsertResults
(
Analysis
a
,
LEX
*
lex
){
LEX
*
const
new_lex
=
copyWithTHD
(
lex
);
const
std
::
string
&
table
=
lex
->
select_lex
.
table_list
.
first
->
table_name
;
const
std
::
string
&
db_name
=
lex
->
select_lex
.
table_list
.
first
->
db
;
//from databasemeta to tablemeta.
const
TableMeta
&
tm
=
a
.
getTableMeta
(
db_name
,
table
);
//rewrite table name
new_lex
->
select_lex
.
table_list
.
first
=
rewrite_table_list
(
lex
->
select_lex
.
table_list
.
first
,
a
);
std
::
vector
<
FieldMeta
*>
fmVec
;
std
::
vector
<
FieldMeta
*>
fmetas
=
tm
.
orderedFieldMetas
();
fmVec
.
assign
(
fmetas
.
begin
(),
fmetas
.
end
());
if
(
lex
->
many_values
.
head
())
{
auto
it
=
List_iterator
<
List_item
>
(
lex
->
many_values
);
List
<
List_item
>
newList
;
for
(;;)
{
List_item
*
const
li
=
it
++
;
if
(
!
li
)
{
break
;
}
List
<
Item
>
*
const
newList0
=
new
List
<
Item
>
();
if
(
li
->
elements
!=
fmVec
.
size
())
{
exit
(
0
);
}
else
{
auto
it0
=
List_iterator
<
Item
>
(
*
li
);
auto
fmVecIt
=
fmVec
.
begin
();
for
(;;)
{
const
Item
*
const
i
=
it0
++
;
assert
(
!!
i
==
(
fmVec
.
end
()
!=
fmVecIt
));
if
(
!
i
)
{
break
;
}
myRewriteInsertHelper
(
*
i
,
**
fmVecIt
,
a
,
newList0
);
++
fmVecIt
;
}
}
newList
.
push_back
(
newList0
);
}
new_lex
->
many_values
=
newList
;
}
return
lexToQuery
(
*
new_lex
);
return
"aa"
;
}
SchemaInfo
*
gschema
;
AES_KEY
*
gkey
;
std
::
string
gdb
=
"tdb"
;
static
int
ginsertFunction
(
unsigned
long
id
,
void
*
input
){
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
gkey
);
Analysis
analysis
(
gdb
,
*
gschema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
std
::
unique_ptr
<
query_parse
>
p
;
struct
bio_job
*
task
=
(
struct
bio_job
*
)
input
;
if
(
task
->
stop
==
1
)
return
1
;
char
*
q
=
(
char
*
)(
task
->
arg1
);
std
::
string
query
(
q
);
p
=
std
::
unique_ptr
<
query_parse
>
(
new
query_parse
(
gdb
,
query
));
LEX
*
const
lex
=
p
->
lex
();
std
::
cout
<<
getInsertResults
(
analysis
,
lex
)
<<
std
::
endl
;
(
void
)
lex
;
return
0
;
}
static
void
testInsertHandler
(){
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
gschema
=
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
;
};
loadChildren
(
gschema
);
gkey
=
getKey
(
std
::
string
(
"113341234"
));
}
int
main
()
{
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
//Free to remove memory leak
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
const
std
::
string
master_key
=
"113341234"
;
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
UNUSED
(
ci
);
//Clean!!
free
(
buffer
);
//this function alone has memory leak
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
shared_ps
!=
NULL
);
UNUSED
(
testInsertHandler
);
UNUSED
(
getInsertResults
);
std
::
string
query1
=
"insert into student values(1,
\"
zhangfei
\"
)"
;
std
::
vector
<
std
::
string
>
queries
{
query1
};
for
(
unsigned
int
i
=
0u
;
i
<
100u
;
i
++
){
//queries.push_back(query1);
}
for
(
auto
item
:
queries
){
testInsertHandler
();
struct
bio_job
*
job
=
(
struct
bio_job
*
)
zmalloc
(
sizeof
(
*
job
));
job
->
arg1
=
(
void
*
)(
item
.
c_str
());
ginsertFunction
(
1
,
job
);
}
return
0
;
}
tools/t
ry
_insert.cc
→
tools/t
est
_insert.cc
View file @
2e881054
File moved
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