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
08888b87
Commit
08888b87
authored
Apr 22, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
still core dump
parent
61246c42
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
151 additions
and
30 deletions
+151
-30
multi_fast_insert.cc
tools/multi_fast_insert.cc
+145
-24
test_global_insert.cc
tools/test_global_insert.cc
+6
-6
No files found.
tools/multi_fast_insert.cc
View file @
08888b87
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <
string
>
#include <
iostream
>
#include <vector>
#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/zmalloc.h"
#include "redisbio/adlist.h"
#include "redisbio/adlist.h"
#include "redisbio/bio.h"
#include "redisbio/bio.h"
//return 0 to continue, return 1 to exit.
extern
CItemTypesDir
itemTypes
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
SchemaInfo
*
gschema
;
AES_KEY
*
gkey
;
std
::
string
gdb
=
"tdb"
;
Analysis
*
ganalysis
=
NULL
;
//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
){
std
::
cout
<<
"###################"
<<
std
::
endl
;
if
(
lex
==
NULL
)
return
"aa"
;
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"
;
}
static
static
int
int
work
(
unsigned
long
id
,
void
*
input
){
ginsertFunction
(
unsigned
long
id
,
void
*
input
){
struct
bio_job
*
task
=
(
struct
bio_job
*
)
input
;
struct
bio_job
*
task
=
(
struct
bio_job
*
)
input
;
if
(
task
->
stop
==
1
)
return
1
;
if
(
task
->
stop
==
1
)
return
1
;
char
*
query
=
(
char
*
)(
task
->
arg1
);
LEX
*
lex
=
(
LEX
*
)(
task
->
arg1
);
(
void
)
query
;
std
::
cout
<<
getInsertResults
(
*
ganalysis
,
lex
)
<<
std
::
endl
;
printf
(
"id=%lu %s
\n
"
,
id
,
query
)
;
(
void
)
lex
;
return
0
;
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
int
main
(){
main
(){
userFunction
=
work
;
userFunction
=
ginsertFunction
;
bioInit
();
bioInit
();
std
::
vector
<
std
::
string
>
input
{
char
*
buffer
;
"a"
,
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
"b"
,
perror
(
"getcwd error"
);
"c"
,
}
"d"
,
//Free to remove memory leak
"e"
,
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
"f"
,
const
std
::
string
master_key
=
"113341234"
;
"g"
,
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
"h"
,
UNUSED
(
ci
);
"i"
,
//Clean!!
"j"
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
);
}
testInsertHandler
();
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
gkey
);
Analysis
analysis
(
gdb
,
*
gschema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
ganalysis
=
&
analysis
;
std
::
vector
<
LEX
*>
qa
(
100
,
NULL
);
//send work
int
type
=
0
;
int
type
=
0
;
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
bioCreateBackgroundJob
(
type
,(
input
[
i
%
10
].
c_str
()),
NULL
,
0
);
query_parse
*
p
=
new
query_parse
(
gdb
,
queries
[
i
]);
LEX
*
const
lex
=
p
->
lex
();
qa
[
i
]
=
lex
;
}
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
bioCreateBackgroundJob
(
type
,
qa
[
i
],
NULL
,
0
);
type
+=
1
;
type
+=
1
;
type
%=
10
;
type
%=
10
;
}
}
//Only ten threads
//Only ten threads to terminate
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
bioCreateBackgroundJob
(
type
,
NULL
,
NULL
,
1
);
bioCreateBackgroundJob
(
type
,
NULL
,
NULL
,
1
);
type
+=
1
;
type
+=
1
;
...
...
tools/test_global_insert.cc
View file @
08888b87
...
@@ -21,6 +21,11 @@
...
@@ -21,6 +21,11 @@
extern
CItemTypesDir
itemTypes
;
extern
CItemTypesDir
itemTypes
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
SchemaInfo
*
gschema
;
AES_KEY
*
gkey
;
std
::
string
gdb
=
"tdb"
;
//expand the item
//expand the item
template
<
typename
ContainerType
>
template
<
typename
ContainerType
>
void
myRewriteInsertHelper
(
const
Item
&
i
,
const
FieldMeta
&
fm
,
Analysis
&
a
,
void
myRewriteInsertHelper
(
const
Item
&
i
,
const
FieldMeta
&
fm
,
Analysis
&
a
,
...
@@ -32,7 +37,6 @@ void myRewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a,
...
@@ -32,7 +37,6 @@ void myRewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a,
}
}
}
}
static
std
::
string
static
std
::
string
getInsertResults
(
Analysis
a
,
LEX
*
lex
){
getInsertResults
(
Analysis
a
,
LEX
*
lex
){
LEX
*
const
new_lex
=
copyWithTHD
(
lex
);
LEX
*
const
new_lex
=
copyWithTHD
(
lex
);
...
@@ -80,10 +84,6 @@ getInsertResults(Analysis a,LEX* lex){
...
@@ -80,10 +84,6 @@ getInsertResults(Analysis a,LEX* lex){
return
"aa"
;
return
"aa"
;
}
}
SchemaInfo
*
gschema
;
AES_KEY
*
gkey
;
std
::
string
gdb
=
"tdb"
;
static
static
int
int
ginsertFunction
(
unsigned
long
id
,
void
*
input
){
ginsertFunction
(
unsigned
long
id
,
void
*
input
){
...
@@ -141,7 +141,7 @@ main() {
...
@@ -141,7 +141,7 @@ main() {
std
::
string
query1
=
"insert into student values(1,
\"
zhangfei
\"
)"
;
std
::
string
query1
=
"insert into student values(1,
\"
zhangfei
\"
)"
;
std
::
vector
<
std
::
string
>
queries
{
query1
};
std
::
vector
<
std
::
string
>
queries
{
query1
};
for
(
unsigned
int
i
=
0u
;
i
<
100u
;
i
++
){
for
(
unsigned
int
i
=
0u
;
i
<
100u
;
i
++
){
//
queries.push_back(query1);
queries
.
push_back
(
query1
);
}
}
for
(
auto
item
:
queries
){
for
(
auto
item
:
queries
){
testInsertHandler
();
testInsertHandler
();
...
...
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