Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ranadeep Biswas
dbcop
Commits
7dffcd67
Commit
7dffcd67
authored
Mar 08, 2019
by
Ranadeep Biswas
Browse files
linearization utils
parent
393b40c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/consistency/sat.rs
View file @
7dffcd67
...
...
@@ -281,7 +281,7 @@ impl Sat {
self
.add_clauses
(
&
clauses
);
}
pub
fn
solve
(
&
self
,
path
:
&
PathBuf
)
->
bool
{
pub
fn
solve
(
&
self
,
path
:
&
PathBuf
)
->
Option
<
Vec
<
(
usize
,
usize
)
>>
{
let
inp_cnf
=
path
.join
(
"history.cnf"
);
let
out_cnf
=
path
.join
(
"result.cnf"
);
self
.cnf
.write_to_file
(
&
inp_cnf
);
...
...
@@ -341,15 +341,40 @@ impl Sat {
edges
.sort_unstable
();
// building co
let
mut
parents
:
HashMap
<
(
usize
,
usize
),
HashSet
<
(
usize
,
usize
)
>>
=
Default
::
default
();
for
e
in
&
edges
{
if
e
.0
==
Edge
::
CO
{
println!
(
"{:?}"
,
e
);
parents
.entry
(
e
.2
)
.or_insert_with
(
Default
::
default
)
.insert
(
e
.1
);
parents
.entry
(
e
.1
)
.or_insert_with
(
Default
::
default
);
}
}
let
mut
lin
=
Vec
::
new
();
while
!
parents
.is_empty
()
{
let
next_t
:
Vec
<
_
>
=
parents
.iter
()
.filter_map
(|(
t1
,
t2s
)|
if
t2s
.is_empty
()
{
Some
(
*
t1
)
}
else
{
None
})
.collect
();
assert_eq!
(
next_t
.len
(),
1
);
parents
.retain
(|
_
,
t2s
|
!
t2s
.is_empty
());
for
(
_
,
t2s
)
in
parents
.iter_mut
()
{
t2s
.remove
(
&
next_t
[
0
]);
}
lin
.push
(
next_t
[
0
]);
}
true
Some
(
lin
)
}
else
{
fals
e
Non
e
}
}
...
...
src/verifier/mod.rs
View file @
7dffcd67
...
...
@@ -415,7 +415,7 @@ impl Verifier {
_
=>
unreachable!
(),
}
sat_solver
.solve
(
&
self
.dir
)
sat_solver
.solve
(
&
self
.dir
)
.is_some
()
}
else
{
info!
(
self
.log
,
"using our algorithms"
);
...
...
@@ -475,7 +475,32 @@ impl Verifier {
if
ser_hist
.history.vis
.has_cycle
()
{
false
}
else
{
ser_hist
.get_linearization
()
.is_some
()
let
lin_o
=
ser_hist
.get_linearization
();
{
// checking correctness
if
let
Some
(
ref
lin
)
=
lin_o
{
let
mut
curr_value_map
:
HashMap
<
usize
,
(
usize
,
usize
)
>
=
Default
::
default
();
for
txn_id
in
lin
.iter
()
{
let
(
read_info
,
write_info
)
=
transaction_infos
.get
(
txn_id
)
.unwrap
();
for
(
x
,
txn1
)
in
read_info
.iter
()
{
match
curr_value_map
.get
(
&
x
)
{
Some
(
txn1_
)
=>
assert_eq!
(
txn1_
,
txn1
),
_
=>
unreachable!
(),
}
}
for
&
x
in
write_info
.iter
()
{
curr_value_map
.insert
(
x
,
*
txn_id
);
}
// if !write_info.is_empty() {
// println!("{:?}", txn_id);
// println!("{:?}", curr_value_map);
// }
}
}
}
lin_o
.is_some
()
}
}
_
=>
unreachable!
(),
...
...
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