Skip to content

Commit

Permalink
Fix index usage in tx
Browse files Browse the repository at this point in the history
Resolves: #7322
  • Loading branch information
luigidellaquila committed Apr 18, 2017
1 parent d948bc0 commit 184bcd2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ public PureTxBetweenIndexBackwardCursor(Object fromKey, boolean fromInclusive, O
else
lastKey = indexChanges.getLowerKey(toKey);

if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, toKey) > 0) {
if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, fromKey) < 0) {
nextKey = null;
} else {
nextKey = firstKey;
nextKey = lastKey;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public PureTxBetweenIndexForwardCursor(Object fromKey, boolean fromInclusive, Ob
else
lastKey = indexChanges.getLowerKey(toKey);

nextKey = firstKey;
if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, toKey) > 0) {
nextKey = null;
} else {
nextKey = firstKey;
}
}

@Override
Expand Down Expand Up @@ -134,7 +138,11 @@ public PureTxBetweenIndexBackwardCursor(Object fromKey, boolean fromInclusive, O
else
lastKey = indexChanges.getLowerKey(toKey);

nextKey = lastKey;
if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, fromKey) < 0) {
nextKey = null;
} else {
nextKey = lastKey;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* Created by tglman on 12/04/17.
Expand Down Expand Up @@ -51,6 +50,28 @@ public void test() {
assertEquals(0L, res.stream().count());
}

@Test
public void test2() {
OClass clazz = database.createClass("Test2");
clazz.createProperty("foo", OType.STRING);
clazz.createProperty("bar", OType.STRING);
clazz.createIndex("Test2.foo_bar", OClass.INDEX_TYPE.NOTUNIQUE, "foo", "bar");

database.begin();
ODocument doc = database.newInstance("Test2");
doc.setProperty("foo", "abcdefg");
doc.setProperty("bar", "abcdefg");
database.save(doc);
OResultSet res = database.query("select from Test2 where foo='abcdefg' and bar = 'abcdefg' ");

assertEquals(1L, res.stream().count());

res = database.query("select from Test2 where foo='aaaaa' and bar = 'aaa'");

System.out.println(res.getExecutionPlan().get().prettyPrint(0, 0));
assertEquals(0L, res.stream().count());
}

@After
public void after() {
database.close();
Expand Down

0 comments on commit 184bcd2

Please sign in to comment.