Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
8ae43b3b
Commit
8ae43b3b
authored
Apr 01, 2019
by
preetwinder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reimplement repair
parent
9f2e7bd5
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
259 additions
and
240 deletions
+259
-240
src/jio.storage/indexstorage2.js
src/jio.storage/indexstorage2.js
+153
-117
test/jio.storage/indexstorage2.tests.js
test/jio.storage/indexstorage2.tests.js
+106
-123
No files found.
src/jio.storage/indexstorage2.js
View file @
8ae43b3b
This diff is collapsed.
Click to expand it.
test/jio.storage/indexstorage2.tests.js
View file @
8ae43b3b
...
@@ -241,6 +241,14 @@
...
@@ -241,6 +241,14 @@
// indexStorage2.buildQuery
// indexStorage2.buildQuery
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
indexStorage2.buildQuery
"
,
{
module
(
"
indexStorage2.buildQuery
"
,
{
setup
:
function
()
{
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
)
||
(
name
===
'
include
'
);
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
[];
};
},
teardown
:
function
()
{
teardown
:
function
()
{
deleteIndexedDB
(
this
.
jio
);
deleteIndexedDB
(
this
.
jio
);
}
}
...
@@ -257,24 +265,22 @@
...
@@ -257,24 +265,22 @@
}
}
});
});
stop
();
stop
();
expect
(
3
);
expect
(
2
);
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
return
id
;
return
id
;
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
name
===
"
list
"
;
};
DummyStorage3
.
prototype
.
buildQuery
=
function
(
options
)
{
DummyStorage3
.
prototype
.
buildQuery
=
function
(
options
)
{
deepEqual
(
options
,
{});
if
(
options
.
include_docs
!==
true
)
{
return
[
return
[
{
id
:
"
2
"
,
value
:
{}},
{
id
:
"
2
"
,
value
:
{}},
{
id
:
"
32
"
,
value
:
{}},
{
id
:
"
32
"
,
value
:
{}},
{
id
:
"
16
"
,
value
:
{}},
{
id
:
"
16
"
,
value
:
{}},
{
id
:
"
21
"
,
value
:
{}}
{
id
:
"
21
"
,
value
:
{}}
];
];
}
return
[];
};
};
RSVP
.
all
([
RSVP
.
all
([
...
@@ -322,6 +328,9 @@
...
@@ -322,6 +328,9 @@
};
};
DummyStorage3
.
prototype
.
buildQuery
=
function
(
options
)
{
DummyStorage3
.
prototype
.
buildQuery
=
function
(
options
)
{
if
(
options
.
include_docs
===
true
)
{
return
[];
}
deepEqual
(
options
,
{
include_docs
:
false
,
select_list
:
[
"
a
"
,
"
c
"
],
deepEqual
(
options
,
{
include_docs
:
false
,
select_list
:
[
"
a
"
,
"
c
"
],
limit
:
3
,
sort_on
:
[[
"
a
"
,
"
descending
"
],
[
"
b
"
,
"
ascending
"
]]});
limit
:
3
,
sort_on
:
[[
"
a
"
,
"
descending
"
],
[
"
b
"
,
"
ascending
"
]]});
return
[
return
[
...
@@ -463,10 +472,20 @@
...
@@ -463,10 +472,20 @@
deepEqual
(
value
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
});
deepEqual
(
value
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
});
return
id
;
return
id
;
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
capacity
)
{
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
capacity
===
'
list
'
;
return
(
name
===
'
list
'
);
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
[{
id
:
"
32
"
,
doc
:
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
}}];
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
[{
id
:
"
32
"
,
value
:
{}}];
};
DummyStorage3
.
prototype
.
get
=
function
(
id
)
{
if
(
id
===
"
32
"
)
{
return
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
};
}
};
};
DummyStorage3
.
prototype
.
buildQuery
=
undefined
;
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
})
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
})
.
then
(
function
()
{
.
then
(
function
()
{
...
@@ -542,9 +561,6 @@
...
@@ -542,9 +561,6 @@
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
return
id
;
return
id
;
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
);
};
RSVP
.
all
([
RSVP
.
all
([
context
.
jio
.
put
(
"
1
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
}),
context
.
jio
.
put
(
"
1
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
}),
...
@@ -569,106 +585,6 @@
...
@@ -569,106 +585,6 @@
});
});
});
});
test
(
"
select_list option is preset
"
,
function
()
{
var
context
=
this
;
context
.
jio
=
jIO
.
createJIO
({
type
:
"
index2
"
,
database
:
"
index2_test
"
,
index_keys
:
[
"
a
"
,
"
b
"
,
"
c
"
],
sub_storage
:
{
type
:
"
dummystorage3
"
}
});
stop
();
expect
(
2
);
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
return
id
;
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
);
};
RSVP
.
all
([
context
.
jio
.
put
(
"
1
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
try
"
}),
context
.
jio
.
put
(
"
2
"
,
{
"
a
"
:
"
98
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
adverse
"
}),
context
.
jio
.
put
(
"
3
"
,
{
"
a
"
:
"
75
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
invite
"
}),
context
.
jio
.
put
(
"
8
"
,
{
"
a
"
:
"
43
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
absolve
"
}),
context
.
jio
.
put
(
"
6
"
,
{
"
a
"
:
"
21
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
defy
"
}),
context
.
jio
.
put
(
"
4
"
,
{
"
a
"
:
"
65
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
odd
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
select_list
:
[
"
a
"
,
"
c
"
],
query
:
"
b:2
"
});
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
4
);
deepEqual
(
result
.
data
.
rows
.
sort
(
idCompare
),
[
{
id
:
"
1
"
,
value
:
{
"
a
"
:
"
55
"
,
"
c
"
:
"
try
"
}},
{
id
:
"
2
"
,
value
:
{
"
a
"
:
"
98
"
,
"
c
"
:
"
adverse
"
}},
{
id
:
"
3
"
,
value
:
{
"
a
"
:
"
75
"
,
"
c
"
:
"
invite
"
}},
{
id
:
"
6
"
,
value
:
{
"
a
"
:
"
21
"
,
"
c
"
:
"
defy
"
}}
]);
})
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
Select_list key is not present in the index
"
,
function
()
{
var
context
=
this
;
context
.
jio
=
jIO
.
createJIO
({
type
:
"
index2
"
,
database
:
"
index2_test
"
,
index_keys
:
[
"
a
"
,
"
c
"
],
sub_storage
:
{
type
:
"
dummystorage3
"
}
});
stop
();
expect
(
3
);
DummyStorage3
.
prototype
.
put
=
function
(
id
)
{
return
id
;
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
)
||
(
name
===
'
query
'
)
||
(
name
===
'
select
'
);
};
DummyStorage3
.
prototype
.
buildQuery
=
function
(
options
)
{
deepEqual
(
options
,
{
select_list
:
[
"
a
"
,
"
b
"
],
query
:
"
a:55
"
});
return
[
{
id
:
"
1
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
}},
{
id
:
"
2
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
5
"
}},
{
id
:
"
3
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
1
"
}}
];
};
RSVP
.
all
([
context
.
jio
.
put
(
"
1
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
try
"
}),
context
.
jio
.
put
(
"
2
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
5
"
,
"
c
"
:
"
adverse
"
}),
context
.
jio
.
put
(
"
3
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
1
"
,
"
c
"
:
"
invite
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
select_list
:
[
"
a
"
,
"
b
"
],
query
:
"
a:55
"
});
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
3
);
deepEqual
(
result
.
data
.
rows
.
sort
(
idCompare
),
[
{
id
:
"
1
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
}},
{
id
:
"
2
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
5
"
}},
{
id
:
"
3
"
,
value
:
{
"
a
"
:
"
55
"
,
"
b
"
:
"
1
"
}}
]);
})
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
Index keys are modified
"
,
function
()
{
test
(
"
Index keys are modified
"
,
function
()
{
var
context
=
this
,
dummy_data
;
var
context
=
this
,
dummy_data
;
context
.
jio
=
jIO
.
createJIO
({
context
.
jio
=
jIO
.
createJIO
({
...
@@ -684,18 +600,18 @@
...
@@ -684,18 +600,18 @@
expect
(
8
);
expect
(
8
);
dummy_data
=
{
dummy_data
=
{
"
32
"
:
{
id
:
"
32
"
,
value
:
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
inverse
"
}},
"
32
"
:
{
id
:
"
32
"
,
doc
:
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
inverse
"
}},
"
5
"
:
{
id
:
"
5
"
,
value
:
{
"
a
"
:
"
6
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
strong
"
}},
"
5
"
:
{
id
:
"
5
"
,
doc
:
{
"
a
"
:
"
6
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
strong
"
}},
"
14
"
:
{
id
:
"
14
"
,
value
:
{
"
a
"
:
"
67
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
disolve
"
}}
"
14
"
:
{
id
:
"
14
"
,
doc
:
{
"
a
"
:
"
67
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
disolve
"
}}
};
};
DummyStorage3
.
prototype
.
put
=
function
(
id
,
value
)
{
DummyStorage3
.
prototype
.
put
=
function
(
id
,
value
)
{
dummy_data
[
id
]
=
{
id
:
id
,
value
:
value
};
dummy_data
[
id
]
=
{
id
:
id
,
doc
:
value
};
return
id
;
return
id
;
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
);
return
(
name
===
'
list
'
)
||
(
name
===
'
include
'
)
;
};
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
...
@@ -792,6 +708,57 @@
...
@@ -792,6 +708,57 @@
});
});
});
});
test
(
"
Parallel operation
"
,
function
()
{
var
context
=
this
,
sub_storage
,
fake_data
;
stop
();
expect
(
3
);
fake_data
=
{};
function
checkConflict
()
{
var
new_storage
=
jIO
.
createJIO
({
type
:
"
index2
"
,
index_keys
:
[
"
a
"
,
"
b
"
],
database
:
"
index2_test
"
,
sub_storage
:
{
type
:
"
dummystorage3
"
}
});
context
.
jio
=
new_storage
;
return
new_storage
.
allDocs
({
query
:
"
a:55
"
})
.
push
(
function
(
result
)
{
equal
(
result
.
data
.
rows
.
length
,
1
);
});
}
DummyStorage3
.
prototype
.
put
=
function
(
id
,
value
)
{
fake_data
[
id
]
=
{
id
:
id
,
doc
:
value
};
return
id
;
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
new
RSVP
.
Promise
(
function
(
resolve
)
{
setTimeout
(
function
()
{
resolve
(
Object
.
values
(
fake_data
));
},
1000
);
});
};
sub_storage
=
jIO
.
createJIO
({
type
:
"
dummystorage3
"
});
sub_storage
.
put
(
"
42
"
,
{
"
a
"
:
"
55
"
,
"
b
"
:
"
2
"
})
.
then
(
function
()
{
return
RSVP
.
all
([
checkConflict
(),
checkConflict
(),
checkConflict
()]);
})
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// IndexStorage2.getAttachment
// IndexStorage2.getAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -937,6 +904,14 @@
...
@@ -937,6 +904,14 @@
return
id
;
return
id
;
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
)
||
(
name
===
'
include
'
);
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
[];
};
RSVP
.
all
([
RSVP
.
all
([
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
894
"
,
"
b
"
:
"
inversion
"
,
"
c
"
:
2
}),
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
894
"
,
"
b
"
:
"
inversion
"
,
"
c
"
:
2
}),
context
.
jio
.
put
(
"
33
"
,
{
"
a
"
:
"
65
"
,
"
b
"
:
"
division
"
,
"
c
"
:
4
}),
context
.
jio
.
put
(
"
33
"
,
{
"
a
"
:
"
65
"
,
"
b
"
:
"
division
"
,
"
c
"
:
4
}),
...
@@ -1021,6 +996,14 @@
...
@@ -1021,6 +996,14 @@
}
}
};
};
DummyStorage3
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
(
name
===
'
list
'
)
||
(
name
===
'
include
'
);
};
DummyStorage3
.
prototype
.
buildQuery
=
function
()
{
return
[];
};
RSVP
.
all
([
RSVP
.
all
([
context
.
jio
.
post
({
"
a
"
:
"
5
"
,
"
b
"
:
"
inversion
"
,
"
c
"
:
2
}),
context
.
jio
.
post
({
"
a
"
:
"
5
"
,
"
b
"
:
"
inversion
"
,
"
c
"
:
2
}),
context
.
jio
.
post
({
"
a
"
:
"
62
"
,
"
b
"
:
"
division
"
,
"
c
"
:
4
}),
context
.
jio
.
post
({
"
a
"
:
"
62
"
,
"
b
"
:
"
division
"
,
"
c
"
:
4
}),
...
...
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