Fixed all tests.
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_btree_updates_next@607 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
index daa5a67..02ad3a1 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
@@ -370,8 +370,8 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.FTM_INCLUSIVE,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
int tupleIndex = slotManager.decodeSecondSlotField(slot);
if (tupleIndex != FieldPrefixSlotManager.GREATEST_SLOT) {
@@ -387,11 +387,11 @@
@Override
public int findUpdateTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.FTM_EXACT,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
int tupleIndex = slotManager.decodeSecondSlotField(slot);
- if (tupleIndex != FieldPrefixSlotManager.GREATEST_SLOT) {
+ if (tupleIndex == FieldPrefixSlotManager.GREATEST_SLOT) {
throw new BTreeNonExistentKeyException("Trying to update a tuple with a nonexistent key in leaf node.");
}
return slot;
@@ -399,11 +399,11 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.FTM_EXACT,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
int tupleIndex = slotManager.decodeSecondSlotField(slot);
- if (tupleIndex != FieldPrefixSlotManager.GREATEST_SLOT) {
+ if (tupleIndex == FieldPrefixSlotManager.GREATEST_SLOT) {
throw new BTreeNonExistentKeyException("Trying to delete a tuple with a nonexistent key in leaf node.");
}
return slot;
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
index 203a8e9..aaf9845 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
@@ -82,8 +82,8 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.FTM_INCLUSIVE,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
int slotOff = slotManager.getSlotOff(tupleIndex);
boolean isDuplicate = true;
@@ -104,8 +104,8 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
- return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.FTM_INCLUSIVE,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
}
@Override
@@ -284,9 +284,9 @@
return getLeftmostChildPageId(srcCmp);
}
if (pred.isLowKeyInclusive())
- fsm = FindTupleMode.FTM_INCLUSIVE;
+ fsm = FindTupleMode.INCLUSIVE;
else
- fsm = FindTupleMode.FTM_EXCLUSIVE;
+ fsm = FindTupleMode.EXCLUSIVE;
targetCmp = pred.getLowKeyComparator();
} else {
tuple = pred.getHighKey();
@@ -294,14 +294,14 @@
return getRightmostChildPageId(srcCmp);
}
if (pred.isHighKeyInclusive())
- fsm = FindTupleMode.FTM_EXCLUSIVE;
+ fsm = FindTupleMode.EXCLUSIVE;
else
- fsm = FindTupleMode.FTM_INCLUSIVE;
+ fsm = FindTupleMode.INCLUSIVE;
targetCmp = pred.getHighKeyComparator();
}
int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, targetCmp, fsm,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
int slotOff = slotManager.getSlotOff(tupleIndex);
if (tupleIndex < 0) {
return buf.getInt(rightLeafOff);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
index e172dce..02adb01 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
@@ -70,8 +70,8 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getFieldCount());
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.FTM_INCLUSIVE,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
int slotOff = slotManager.getSlotOff(tupleIndex);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
boolean isDuplicate = true;
@@ -94,8 +94,8 @@
@Override
public int findUpdateTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getFieldCount());
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.FTM_EXACT,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
if (tupleIndex < 0) {
throw new BTreeNonExistentKeyException("Trying to update a tuple with a nonexistent key in leaf node.");
@@ -106,8 +106,8 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getFieldCount());
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.FTM_EXACT,
- FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY);
+ int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
// TODO: Push this check into findSlot, and distinguish between greatest slot and errors.
if (tupleIndex < 0) {
throw new BTreeNonExistentKeyException("Trying to delete a tuple with a nonexistent key in leaf node.");
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
index a0f8e00..1f62f30 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
@@ -44,8 +44,8 @@
} else if (cmp > 0) {
begin = mid + 1;
} else {
- if (mode == FindTupleMode.FTM_EXCLUSIVE) {
- if (matchPolicy == FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY)
+ if (mode == FindTupleMode.EXCLUSIVE) {
+ if (matchPolicy == FindTupleNoExactMatchPolicy.HIGHER_KEY)
begin = mid + 1;
else
end = mid - 1;
@@ -55,10 +55,10 @@
}
}
- if (mode == FindTupleMode.FTM_EXACT)
+ if (mode == FindTupleMode.EXACT)
return -1;
- if (matchPolicy == FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY) {
+ if (matchPolicy == FindTupleNoExactMatchPolicy.HIGHER_KEY) {
if (begin > frame.getTupleCount() - 1)
return -1;
frameTuple.resetByTupleIndex(frame, begin);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
index 1eda31e..2fd09c8 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
@@ -196,18 +196,18 @@
frameTuple.setFieldCount(lowKeyCmp.getFieldCount());
// init
- lowKeyFtm = FindTupleMode.FTM_EXCLUSIVE;
+ lowKeyFtm = FindTupleMode.EXCLUSIVE;
if (pred.lowKeyInclusive) {
- lowKeyFtp = FindTupleNoExactMatchPolicy.FTP_LOWER_KEY;
+ lowKeyFtp = FindTupleNoExactMatchPolicy.LOWER_KEY;
} else {
- lowKeyFtp = FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY;
+ lowKeyFtp = FindTupleNoExactMatchPolicy.HIGHER_KEY;
}
- highKeyFtm = FindTupleMode.FTM_EXCLUSIVE;
+ highKeyFtm = FindTupleMode.EXCLUSIVE;
if (pred.highKeyInclusive) {
- highKeyFtp = FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY;
+ highKeyFtp = FindTupleNoExactMatchPolicy.HIGHER_KEY;
} else {
- highKeyFtp = FindTupleNoExactMatchPolicy.FTP_LOWER_KEY;
+ highKeyFtp = FindTupleNoExactMatchPolicy.LOWER_KEY;
}
if (pred.isForward()) {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
index 6f98c8c..ac3bed0 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
@@ -101,8 +101,8 @@
prefixBegin = prefixMid + 1;
tuplePrefixSlotNumUbound = prefixMid + 1;
} else {
- if (mode == FindTupleMode.FTM_EXCLUSIVE) {
- if (matchPolicy == FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY)
+ if (mode == FindTupleMode.EXCLUSIVE) {
+ if (matchPolicy == FindTupleNoExactMatchPolicy.HIGHER_KEY)
prefixBegin = prefixMid + 1;
else
prefixEnd = prefixMid - 1;
@@ -153,8 +153,8 @@
else if (cmp > 0)
tupleBegin = tupleMid + 1;
else {
- if (mode == FindTupleMode.FTM_EXCLUSIVE) {
- if (matchPolicy == FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY)
+ if (mode == FindTupleMode.EXCLUSIVE) {
+ if (matchPolicy == FindTupleNoExactMatchPolicy.HIGHER_KEY)
tupleBegin = tupleMid + 1;
else
tupleEnd = tupleMid - 1;
@@ -167,12 +167,12 @@
// System.out.println("RECS: " + recBegin + " " + recMid + " " +
// recEnd);
- if (mode == FindTupleMode.FTM_EXACT)
+ if (mode == FindTupleMode.EXACT)
return encodeSlotFields(prefixMatch, GREATEST_SLOT);
// do final comparison to determine whether the search key is greater
// than all keys or in between some existing keys
- if (matchPolicy == FindTupleNoExactMatchPolicy.FTP_HIGHER_KEY) {
+ if (matchPolicy == FindTupleNoExactMatchPolicy.HIGHER_KEY) {
if (tupleBegin > frame.getTupleCount() - 1)
return encodeSlotFields(prefixMatch, GREATEST_SLOT);
frameTuple.resetByTupleIndex(frame, tupleBegin);
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/FindTupleNoExactMatchPolicy.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/FindTupleNoExactMatchPolicy.java
index b8f3c9a..8b3f7f5 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/FindTupleNoExactMatchPolicy.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/FindTupleNoExactMatchPolicy.java
@@ -16,5 +16,5 @@
package edu.uci.ics.hyracks.storage.am.common.ophelpers;
public enum FindTupleNoExactMatchPolicy {
- FTP_LOWER_KEY, FTP_HIGHER_KEY
+ LOWER_KEY, HIGHER_KEY, NONE
}