Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug left-index-remove can't handle none-flatten query #281

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ protected void removeIndexLeft(ConditionQuery query, HugeElement element) {
}

// TODO: remove left index in async thread
// Process range index
this.processRangeIndexLeft(query, element);
// Process secondary index or search index
this.processSecondaryOrSearchIndexLeft(query, element);

for (ConditionQuery cq: ConditionQueryFlatten.flatten(query)) {
// Process range index
this.processRangeIndexLeft(cq, element);
// Process secondary index or search index
this.processSecondaryOrSearchIndexLeft(cq, element);
}
this.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public Iterator<BackendEntry> query(Query query) {
}

List<Query> queries = new ArrayList<>();
IdQuery ids = new IdQuery(query.resultType(), query);
for (ConditionQuery cq: ConditionQueryFlatten.flatten(
(ConditionQuery) query)) {
Query q = this.optimizeQuery(cq);
Expand All @@ -320,13 +321,18 @@ public Iterator<BackendEntry> query(Query query) {
* 1.sysprop-query, which would not be empty.
* 2.index-query result(ids after optimization), which may be empty.
*/
if (!q.empty()) {
if (q.getClass() == IdQuery.class && !q.ids().isEmpty()) {
ids.query(q.ids());
} else if (!q.empty()) {
// Return empty if there is no result after index-query
queries.add(q);
}
}

ExtendableIterator<BackendEntry> rs = new ExtendableIterator<>();
if (!ids.empty()) {
queries.add(ids);
}
for (Query q : queries) {
rs.extend(super.query(q));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public void lockReads(String group, Id... locks) {
// NOTE: when used in multi-threads, should add `synchronized`
public void lockReads(String group, Collection<Id> locks) {
List<Id> newLocks = new ArrayList<>(locks.size());
Set<Id> locked = locksOfGroup(group);
for (Id lock : locks) {
Set<Id> locked = locksOfGroup(group);
if (!locked.contains(lock)) {
newLocks.add(lock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1566,18 +1566,13 @@ public void testQueryWithMultiLayerConditions() {
.and(P.lt(29).or(P.eq(35)).or(P.gt(45)))
).values("name").toList();

Assert.assertEquals(5, vertices.size());
Assert.assertEquals(4, vertices.size());

Set<String> names = ImmutableSet.of("Hebe", "James",
"Tom Cat", "Lisa");
int numJames = 0;
for (Object name : vertices) {
Assert.assertTrue(names.contains(name));
if (name.equals("James")) {
numJames++;
}
}
Assert.assertEquals(2, numJames);
}

@Test
Expand Down