@Override public boolean keyQualifies(Key key) { return this.key.compareTo(key) == 0; }
@Override public boolean keyQualifies(Key key) { boolean startQualifies = true; if(start != null) { int c = key.compareTo(start); startQualifies = (startIncluded && c>=0) || c>0; } boolean endQualifies = true; if(end != null) { int c = key.compareTo(end); endQualifies = (endIncluded && c<=0) || c<0; } return startQualifies && endQualifies; }
@Override public boolean keyQualifies(Key key) { return getKey().compareTo(key) != 0; }
private static RangeCondition mergeRangeConditions(List<RangeCondition> rangeConditions) { Key lowestKey = null; boolean startInclusive = false; boolean endInclusive = false; Key highestKey = null; for(SearchCondition condition : rangeConditions) { RangeCondition rangeCondition = (RangeCondition) condition; Key rangeStartKey = rangeCondition.getStart(); Key rangeEndKey = rangeCondition.getEnd(); if(rangeStartKey != null && (lowestKey == null || rangeStartKey.compareTo(lowestKey) < 0)) { lowestKey = rangeStartKey; startInclusive = rangeCondition.isStartIncluded(); } if(rangeEndKey != null && (highestKey == null || rangeEndKey.compareTo(highestKey) > 0)) { highestKey = rangeEndKey; endInclusive = rangeCondition.isEndIncluded(); } } return new RangeCondition(lowestKey, startInclusive, highestKey, endInclusive); }
private CompareResult compare(Key[] otherKeys, CompareMethod compareMethod) { Key[] keys = getKeys(); //we assume keys are ordered in same order int keyLength = keys.length; int lastCompare = -1; for(int i=0; i<keyLength; i++) { Key key = keys[i]; Key otherKey = otherKeys.length > i ? otherKeys[i] : null; if(key != null && otherKey != null && i<valueMarker) { lastCompare = key.compareTo(otherKey); if(lastCompare != 0) { return new CompareResult(lastCompare); } } else { break; } } if(compareMethod == CompareMethod.BEFORE) { return new CompareResult(-1); } else { return new CompareResult(lastCompare); } }
@Override public LeaveBlock findLeaveBlock(LockIntentType intent, Key key) throws JasDBStorageException { TreeNode closestNode = treeNodes.getBefore(key); Key nodeKey = closestNode.getKey(); int compare = key.compareTo(nodeKey); long blockPointer; if(compare <= 0) { blockPointer = closestNode.getLeft(); } else { blockPointer = closestNode.getRight(); } IndexBlock block = persister.loadBlock(blockPointer); persister.getLockManager().acquireLock(intent, block); return block.findLeaveBlock(intent, key); }
} else if(rangeCondition.getEnd() != null) { Key lastKey = currentLeave.getLast(); int lastKeyCompare = lastKey.compareTo(rangeCondition.getEnd()); if(lastKeyCompare > 0) {