Changed type of LSN in tree-index pages from int to long.
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_btree_updates_next@652 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 629824d..aa2a08b 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
@@ -50,16 +50,16 @@
public class BTreeFieldPrefixNSMLeafFrame implements IBTreeLeafFrame {
protected static final int pageLsnOff = 0; // 0
- protected static final int tupleCountOff = pageLsnOff + 4; // 4
- protected static final int freeSpaceOff = tupleCountOff + 4; // 8
- protected static final int totalFreeSpaceOff = freeSpaceOff + 4; // 12
- protected static final int levelOff = totalFreeSpaceOff + 4; // 16
- protected static final int smFlagOff = levelOff + 1; // 17
- protected static final int uncompressedTupleCountOff = smFlagOff + 1; // 18
- protected static final int prefixTupleCountOff = uncompressedTupleCountOff + 4; // 21
+ protected static final int tupleCountOff = pageLsnOff + 8; // 8
+ protected static final int freeSpaceOff = tupleCountOff + 4; // 12
+ protected static final int totalFreeSpaceOff = freeSpaceOff + 4; // 16
+ protected static final int levelOff = totalFreeSpaceOff + 4; // 20
+ protected static final int smFlagOff = levelOff + 1; // 24
+ protected static final int uncompressedTupleCountOff = smFlagOff + 1; // 25
+ protected static final int prefixTupleCountOff = uncompressedTupleCountOff + 4; // 26
- protected static final int prevLeafOff = prefixTupleCountOff + 4; // 22
- protected static final int nextLeafOff = prevLeafOff + 4; // 26
+ protected static final int prevLeafOff = prefixTupleCountOff + 4; // 30
+ protected static final int nextLeafOff = prevLeafOff + 4; // 34
protected ICachedPage page = null;
protected ByteBuffer buf = null;
@@ -335,7 +335,7 @@
@Override
public void initBuffer(byte level) {
- buf.putInt(pageLsnOff, 0);
+ buf.putLong(pageLsnOff, 0);
// during creation
buf.putInt(tupleCountOff, 0);
resetSpaceParams();
@@ -414,13 +414,13 @@
}
@Override
- public int getPageLsn() {
- return buf.getInt(pageLsnOff);
+ public long getPageLsn() {
+ return buf.getLong(pageLsnOff);
}
@Override
- public void setPageLsn(int pageLsn) {
- buf.putInt(pageLsnOff, pageLsn);
+ public void setPageLsn(long pageLsn) {
+ buf.putLong(pageLsnOff, pageLsn);
}
@Override
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
index a8efee7..edab4c2 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
@@ -52,7 +52,7 @@
public static final float DEFAULT_FILL_FACTOR = 0.7f;
- private final static int RESTART_OP = Integer.MIN_VALUE;
+ private final static long RESTART_OP = Long.MIN_VALUE;
private final static int MAX_RESTARTS = 10;
private final static int rootPage = 1;
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOpContext.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOpContext.java
index 6e89a89..7dc51de 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOpContext.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOpContext.java
@@ -22,6 +22,7 @@
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrame;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.IndexOp;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.IntArrayList;
+import edu.uci.ics.hyracks.storage.am.common.ophelpers.LongArrayList;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
public final class BTreeOpContext implements IIndexOpContext {
@@ -34,7 +35,7 @@
public RangePredicate pred;
public final BTreeSplitKey splitKey;
public int opRestarts = 0;
- public final IntArrayList pageLsns; // used like a stack
+ public final LongArrayList pageLsns; // used like a stack
public final IntArrayList smPages;
public final IntArrayList freePages;
@@ -50,7 +51,7 @@
}
this.interiorFrame = interiorFrame;
this.metaFrame = metaFrame;
- this.pageLsns = new IntArrayList(treeHeightHint, treeHeightHint);
+ this.pageLsns = new LongArrayList(treeHeightHint, treeHeightHint);
if (op == IndexOp.SEARCH || op == IndexOp.DISKORDERSCAN) {
smPages = null;
freePages = null;
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
index 6853ed2..8b5a325 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
@@ -48,9 +48,9 @@
public int getTotalFreeSpace();
- public void setPageLsn(int pageLsn);
+ public void setPageLsn(long pageLsn);
- public int getPageLsn();
+ public long getPageLsn();
public void setPage(ICachedPage page);
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/LIFOMetaDataFrame.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/LIFOMetaDataFrame.java
index b0ec13d..0e4a6e7 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/LIFOMetaDataFrame.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/LIFOMetaDataFrame.java
@@ -27,11 +27,11 @@
public class LIFOMetaDataFrame implements ITreeIndexMetaDataFrame {
- protected static final int tupleCountOff = 0;
- protected static final int freeSpaceOff = tupleCountOff + 4;
- protected static final int maxPageOff = freeSpaceOff + 4;
- protected static final int dummyFieldOff = maxPageOff + 4;
- protected static final byte levelOff = dummyFieldOff + 4;
+ protected static final int tupleCountOff = 0; // 0
+ protected static final int freeSpaceOff = tupleCountOff + 8; // 8
+ protected static final int maxPageOff = freeSpaceOff + 4; // 12
+ protected static final int dummyFieldOff = maxPageOff + 4; // 16
+ protected static final byte levelOff = dummyFieldOff + 4; // 20
protected static final byte nextPageOff = levelOff + 1;
protected ICachedPage page = null;
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/TreeIndexNSMFrame.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/TreeIndexNSMFrame.java
index 98b3e0b..197af60 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/TreeIndexNSMFrame.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/frames/TreeIndexNSMFrame.java
@@ -30,11 +30,11 @@
public abstract class TreeIndexNSMFrame implements ITreeIndexFrame {
protected static final int pageLsnOff = 0; // 0
- protected static final int tupleCountOff = pageLsnOff + 4; // 4
- protected static final int freeSpaceOff = tupleCountOff + 4; // 8
- protected static final int totalFreeSpaceOff = freeSpaceOff + 4; // 16
- protected static final byte levelOff = totalFreeSpaceOff + 4;
- protected static final byte smFlagOff = levelOff + 1;
+ protected static final int tupleCountOff = pageLsnOff + 8; // 8
+ protected static final int freeSpaceOff = tupleCountOff + 4; // 12
+ protected static final int totalFreeSpaceOff = freeSpaceOff + 4; // 20
+ protected static final byte levelOff = totalFreeSpaceOff + 4; // 24
+ protected static final byte smFlagOff = levelOff + 1; // 25
protected ICachedPage page = null;
protected ByteBuffer buf = null;
@@ -52,7 +52,7 @@
@Override
public void initBuffer(byte level) {
- buf.putInt(pageLsnOff, 0); // TODO: might to set to a different lsn
+ buf.putLong(pageLsnOff, 0); // TODO: might to set to a different lsn
// during creation
buf.putInt(tupleCountOff, 0);
resetSpaceParams();
@@ -248,13 +248,13 @@
}
@Override
- public int getPageLsn() {
- return buf.getInt(pageLsnOff);
+ public long getPageLsn() {
+ return buf.getLong(pageLsnOff);
}
@Override
- public void setPageLsn(int pageLsn) {
- buf.putInt(pageLsnOff, pageLsn);
+ public void setPageLsn(long pageLsn) {
+ buf.putLong(pageLsnOff, pageLsn);
}
@Override
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/TreeDiskOrderScanCursor.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/TreeDiskOrderScanCursor.java
index a67f982..18d60ec 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/TreeDiskOrderScanCursor.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/TreeDiskOrderScanCursor.java
@@ -91,7 +91,7 @@
if (tupleIndex >= frame.getTupleCount()) {
boolean nextLeafExists = positionToNextLeaf(true);
if (nextLeafExists) {
- frameTuple.resetByTupleIndex(frame, tupleIndex);
+ frameTuple.resetByTupleIndex(frame, tupleIndex);
return true;
} else {
return false;
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/LongArrayList.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/LongArrayList.java
new file mode 100644
index 0000000..4dd1b5f
--- /dev/null
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/LongArrayList.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package edu.uci.ics.hyracks.storage.am.common.ophelpers;
+
+public class LongArrayList {
+ private long[] data;
+ private int size;
+ private int first;
+ private final int growth;
+
+ public LongArrayList(int initialCapacity, int growth) {
+ data = new long[initialCapacity];
+ size = 0;
+ first = 0;
+ this.growth = growth;
+ }
+
+ public int size() {
+ return size;
+ }
+
+ public int first() {
+ return first;
+ }
+
+ public void add(long i) {
+ if (size == data.length) {
+ long[] newData = new long[data.length + growth];
+ System.arraycopy(data, 0, newData, 0, data.length);
+ data = newData;
+ }
+
+ data[size++] = i;
+ }
+
+ public void removeLast() {
+ if (size > 0)
+ size--;
+ }
+
+ // WARNING: caller is responsible for checking size > 0
+ public long getLast() {
+ return data[size - 1];
+ }
+
+ public long get(int i) {
+ return data[i];
+ }
+
+ // WARNING: caller is responsible for checking i < size
+ public void set(int i, long value) {
+ data[i] = value;
+
+ }
+
+ public long getFirst() {
+ return data[first];
+ }
+
+ public void moveFirst() {
+ first++;
+ }
+
+ public void clear() {
+ size = 0;
+ first = 0;
+ }
+
+ public boolean isLast() {
+ return size == first;
+ }
+
+ public boolean isEmpty() {
+ return size == 0;
+ }
+}
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeFrame.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeFrame.java
index a0350bf..dd57986 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeFrame.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeFrame.java
@@ -26,9 +26,9 @@
public void delete(int tupleIndex, MultiComparator cmp);
- public int getPageNsn();
+ public long getPageNsn();
- public void setPageNsn(int pageNsn);
+ public void setPageNsn(long pageNsn);
public int getRightPage();
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
index 1129fd6..0486496 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
@@ -95,13 +95,13 @@
}
@Override
- public void setPageNsn(int pageNsn) {
- buf.putInt(pageNsnOff, pageNsn);
+ public void setPageNsn(long pageNsn) {
+ buf.putLong(pageNsnOff, pageNsn);
}
@Override
- public int getPageNsn() {
- return buf.getInt(pageNsnOff);
+ public long getPageNsn() {
+ return buf.getLong(pageNsnOff);
}
@Override
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/PathList.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/PathList.java
index d66d0a0..4f86111 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/PathList.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/PathList.java
@@ -16,15 +16,16 @@
package edu.uci.ics.hyracks.storage.am.rtree.impls;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.IntArrayList;
+import edu.uci.ics.hyracks.storage.am.common.ophelpers.LongArrayList;
public class PathList {
private IntArrayList pageIds;
- private IntArrayList pageLsns;
+ private LongArrayList pageLsns;
private IntArrayList pageIndexes;
public PathList(int initialCapacity, int growth) {
pageIds = new IntArrayList(initialCapacity, growth);
- pageLsns = new IntArrayList(initialCapacity, growth);
+ pageLsns = new LongArrayList(initialCapacity, growth);
pageIndexes = new IntArrayList(initialCapacity, growth);
}
@@ -36,7 +37,7 @@
return pageIds.first();
}
- public void add(int pageId, int pageLsn, int pageIndex) {
+ public void add(int pageId, long pageLsn, int pageIndex) {
pageIds.add(pageId);
pageLsns.add(pageLsn);
pageIndexes.add(pageIndex);
@@ -46,7 +47,7 @@
return pageIds.getFirst();
}
- public int getFirstPageLsn() {
+ public long getFirstPageLsn() {
return pageLsns.getFirst();
}
@@ -58,7 +59,7 @@
return pageIds.getLast();
}
- public int getLastPageLsn() {
+ public long getLastPageLsn() {
return pageLsns.getLast();
}
@@ -70,7 +71,7 @@
return pageIds.get(i);
}
- public int getPageLsn(int i) {
+ public long getPageLsn(int i) {
return pageLsns.get(i);
}
@@ -78,7 +79,7 @@
return pageIndexes.get(i);
}
- public void setPageLsn(int i, int pageLsn) {
+ public void setPageLsn(int i, long pageLsn) {
pageLsns.set(i, pageLsn);
}
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
index b85b4eb..e7fa260 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
@@ -16,7 +16,6 @@
package edu.uci.ics.hyracks.storage.am.rtree.impls;
import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -53,7 +52,7 @@
private boolean loaded = false;
private final int rootPage = 1; // the root page never changes
- private final AtomicInteger globalNsn; // Global node sequence number
+ private final AtomicLong globalNsn; // Global node sequence number
private int numOfPages = 1;
private final ReadWriteLock treeLatch;
@@ -86,7 +85,7 @@
this.freePageManager = freePageManager;
this.interiorFrameFactory = interiorFrameFactory;
this.leafFrameFactory = leafFrameFactory;
- globalNsn = new AtomicInteger();
+ globalNsn = new AtomicLong();
this.treeLatch = new ReentrantReadWriteLock(true);
this.diskOrderScanPredicate = new SearchPredicate(null, cmp);
}
@@ -95,7 +94,7 @@
globalNsn.incrementAndGet();
}
- public int getGlobalNsn() {
+ public long getGlobalNsn() {
return globalNsn.get();
}
@@ -294,7 +293,7 @@
boolean writeLatched = false;
ICachedPage node = null;
boolean isLeaf = false;
- int pageLsn = 0, parentLsn = 0;
+ long pageLsn = 0, parentLsn = 0;
while (true) {
if (!writeLatched) {
@@ -457,7 +456,7 @@
ctx.interiorFrame.setRightPage(rightPageId);
rightFrame.setPageNsn(ctx.interiorFrame.getPageNsn());
incrementGlobalNsn();
- int newNsn = getGlobalNsn();
+ long newNsn = getGlobalNsn();
rightFrame.setPageLsn(newNsn);
ctx.interiorFrame.setPageNsn(newNsn);
ctx.interiorFrame.setPageLsn(newNsn);
@@ -470,7 +469,7 @@
ctx.leafFrame.setRightPage(rightPageId);
rightFrame.setPageNsn(ctx.leafFrame.getPageNsn());
incrementGlobalNsn();
- int newNsn = getGlobalNsn();
+ long newNsn = getGlobalNsn();
rightFrame.setPageLsn(newNsn);
ctx.leafFrame.setPageNsn(newNsn);
ctx.leafFrame.setPageLsn(newNsn);
@@ -502,7 +501,7 @@
ctx.interiorFrame.insert(ctx.splitKey.getRightTuple(), -1);
incrementGlobalNsn();
- int newNsn = getGlobalNsn();
+ long newNsn = getGlobalNsn();
ctx.interiorFrame.setPageLsn(newNsn);
ctx.interiorFrame.setPageNsn(newNsn);
} finally {
@@ -584,8 +583,9 @@
public void findPath(RTreeOpContext ctx) throws HyracksDataException {
int pageId = rootPage;
int parentIndex = -1;
- int parentLsn = 0;
- int pageLsn, pageIndex;
+ long parentLsn = 0;
+ long pageLsn;
+ int pageIndex;
ctx.traverseList.add(pageId, -1, parentIndex);
while (!ctx.traverseList.isLast()) {
pageId = ctx.traverseList.getFirstPageId();
@@ -746,7 +746,7 @@
while (!ctx.pathList.isEmpty()) {
int pageId = ctx.pathList.getLastPageId();
- int parentLsn = ctx.pathList.getLastPageLsn();
+ long parentLsn = ctx.pathList.getLastPageLsn();
int pageIndex = ctx.pathList.getLastPageIndex();
ctx.pathList.moveLast();
ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
@@ -755,7 +755,7 @@
incrementReadLatchesAcquired();
ctx.interiorFrame.setPage(node);
boolean isLeaf = ctx.interiorFrame.isLeaf();
- int pageLsn = ctx.interiorFrame.getPageLsn();
+ long pageLsn = ctx.interiorFrame.getPageLsn();
int parentIndex = ctx.traverseList.getPageIndex(pageIndex);
ctx.traverseList.setPageLsn(pageIndex, pageLsn);
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
index 1d4fb73..a138212 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
@@ -90,7 +90,7 @@
}
while (!pathList.isEmpty()) {
int pageId = pathList.getLastPageId();
- int parentLsn = pathList.getLastPageLsn();
+ long parentLsn = pathList.getLastPageLsn();
pathList.moveLast();
ICachedPage node = bufferCache.pin(
BufferedFileHandle.getDiskPageId(fileId, pageId), false);
@@ -99,7 +99,7 @@
readLatched = true;
interiorFrame.setPage(node);
boolean isLeaf = interiorFrame.isLeaf();
- int pageLsn = interiorFrame.getPageLsn();
+ long pageLsn = interiorFrame.getPageLsn();
if (pageId != rootPage && parentLsn < interiorFrame.getPageNsn()) {
// Concurrent split detected, we need to visit the right page