Skip to content

Commit

Permalink
Issue #7919 was fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Apr 26, 2018
1 parent 401e5bf commit 756f18c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,13 @@ public PureTxBetweenIndexForwardCursor(Object fromKey, boolean fromInclusive, Ob
fromKey = enhanceFromCompositeKeyBetweenAsc(fromKey, fromInclusive);
toKey = enhanceToCompositeKeyBetweenAsc(toKey, toInclusive);

if (fromInclusive)
firstKey = indexChanges.getCeilingKey(fromKey);
else
firstKey = indexChanges.getHigherKey(fromKey);

if (toInclusive)
lastKey = indexChanges.getFloorKey(toKey);
else
lastKey = indexChanges.getLowerKey(toKey);

if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, toKey) > 0) {
final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive);
if (keys.length == 0) {
nextKey = null;
} else {
firstKey = keys[0];
lastKey = keys[1];

nextKey = firstKey;
}
}
Expand Down Expand Up @@ -161,19 +155,13 @@ public PureTxBetweenIndexBackwardCursor(Object fromKey, boolean fromInclusive, O
fromKey = enhanceFromCompositeKeyBetweenDesc(fromKey, fromInclusive);
toKey = enhanceToCompositeKeyBetweenDesc(toKey, toInclusive);

if (fromInclusive)
firstKey = indexChanges.getCeilingKey(fromKey);
else
firstKey = indexChanges.getHigherKey(fromKey);

if (toInclusive)
lastKey = indexChanges.getFloorKey(toKey);
else
lastKey = indexChanges.getLowerKey(toKey);

if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, fromKey) < 0) {
final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive);
if (keys.length == 0) {
nextKey = null;
} else {
firstKey = keys[0];
lastKey = keys[1];

nextKey = lastKey;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,13 @@ public PureTxBetweenIndexForwardCursor(Object fromKey, boolean fromInclusive, Ob
fromKey = enhanceFromCompositeKeyBetweenAsc(fromKey, fromInclusive);
toKey = enhanceToCompositeKeyBetweenAsc(toKey, toInclusive);

if (toInclusive)
firstKey = indexChanges.getCeilingKey(fromKey);
else
firstKey = indexChanges.getHigherKey(fromKey);

if (fromInclusive)
lastKey = indexChanges.getFloorKey(toKey);
else
lastKey = indexChanges.getLowerKey(toKey);

if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, toKey) > 0) {
final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive);
if (keys.length == 0) {
nextKey = null;
} else {
firstKey = keys[0];
lastKey = keys[1];

nextKey = firstKey;
}
}
Expand Down Expand Up @@ -126,19 +120,13 @@ public PureTxBetweenIndexBackwardCursor(Object fromKey, boolean fromInclusive, O
fromKey = enhanceFromCompositeKeyBetweenDesc(fromKey, fromInclusive);
toKey = enhanceToCompositeKeyBetweenDesc(toKey, toInclusive);

if (toInclusive)
firstKey = indexChanges.getCeilingKey(fromKey);
else
firstKey = indexChanges.getHigherKey(fromKey);

if (fromInclusive)
lastKey = indexChanges.getFloorKey(toKey);
else
lastKey = indexChanges.getLowerKey(toKey);

if (firstKey != null && ODefaultComparator.INSTANCE.compare(firstKey, fromKey) < 0) {
final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive);
if (keys.length == 0) {
nextKey = null;
} else {
firstKey = keys[0];
lastKey = keys[1];

nextKey = lastKey;
}
}
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/com/orientechnologies/orient/core/tx/OTransactionIndexChanges.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ public Object getCeilingKey(Object key) {
return changesPerKey.ceilingKey(key);
}

public Object[] firstAndLastKeys(Object from, boolean fromInclusive, Object to, boolean toInclusive) {
final NavigableMap<Object, OTransactionIndexChangesPerKey> interval = changesPerKey
.subMap(from, fromInclusive, to, toInclusive);

if (interval.isEmpty()) {
return new Object[0];
} else {
return new Object[] {interval.firstKey(), interval.lastKey()};
}
}

public Object getFloorKey(Object key) {
return changesPerKey.floorKey(key);
}
Expand Down

0 comments on commit 756f18c

Please sign in to comment.