integrating recent changes
git-svn-id: https://hyracks.googlecode.com/svn/trunk/hyracks@90 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
index e383eec..c02b062 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
@@ -1,65 +1,63 @@
-/*
- * 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.btree.compressors;
+package edu.uci.ics.asterix.indexing.btree.compressors;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.storage.am.btree.frames.FieldPrefixNSMLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.impls.FieldIterator;
-import edu.uci.ics.hyracks.storage.am.btree.impls.FieldPrefixSlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IComparator;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFieldAccessor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFrameCompressor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IPrefixSlotManager;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.indexing.btree.frames.FieldPrefixNSMLeaf;
+import edu.uci.ics.asterix.indexing.btree.impls.FieldIterator;
+import edu.uci.ics.asterix.indexing.btree.impls.FieldPrefixSlotManager;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IComparator;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFieldAccessor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFrameCompressor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IPrefixSlotManager;
public class FieldPrefixCompressor implements IFrameCompressor {
+
+ // minimum ratio of uncompressed records to total records to consider re-compression
+ private float ratioThreshold;
- public void compress(FieldPrefixNSMLeaf frame, MultiComparator cmp) throws HyracksDataException {
- int numRecords = frame.getNumRecords();
- //System.out.println("NUMRECORDS: " + numRecords);
+ // minimum number of records matching field prefixes to consider compressing them
+ private int occurrenceThreshold;
+
+ public FieldPrefixCompressor(float ratioThreshold, int occurrenceThreshold) {
+ this.ratioThreshold = ratioThreshold;
+ this.occurrenceThreshold = occurrenceThreshold;
+ }
+
+ @Override
+ public boolean compress(FieldPrefixNSMLeaf frame, MultiComparator cmp) throws Exception {
+ int numRecords = frame.getNumRecords();
if(numRecords <= 0) {
frame.setNumPrefixRecords(0);
frame.setFreeSpaceOff(frame.getOrigFreeSpaceOff());
frame.setTotalFreeSpace(frame.getOrigTotalFreeSpace());
- return;
+ return false;
}
-
+
+ int numUncompressedRecords = frame.getNumUncompressedRecords();
+ float ratio = (float)numUncompressedRecords / (float)numRecords;
+ if(ratio < ratioThreshold) return false;
+
IComparator[] cmps = cmp.getComparators();
IFieldAccessor[] fields = cmp.getFields();
ByteBuffer buf = frame.getBuffer();
byte[] pageArray = buf.array();
IPrefixSlotManager slotManager = frame.slotManager;
-
- int occurrenceThreshold = 2;
-
+
// perform analysis pass
ArrayList<KeyPartition> keyPartitions = getKeyPartitions(frame, cmp, occurrenceThreshold);
- if(keyPartitions.size() == 0) return;
-
- //System.out.println("KEYPARTITIONS: " + keyPartitions.size());
+ if(keyPartitions.size() == 0) return false;
// for each keyPartition, determine the best prefix length for compression, and count how many prefix records we would need in total
int totalSlotsNeeded = 0;
int totalPrefixBytes = 0;
- for(KeyPartition kp : keyPartitions) {
+ for(KeyPartition kp : keyPartitions) {
+
for(int j = 0; j < kp.pmi.length; j++) {
int benefitMinusCost = kp.pmi[j].spaceBenefit - kp.pmi[j].spaceCost;
if(benefitMinusCost > kp.maxBenefitMinusCost) {
@@ -68,11 +66,13 @@
}
}
- if(kp.maxBenefitMinusCost <= 0) continue; // ignore keyPartitions with no benefit
+ // ignore keyPartitions with no benefit and don't count bytes and slots needed
+ if(kp.maxBenefitMinusCost <= 0) continue;
totalPrefixBytes += kp.pmi[kp.maxPmiIndex].prefixBytes;
totalSlotsNeeded += kp.pmi[kp.maxPmiIndex].prefixSlotsNeeded;
}
+
//System.out.println("TOTAL SLOTS NEEDED: " + totalSlotsNeeded);
// we use a greedy heuristic to solve this "knapsack"-like problem
@@ -128,6 +128,7 @@
int kpIndex = 0;
int recSlotNum = 0;
int prefixSlotNum = 0;
+ numUncompressedRecords = 0;
FieldIterator recToWrite = new FieldIterator(fields, frame);
while(recSlotNum < numRecords) {
if(kpIndex < keyPartitions.size()) {
@@ -175,11 +176,12 @@
newRecordSlots[numRecords - 1 - slotNum] = slotManager.encodeSlotFields(FieldPrefixSlotManager.RECORD_UNCOMPRESSED, recordFreeSpace);
recordFreeSpace += recToWrite.copyFields(0, fields.length - 1, buffer, recordFreeSpace);
}
+ numUncompressedRecords += recordsInSegment;
}
else {
// segment has enough records, compress segment
- // extract prefix, write prefix record to buffer, and set prefix slot
- newPrefixSlots[newPrefixSlots.length - 1 - prefixSlotNum] = slotManager.encodeSlotFields(numFieldsToCompress, prefixFreeSpace);
+ // extract prefix, write prefix record to buffer, and set prefix slot
+ newPrefixSlots[newPrefixSlots.length - 1 - prefixSlotNum] = slotManager.encodeSlotFields(numFieldsToCompress, prefixFreeSpace);
//int tmp = freeSpace;
//prevRec.reset();
//System.out.println("SOURCE CONTENTS: " + buf.getInt(prevRec.getFieldOff()) + " " + buf.getInt(prevRec.getFieldOff()+4));
@@ -214,6 +216,7 @@
recToWrite.openRecSlotNum(recSlotNum);
newRecordSlots[numRecords - 1 - recSlotNum] = slotManager.encodeSlotFields(FieldPrefixSlotManager.RECORD_UNCOMPRESSED, recordFreeSpace);
recordFreeSpace += recToWrite.copyFields(0, fields.length - 1, buffer, recordFreeSpace);
+ numUncompressedRecords++;
}
}
else {
@@ -221,20 +224,21 @@
recToWrite.openRecSlotNum(recSlotNum);
newRecordSlots[numRecords - 1 - recSlotNum] = slotManager.encodeSlotFields(FieldPrefixSlotManager.RECORD_UNCOMPRESSED, recordFreeSpace);
recordFreeSpace += recToWrite.copyFields(0, fields.length - 1, buffer, recordFreeSpace);
+ numUncompressedRecords++;
}
recSlotNum++;
}
// sanity check to see if we have written exactly as many prefix bytes as computed before
if(prefixFreeSpace != frame.getOrigFreeSpaceOff() + totalPrefixBytes) {
- throw new HyracksDataException("ERROR: Number of prefix bytes written don't match computed number");
+ throw new AsterixException("ERROR: Number of prefix bytes written don't match computed number");
}
// in some rare instances our procedure could even increase the space requirement which is very dangerous
// this can happen to to the greedy solution of the knapsack-like problem
// therefore, we check if the new space exceeds the page size to avoid the only danger of an increasing space
int totalSpace = recordFreeSpace + newRecordSlots.length * slotManager.getSlotSize() + newPrefixSlots.length * slotManager.getSlotSize();
- if(totalSpace > buf.capacity()) return; // just leave the page as is
+ if(totalSpace > buf.capacity()) return false; // just leave the page as is
// copy new records and new slots into original page
int freeSpaceAfterInit = frame.getOrigFreeSpaceOff();
@@ -268,8 +272,11 @@
// update space fields, TODO: we need to update more fields
frame.setFreeSpaceOff(recordFreeSpace);
frame.setNumPrefixRecords(newPrefixSlots.length);
+ frame.setNumUncompressedRecords(numUncompressedRecords);
int totalFreeSpace = buf.capacity() - recordFreeSpace - ((newRecordSlots.length + newPrefixSlots.length) * slotManager.getSlotSize());
frame.setTotalFreeSpace(totalFreeSpace);
+
+ return true;
}
// we perform an analysis pass over the records to determine the costs and benefits of different compression options
@@ -306,19 +313,7 @@
int prefixFieldsMatch = 0;
int prefixBytes = 0; // counts the bytes of the common prefix fields
- for(int j = 0; j < maxCmps; j++) {
- // debug
- if(rec.getFieldOff() > 50000) {
- System.out.println("NUMRECORDS: " + numRecords + " " + frame.getNumPrefixRecords());
- int recSlotOff = slotManager.getRecSlotOff(i);
- int recSlot = buf.getInt(recSlotOff);
- int prefixSlotNum = slotManager.decodeFirstSlotField(recSlot);
- int recOff = slotManager.decodeSecondSlotField(recSlot);
-
- System.out.println("HERE: " + recSlotOff + " " + recSlot + " " + prefixSlotNum + " " + recOff);
- String keys = frame.printKeys(cmp);
- System.out.println(keys);
- }
+ for(int j = 0; j < maxCmps; j++) {
if(cmps[j].compare(pageArray, prevRec.getFieldOff(), pageArray, rec.getFieldOff()) == 0) {
prefixFieldsMatch++;
@@ -386,26 +381,15 @@
public PrefixMatchInfo[] pmi;
public int maxBenefitMinusCost = 0;
- public int maxPmiIndex = -1;
-
- public int totalUncompressedSpace = 0;
+ public int maxPmiIndex = -1;
+ // number of fields used for compression for this kp of current page
public KeyPartition(int numKeyFields) {
pmi = new PrefixMatchInfo[numKeyFields];
for(int i = 0; i < numKeyFields; i++) {
pmi[i] = new PrefixMatchInfo();
}
- }
-
- void print() {
- for(int i = 0; i < pmi.length; i++) {
- System.out.println("PMI: " + i + " | "
- + "MATCHES: " + pmi[i].matches + " | "
- + "SPACECOST: " + pmi[i].spaceCost + " | "
- + "SPACEBENEFIT: " + pmi[i].spaceBenefit + " | "
- + "SLOTSNEEDED: " + pmi[i].prefixSlotsNeeded);
- }
- }
+ }
}
private class SortByHeuristic implements Comparator<KeyPartition>{
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeaf.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeaf.java
index 02a9c9e..860f75f 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeaf.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeaf.java
@@ -1,39 +1,25 @@
-/*
- * 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.btree.frames;
+package edu.uci.ics.asterix.indexing.btree.frames;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
-import edu.uci.ics.hyracks.storage.am.btree.compressors.FieldPrefixCompressor;
-import edu.uci.ics.hyracks.storage.am.btree.impls.BTreeException;
-import edu.uci.ics.hyracks.storage.am.btree.impls.FieldIterator;
-import edu.uci.ics.hyracks.storage.am.btree.impls.FieldPrefixSlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
-import edu.uci.ics.hyracks.storage.am.btree.impls.SlotOffRecOff;
-import edu.uci.ics.hyracks.storage.am.btree.impls.SplitKey;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IComparator;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFieldAccessor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFrameCompressor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IPrefixSlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.SpaceStatus;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.indexing.btree.compressors.FieldPrefixCompressor;
+import edu.uci.ics.asterix.indexing.btree.impls.BTreeException;
+import edu.uci.ics.asterix.indexing.btree.impls.FieldIterator;
+import edu.uci.ics.asterix.indexing.btree.impls.FieldPrefixSlotManager;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.impls.SlotOffRecOff;
+import edu.uci.ics.asterix.indexing.btree.impls.SplitKey;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IComparator;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFieldAccessor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFrameCompressor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IPrefixSlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.SpaceStatus;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public class FieldPrefixNSMLeaf implements IBTreeFrameLeaf {
@@ -42,20 +28,21 @@
protected static final int freeSpaceOff = numRecordsOff + 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; // 20
- protected static final int numPrefixRecordsOff = smFlagOff + 1; // 21
+ protected static final int smFlagOff = levelOff + 1; // 17
+ protected static final int numUncompressedRecordsOff = smFlagOff + 1; // 18
+ protected static final int numPrefixRecordsOff = numUncompressedRecordsOff + 4; // 21
protected static final int prevLeafOff = numPrefixRecordsOff + 4; // 22
protected static final int nextLeafOff = prevLeafOff + 4; // 26
protected ICachedPage page = null;
protected ByteBuffer buf = null;
- protected IFrameCompressor compressor;
+ public IFrameCompressor compressor;
public IPrefixSlotManager slotManager; // TODO: should be protected, but will trigger some refactoring
public FieldPrefixNSMLeaf() {
this.slotManager = new FieldPrefixSlotManager();
- this.compressor = new FieldPrefixCompressor();
+ this.compressor = new FieldPrefixCompressor(0.001f, 2);
}
@Override
@@ -76,8 +63,8 @@
}
@Override
- public void compress(MultiComparator cmp) throws Exception {
- compressor.compress(this, cmp);
+ public boolean compress(MultiComparator cmp) throws Exception {
+ return compressor.compress(this, cmp);
}
// assumptions:
@@ -254,6 +241,7 @@
buf.putInt(pageLsnOff, 0); // TODO: might to set to a different lsn during creation
buf.putInt(numRecordsOff, 0);
resetSpaceParams();
+ buf.putInt(numUncompressedRecordsOff, 0);
buf.putInt(numPrefixRecordsOff, 0);
buf.put(levelOff, level);
buf.put(smFlagOff, (byte)0);
@@ -270,7 +258,7 @@
}
@Override
- public void insert(byte[] data, MultiComparator cmp) throws Exception {
+ public void insert(byte[] data, MultiComparator cmp) throws Exception {
int slot = slotManager.findSlot(buf, data, cmp, false);
slot = slotManager.insertSlot(slot, buf.getInt(freeSpaceOff));
@@ -294,17 +282,20 @@
for(int i = numPrefixFields; i < cmp.getFields().length; i++) {
suffixSize += cmp.getFields()[i].getLength(data, suffixSize);
}
- suffixSize -= suffixStartOff;
+ suffixSize -= suffixStartOff;
+ }
+ else {
+ buf.putInt(numUncompressedRecordsOff, buf.getInt(numUncompressedRecordsOff) + 1);
}
int freeSpace = buf.getInt(freeSpaceOff);
- System.arraycopy(data, suffixStartOff, buf.array(), freeSpace, suffixSize);
+ System.arraycopy(data, suffixStartOff, buf.array(), freeSpace, suffixSize);
buf.putInt(numRecordsOff, buf.getInt(numRecordsOff) + 1);
buf.putInt(freeSpaceOff, buf.getInt(freeSpaceOff) + suffixSize);
buf.putInt(totalFreeSpaceOff, buf.getInt(totalFreeSpaceOff) - suffixSize - slotManager.getSlotSize());
//System.out.println(buf.getInt(totalFreeSpaceOff) + " " + buf.getInt(freeSpaceOff) + " " + buf.getInt(numRecordsOff));
- //System.out.println("COPIED: " + suffixSize + " / " + data.length);
+ //System.out.println("COPIED: " + suffixSize + " / " + data.length);
}
public void verifyPrefixes(MultiComparator cmp) {
@@ -434,10 +425,6 @@
@Override
public int split(IBTreeFrame rightFrame, byte[] data, MultiComparator cmp, SplitKey splitKey) throws Exception {
- //System.out.println("ORIG");
- //String orig = printKeys(cmp);
- //System.out.println(orig);
-
FieldPrefixNSMLeaf rf = (FieldPrefixNSMLeaf)rightFrame;
// before doing anything check if key already exists
@@ -555,7 +542,7 @@
right.putInt(numRecordsOff, recordsToRight);
right.putInt(numPrefixRecordsOff, prefixesToRight);
-
+
// on left page move slots to reflect possibly removed prefixes
src = slotManager.getRecSlotEndOff() + recordsToRight * slotManager.getSlotSize();
dest = slotManager.getRecSlotEndOff() + recordsToRight * slotManager.getSlotSize() + (numPrefixRecords - prefixesToLeft) * slotManager.getSlotSize();
@@ -563,33 +550,11 @@
System.arraycopy(buf.array(), src, buf.array(), dest, length);
buf.putInt(numRecordsOff, recordsToLeft);
- buf.putInt(numPrefixRecordsOff, prefixesToLeft);
-
-
- //System.out.println("VERIFY LEFT");
- //verifyPrefixes(cmp);
-
- //System.out.println("VERIFY RIGHT");
- //rf.verifyPrefixes(cmp);
-
- String a = printKeys(cmp);
- String b = rightFrame.printKeys(cmp);
- //System.out.println("BEFORE COMPACT");
- //System.out.println(a);
- //System.out.println(b);
-
+ buf.putInt(numPrefixRecordsOff, prefixesToLeft);
+
// compact both pages
compact(cmp);
rightFrame.compact(cmp);
-
- a = printKeys(cmp);
- b = rightFrame.printKeys(cmp);
- //System.out.println("AFTER COMPACT");
- //System.out.println(a);
- //System.out.println(b);
-
- //System.out.println("AFTER SPLIT REC: " + getNumRecords() + " " + rightFrame.getNumRecords());
- //System.out.println("AFTER SPLIT TOT: " + getTotalFreeSpace() + " " + rightFrame.getTotalFreeSpace());
// insert last key
targetFrame.insert(data, cmp);
@@ -643,4 +608,12 @@
public int getPrevLeaf() {
return buf.getInt(prevLeafOff);
}
+
+ public int getNumUncompressedRecords() {
+ return buf.getInt(numUncompressedRecordsOff);
+ }
+
+ public void setNumUncompressedRecords(int numUncompressedRecords) {
+ buf.putInt(numUncompressedRecordsOff, numUncompressedRecords);
+ }
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeafFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeafFactory.java
index b01dc4b..951e0e2 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeafFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/FieldPrefixNSMLeafFactory.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.frames;
+package edu.uci.ics.asterix.indexing.btree.frames;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeafFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeafFactory;
public class FieldPrefixNSMLeafFactory implements IBTreeFrameLeafFactory {
@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 50137cf..6ae6622 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
@@ -1,50 +1,35 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.util.ArrayList;
import java.util.Stack;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
-import java.util.logging.Logger;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeCursor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInterior;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInteriorFactory;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeafFactory;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameMeta;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManagerFactory;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.SpaceStatus;
-import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
-import edu.uci.ics.hyracks.storage.common.file.FileInfo;
+import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeCursor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInterior;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInteriorFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeafFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameMeta;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManagerFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.SpaceStatus;
+import edu.uci.ics.asterix.storage.buffercache.IBufferCache;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.file.FileInfo;
public class BTree {
- private static final Logger LOGGER = Logger.getLogger(BTree.class.getName());
-
+
private final static int RESTART_OP = Integer.MIN_VALUE;
private final static int MAX_RESTARTS = 10;
private final int metaDataPage = 0; // page containing meta data, e.g.,
// maxPage
private final int rootPage = 1; // the root page never changes
-
+
private final IBufferCache bufferCache;
private int fileId;
private final IBTreeFrameInteriorFactory interiorFrameFactory;
@@ -53,7 +38,7 @@
private final ISlotManagerFactory leafSlotManagerFactory;
private final MultiComparator cmp;
private final ReadWriteLock treeLatch;
-
+
public int rootSplits = 0;
public int[] splitsByLevel = new int[500];
public long readLatchesAcquired = 0;
@@ -70,7 +55,7 @@
public int usefulCompression = 0;
public int uselessCompression = 0;
-
+
public String printStats() {
StringBuilder strBuilder = new StringBuilder();
strBuilder.append("\n");
@@ -96,12 +81,12 @@
this.cmp = cmp;
this.treeLatch = new ReentrantReadWriteLock(true);
}
-
+
public void create(int fileId, IBTreeFrameLeaf leafFrame, IBTreeFrameMeta metaFrame) throws Exception {
// initialize meta data page
ICachedPage metaNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, metaDataPage), false);
pins++;
-
+
metaNode.acquireWriteLatch();
writeLatchesAcquired++;
try {
@@ -114,11 +99,11 @@
bufferCache.unpin(metaNode);
unpins++;
}
-
+
// initialize root page
ICachedPage rootNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, rootPage), true);
pins++;
-
+
rootNode.acquireWriteLatch();
writeLatchesAcquired++;
try {
@@ -126,7 +111,7 @@
leafFrame.initBuffer((byte) 0);
} finally {
rootNode.releaseWriteLatch();
- writeLatchesReleased++;
+ writeLatchesReleased++;
bufferCache.unpin(rootNode);
unpins++;
}
@@ -144,10 +129,10 @@
private int getFreePage(IBTreeFrameMeta metaFrame) throws Exception {
ICachedPage metaNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, metaDataPage), false);
pins++;
-
+
metaNode.acquireWriteLatch();
writeLatchesAcquired++;
-
+
int freePage = -1;
try {
metaFrame.setPage(metaNode);
@@ -157,7 +142,7 @@
if (nextPage > 0) { // sibling may have free pages
ICachedPage nextNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, nextPage), false);
pins++;
-
+
nextNode.acquireWriteLatch();
writeLatchesAcquired++;
// we copy over the free space entries of nextpage into the
@@ -171,9 +156,8 @@
// copy entire page (including sibling pointer, free
// page entries, and all other info)
// after this copy nextPage is considered a free page
- System.arraycopy(nextNode.getBuffer().array(), 0, metaNode.getBuffer().array(), 0, nextNode
- .getBuffer().capacity());
-
+ System.arraycopy(nextNode.getBuffer().array(), 0, metaNode.getBuffer().array(), 0, nextNode.getBuffer().capacity());
+
// reset unchanged entry
metaFrame.setMaxPage(maxPage);
@@ -206,7 +190,7 @@
return freePage;
}
-
+
private void addFreePages(BTreeOpContext ctx) throws Exception {
for (Integer i : ctx.freePages) {
addFreePage(ctx.metaFrame, i);
@@ -216,101 +200,102 @@
private void addFreePage(IBTreeFrameMeta metaFrame, int freePage) throws Exception {
// root page is special, don't add it to free pages
- if (freePage == rootPage)
- return;
-
+ if (freePage == rootPage) return;
+
ICachedPage metaNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, metaDataPage), false);
pins++;
-
+
metaNode.acquireWriteLatch();
writeLatchesAcquired++;
-
+
metaFrame.setPage(metaNode);
try {
- if (metaFrame.hasSpace()) {
- metaFrame.addFreePage(freePage);
- } else {
+ if(metaFrame.hasSpace()) {
+ metaFrame.addFreePage(freePage);
+ }
+ else {
// allocate a new page in the chain of meta pages
int newPage = metaFrame.getFreePage();
- if (newPage < 0) {
+ if(newPage < 0) {
throw new Exception("Inconsistent Meta Page State. It has no space, but it also has no entries.");
}
-
+
ICachedPage newNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, newPage), false);
pins++;
-
+
newNode.acquireWriteLatch();
writeLatchesAcquired++;
-
- try {
+
+
+ try {
int metaMaxPage = metaFrame.getMaxPage();
// copy metaDataPage to newNode
- System.arraycopy(metaNode.getBuffer().array(), 0, newNode.getBuffer().array(), 0, metaNode
- .getBuffer().capacity());
-
+ System.arraycopy(metaNode.getBuffer().array(), 0, newNode.getBuffer().array(), 0, metaNode.getBuffer().capacity());
+
metaFrame.initBuffer(-1);
metaFrame.setNextPage(newPage);
metaFrame.setMaxPage(metaMaxPage);
- metaFrame.addFreePage(freePage);
+ metaFrame.addFreePage(freePage);
} finally {
newNode.releaseWriteLatch();
writeLatchesReleased++;
-
+
bufferCache.unpin(newNode);
unpins++;
}
- }
+ }
} catch (Exception e) {
e.printStackTrace();
} finally {
metaNode.releaseWriteLatch();
writeLatchesReleased++;
-
+
bufferCache.unpin(metaNode);
unpins++;
}
}
-
+
public void printTree(IBTreeFrameLeaf leafFrame, IBTreeFrameInterior interiorFrame) throws Exception {
printTree(rootPage, null, false, leafFrame, interiorFrame);
}
public void printTree(int pageId, ICachedPage parent, boolean unpin, IBTreeFrameLeaf leafFrame,
IBTreeFrameInterior interiorFrame) throws Exception {
-
+
ICachedPage node = bufferCache.pin(FileInfo.getDiskPageId(fileId, pageId), false);
pins++;
node.acquireReadLatch();
readLatchesAcquired++;
-
+
try {
if (parent != null && unpin == true) {
parent.releaseReadLatch();
readLatchesReleased++;
-
+
bufferCache.unpin(parent);
unpins++;
}
interiorFrame.setPage(node);
int level = interiorFrame.getLevel();
- if (LOGGER.isLoggable(Level.FINEST)) {
- LOGGER.finest(String.format("%1d ", level));
- LOGGER.finest(String.format("%3d ", pageId));
+ if (GlobalConfig.ASTERIX_LOGGER.isLoggable(Level.FINEST)) {
+ GlobalConfig.ASTERIX_LOGGER.finest(String.format("%1d ", level));
+ GlobalConfig.ASTERIX_LOGGER.finest(String.format("%3d ", pageId));
for (int i = 0; i < currentLevel - level; i++)
- LOGGER.finest(" ");
-
+ GlobalConfig.ASTERIX_LOGGER.finest(" ");
+
String keyString;
- if (interiorFrame.isLeaf()) {
- leafFrame.setPage(node);
- keyString = leafFrame.printKeys(cmp);
- } else {
- keyString = interiorFrame.printKeys(cmp);
+ if(interiorFrame.isLeaf()) {
+ leafFrame.setPage(node);
+ keyString = leafFrame.printKeys(cmp);
}
-
- LOGGER.finest(keyString);
+ else {
+ keyString = interiorFrame.printKeys(cmp);
+ }
+
+ GlobalConfig.ASTERIX_LOGGER.finest(keyString);
}
if (!interiorFrame.isLeaf()) {
@@ -321,41 +306,40 @@
} else {
node.releaseReadLatch();
readLatchesReleased++;
-
+
bufferCache.unpin(node);
unpins++;
}
} catch (Exception e) {
node.releaseReadLatch();
readLatchesReleased++;
-
+
bufferCache.unpin(node);
unpins++;
}
}
- public void diskOrderScan(BTreeDiskOrderScanCursor cursor, IBTreeFrameLeaf leafFrame, IBTreeFrameMeta metaFrame)
- throws Exception {
+ public void diskOrderScan(BTreeDiskOrderScanCursor cursor, IBTreeFrameLeaf leafFrame, IBTreeFrameMeta metaFrame) throws Exception {
int currentPageId = rootPage + 1;
int maxPageId = -1;
-
+
ICachedPage metaNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, metaDataPage), false);
pins++;
-
+
metaNode.acquireReadLatch();
readLatchesAcquired++;
-
+
try {
metaFrame.setPage(metaNode);
maxPageId = metaFrame.getMaxPage();
} finally {
metaNode.releaseReadLatch();
readLatchesAcquired++;
-
+
bufferCache.unpin(metaNode);
unpins++;
}
-
+
ICachedPage page = bufferCache.pin(FileInfo.getDiskPageId(fileId, currentPageId), false);
page.acquireReadLatch();
cursor.setBufferCache(bufferCache);
@@ -364,7 +348,7 @@
cursor.setMaxPageId(maxPageId);
cursor.open(page, null);
}
-
+
public void search(IBTreeCursor cursor, RangePredicate pred, IBTreeFrameLeaf leafFrame,
IBTreeFrameInterior interiorFrame) throws Exception {
BTreeOpContext ctx = new BTreeOpContext();
@@ -519,131 +503,134 @@
repeatOp = false;
}
}
-
+
+ public long uselessCompressionTime = 0;
+
private void insertLeaf(ICachedPage node, int pageId, byte[] data, BTreeOpContext ctx) throws Exception {
- ctx.leafFrame.setPage(node);
- SpaceStatus spaceStatus = ctx.leafFrame.hasSpaceInsert(data, cmp);
- switch (spaceStatus) {
+ ctx.leafFrame.setPage(node);
+ SpaceStatus spaceStatus = ctx.leafFrame.hasSpaceInsert(data, cmp);
+ switch (spaceStatus) {
+
+ case SUFFICIENT_CONTIGUOUS_SPACE: {
+ // System.out.println("INSERT LEAF");
+ ctx.leafFrame.insert(data, cmp);
+ ctx.splitKey.reset();
+ } break;
- case SUFFICIENT_CONTIGUOUS_SPACE: {
- // System.out.println("INSERT LEAF");
- ctx.leafFrame.insert(data, cmp);
- ctx.splitKey.reset();
- }
- break;
+ case SUFFICIENT_SPACE: {
+ ctx.leafFrame.compact(cmp);
+ ctx.leafFrame.insert(data, cmp);
+ ctx.splitKey.reset();
+ } break;
- case SUFFICIENT_SPACE: {
- ctx.leafFrame.compact(cmp);
- ctx.leafFrame.insert(data, cmp);
- ctx.splitKey.reset();
- }
- break;
+ case INSUFFICIENT_SPACE: {
+ // try compressing the page first and see if there is space available
+ long start = System.currentTimeMillis();
+ boolean reCompressed = ctx.leafFrame.compress(cmp);
+ long end = System.currentTimeMillis();
+ if(reCompressed) spaceStatus = ctx.leafFrame.hasSpaceInsert(data, cmp);
+
+ if(spaceStatus == SpaceStatus.SUFFICIENT_CONTIGUOUS_SPACE) {
+ ctx.leafFrame.insert(data, cmp);
+ ctx.splitKey.reset();
+
+ usefulCompression++;
+ }
+ else {
+ uselessCompressionTime += (end - start);
+ uselessCompression++;
+
+ // perform split
+ splitsByLevel[0]++; // debug
+ int rightSiblingPageId = ctx.leafFrame.getNextLeaf();
+ ICachedPage rightSibling = null;
+ if (rightSiblingPageId > 0) {
+ rightSibling = bufferCache.pin(FileInfo.getDiskPageId(fileId, rightSiblingPageId), false);
+ pins++;
+ }
- case INSUFFICIENT_SPACE: {
- // try compressing the page first and see if there is space available
- ctx.leafFrame.compress(cmp);
- spaceStatus = ctx.leafFrame.hasSpaceInsert(data, cmp);
+ treeLatch.writeLock().lock(); // lock is released in
+ // unsetSmPages(), after sm has
+ // fully completed
+ treeLatchesAcquired++;
+ try {
- if (spaceStatus == SpaceStatus.SUFFICIENT_CONTIGUOUS_SPACE) {
- ctx.leafFrame.insert(data, cmp);
- ctx.splitKey.reset();
+ int rightPageId = getFreePage(ctx.metaFrame);
+ ICachedPage rightNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, rightPageId), true);
+ pins++;
+ rightNode.acquireWriteLatch();
+ writeLatchesAcquired++;
+ try {
+ ISlotManager rightSlotManager = leafSlotManagerFactory.getSlotManager();
+ IBTreeFrameLeaf rightFrame = leafFrameFactory.getFrame();
+ rightFrame.setPage(rightNode);
+ rightFrame.initBuffer((byte) 0);
- usefulCompression++;
- } else {
- uselessCompression++;
+ int ret = ctx.leafFrame.split(rightFrame, data, cmp, ctx.splitKey);
- // perform split
- splitsByLevel[0]++; // debug
- int rightSiblingPageId = ctx.leafFrame.getNextLeaf();
- ICachedPage rightSibling = null;
- if (rightSiblingPageId > 0) {
- rightSibling = bufferCache.pin(FileInfo.getDiskPageId(fileId, rightSiblingPageId), false);
- pins++;
- }
+ ctx.smPages.add(pageId);
+ ctx.smPages.add(rightPageId);
+ ctx.leafFrame.setSmFlag(true);
+ rightFrame.setSmFlag(true);
- treeLatch.writeLock().lock(); // lock is released in
- // unsetSmPages(), after sm has
- // fully completed
- treeLatchesAcquired++;
- try {
+ rightFrame.setNextLeaf(ctx.leafFrame.getNextLeaf());
+ rightFrame.setPrevLeaf(pageId);
+ ctx.leafFrame.setNextLeaf(rightPageId);
- int rightPageId = getFreePage(ctx.metaFrame);
- ICachedPage rightNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, rightPageId), true);
- pins++;
- rightNode.acquireWriteLatch();
- writeLatchesAcquired++;
- try {
- ISlotManager rightSlotManager = leafSlotManagerFactory.getSlotManager();
- IBTreeFrameLeaf rightFrame = leafFrameFactory.getFrame();
- rightFrame.setPage(rightNode);
- rightFrame.initBuffer((byte) 0);
+ // TODO: we just use increasing numbers as pageLsn, we
+ // should tie this together with the LogManager and
+ // TransactionManager
+ rightFrame.setPageLsn(rightFrame.getPageLsn() + 1);
+ ctx.leafFrame.setPageLsn(ctx.leafFrame.getPageLsn() + 1);
- int ret = ctx.leafFrame.split(rightFrame, data, cmp, ctx.splitKey);
+ if (ret != 0) {
+ ctx.splitKey.reset();
+ } else {
+ // System.out.print("LEAF SPLITKEY: ");
+ // cmp.printKey(splitKey.getData(), 0);
+ // System.out.println("");
- ctx.smPages.add(pageId);
- ctx.smPages.add(rightPageId);
- ctx.leafFrame.setSmFlag(true);
- rightFrame.setSmFlag(true);
+ ctx.splitKey.setPages(pageId, rightPageId);
+ }
+ if (rightSibling != null) {
+ rightSibling.acquireWriteLatch();
+ writeLatchesAcquired++;
+ try {
+ rightFrame.setPage(rightSibling); // reuse
+ // rightFrame
+ // for
+ // modification
+ rightFrame.setPrevLeaf(rightPageId);
+ } finally {
+ rightSibling.releaseWriteLatch();
+ writeLatchesReleased++;
+ }
+ }
+ } finally {
+ rightNode.releaseWriteLatch();
+ writeLatchesReleased++;
+ bufferCache.unpin(rightNode);
+ unpins++;
+ }
+ } catch (Exception e) {
+ treeLatch.writeLock().unlock();
+ treeLatchesReleased++;
+ throw e;
+ } finally {
+ if (rightSibling != null) {
+ bufferCache.unpin(rightSibling);
+ unpins++;
+ }
+ }
+ }
+ } break;
+
+ }
- rightFrame.setNextLeaf(ctx.leafFrame.getNextLeaf());
- rightFrame.setPrevLeaf(pageId);
- ctx.leafFrame.setNextLeaf(rightPageId);
-
- // TODO: we just use increasing numbers as pageLsn, we
- // should tie this together with the LogManager and
- // TransactionManager
- rightFrame.setPageLsn(rightFrame.getPageLsn() + 1);
- ctx.leafFrame.setPageLsn(ctx.leafFrame.getPageLsn() + 1);
-
- if (ret != 0) {
- ctx.splitKey.reset();
- } else {
- // System.out.print("LEAF SPLITKEY: ");
- // cmp.printKey(splitKey.getData(), 0);
- // System.out.println("");
-
- ctx.splitKey.setPages(pageId, rightPageId);
- }
- if (rightSibling != null) {
- rightSibling.acquireWriteLatch();
- writeLatchesAcquired++;
- try {
- rightFrame.setPage(rightSibling); // reuse
- // rightFrame
- // for
- // modification
- rightFrame.setPrevLeaf(rightPageId);
- } finally {
- rightSibling.releaseWriteLatch();
- writeLatchesReleased++;
- }
- }
- } finally {
- rightNode.releaseWriteLatch();
- writeLatchesReleased++;
- bufferCache.unpin(rightNode);
- unpins++;
- }
- } catch (Exception e) {
- treeLatch.writeLock().unlock();
- treeLatchesReleased++;
- throw e;
- } finally {
- if (rightSibling != null) {
- bufferCache.unpin(rightSibling);
- unpins++;
- }
- }
- }
- }
- break;
-
- }
-
- node.releaseWriteLatch();
- writeLatchesReleased++;
- bufferCache.unpin(node);
- unpins++;
+ node.releaseWriteLatch();
+ writeLatchesReleased++;
+ bufferCache.unpin(node);
+ unpins++;
}
private void insertInterior(ICachedPage node, int pageId, byte[] data, BTreeOpContext ctx) throws Exception {
@@ -1052,8 +1039,7 @@
} // end while
} else { // smFlag
ctx.opRestarts++;
- System.out.println("ONGOING SM ON PAGE " + pageId + " AT LEVEL " + ctx.interiorFrame.getLevel()
- + ", RESTARTS: " + ctx.opRestarts);
+ System.out.println("ONGOING SM ON PAGE " + pageId + " AT LEVEL " + ctx.interiorFrame.getLevel() + ", RESTARTS: " + ctx.opRestarts);
releaseLatch(node, ctx.op, isLeaf);
bufferCache.unpin(node);
unpins++;
@@ -1107,6 +1093,7 @@
// failure to pin a new node during a
// split
System.out.println("ASTERIX EXCEPTION");
+ e.printStackTrace();
releaseLatch(node, ctx.op, isLeaf);
bufferCache.unpin(node);
unpins++;
@@ -1121,7 +1108,7 @@
private boolean bulkNewPage = false;
- public final class BulkLoadContext {
+ public final class BulkLoadContext {
public int slotSize;
public int leafMaxBytes;
public int interiorMaxBytes;
@@ -1214,18 +1201,17 @@
frontier.lastRecord = insBytes;
frontier.bytesInserted += spaceNeeded;
}
-
+
// assumes btree has been created and opened
- public BulkLoadContext beginBulkLoad(float fillFactor, IBTreeFrameLeaf leafFrame,
- IBTreeFrameInterior interiorFrame, IBTreeFrameMeta metaFrame) throws Exception {
- BulkLoadContext ctx = new BulkLoadContext(fillFactor, leafFrame, interiorFrame, metaFrame);
+ public BulkLoadContext beginBulkLoad(float fillFactor, IBTreeFrameLeaf leafFrame, IBTreeFrameInterior interiorFrame, IBTreeFrameMeta metaFrame) throws Exception {
+ BulkLoadContext ctx = new BulkLoadContext(fillFactor, leafFrame, interiorFrame, metaFrame);
return ctx;
}
-
- public void bulkLoadAddRecord(BulkLoadContext ctx, byte[] record) throws Exception {
+
+ public void bulkLoadAddRecord(BulkLoadContext ctx, byte[] record) throws Exception {
NodeFrontier leafFrontier = ctx.nodeFrontiers.get(0);
IBTreeFrameLeaf leafFrame = ctx.leafFrame;
-
+
int spaceNeeded = record.length + ctx.slotSize;
if (leafFrontier.bytesInserted + spaceNeeded > ctx.leafMaxBytes) {
int splitKeySize = cmp.getKeySize(leafFrontier.lastRecord, 0);
@@ -1248,22 +1234,21 @@
leafFrame.setPrevLeaf(prevPageId);
leafFrontier.bytesInserted = 0;
}
-
+
leafFrame.setPage(leafFrontier.page);
leafFrame.insertSorted(record, cmp);
leafFrontier.lastRecord = record;
leafFrontier.bytesInserted += spaceNeeded;
}
-
- public void endBulkLoad(BulkLoadContext ctx) throws Exception {
+
+ public void endBulkLoad(BulkLoadContext ctx) throws Exception {
// copy root
ICachedPage rootNode = bufferCache.pin(FileInfo.getDiskPageId(fileId, rootPage), bulkNewPage);
rootNode.acquireWriteLatch();
- try {
+ try {
ICachedPage toBeRoot = ctx.nodeFrontiers.get(ctx.nodeFrontiers.size() - 1).page;
- System.arraycopy(toBeRoot.getBuffer().array(), 0, rootNode.getBuffer().array(), 0, toBeRoot.getBuffer()
- .capacity());
- } finally {
+ System.arraycopy(toBeRoot.getBuffer().array(), 0, rootNode.getBuffer().array(), 0, toBeRoot.getBuffer().capacity());
+ } finally {
rootNode.releaseWriteLatch();
bufferCache.unpin(rootNode);
@@ -1276,7 +1261,7 @@
// debug
currentLevel = (byte) ctx.nodeFrontiers.size();
}
-
+
public IBTreeFrameInteriorFactory getInteriorFrameFactory() {
return interiorFrameFactory;
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeDiskOrderScanCursor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeDiskOrderScanCursor.java
index 47f43ab..b2b4a5b 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeDiskOrderScanCursor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeDiskOrderScanCursor.java
@@ -1,46 +1,32 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeCursor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISearchPredicate;
-import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
-import edu.uci.ics.hyracks.storage.common.file.FileInfo;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeCursor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISearchPredicate;
+import edu.uci.ics.asterix.storage.buffercache.IBufferCache;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.file.FileInfo;
public class BTreeDiskOrderScanCursor implements IBTreeCursor {
-
+
// TODO: might want to return records in physical order, not logical order to speed up access
-
+
private int recordNum = 0;
private int recordOffset = -1;
- private int fileId = -1;
+ private int fileId = -1;
int currentPageId = -1;
int maxPageId = -1; // TODO: figure out how to scan to the end of file, this is dirty and may not with concurrent updates
private ICachedPage page = null;
private IBTreeFrameLeaf frame = null;
private IBufferCache bufferCache = null;
-
+
public BTreeDiskOrderScanCursor(IBTreeFrameLeaf frame) {
this.frame = frame;
}
-
+
@Override
- public void close() throws HyracksDataException {
+ public void close() throws AsterixException {
page.releaseReadLatch();
bufferCache.unpin(page);
page = null;
@@ -55,91 +41,89 @@
public ICachedPage getPage() {
return page;
}
-
- private boolean positionToNextLeaf(boolean skipCurrent) throws HyracksDataException {
- while ((frame.getLevel() != 0 || skipCurrent) && currentPageId <= maxPageId) {
+
+ private boolean positionToNextLeaf(boolean skipCurrent) throws AsterixException {
+ while( (frame.getLevel() != 0 || skipCurrent) && currentPageId <= maxPageId) {
currentPageId++;
-
+
ICachedPage nextPage = bufferCache.pin(FileInfo.getDiskPageId(fileId, currentPageId), false);
nextPage.acquireReadLatch();
-
+
page.releaseReadLatch();
bufferCache.unpin(page);
-
+
page = nextPage;
frame.setPage(page);
recordNum = 0;
skipCurrent = false;
- }
- if (currentPageId <= maxPageId)
- return true;
- else
- return false;
+ }
+ if(currentPageId <= maxPageId) return true;
+ else return false;
}
-
+
@Override
- public boolean hasNext() throws HyracksDataException {
- if (recordNum >= frame.getNumRecords()) {
+ public boolean hasNext() throws AsterixException {
+ if(recordNum >= frame.getNumRecords()) {
boolean nextLeafExists = positionToNextLeaf(true);
- if (nextLeafExists) {
+ if(nextLeafExists) {
recordOffset = frame.getRecordOffset(recordNum);
return true;
- } else {
- return false;
}
- }
-
+ else {
+ return false;
+ }
+ }
+
recordOffset = frame.getRecordOffset(recordNum);
return true;
}
@Override
- public void next() throws HyracksDataException {
+ public void next() throws AsterixException {
recordNum++;
}
-
+
@Override
- public void open(ICachedPage page, ISearchPredicate searchPred) throws HyracksDataException {
+ public void open(ICachedPage page, ISearchPredicate searchPred) throws AsterixException {
// in case open is called multiple times without closing
- if (this.page != null) {
+ if(this.page != null) {
this.page.releaseReadLatch();
bufferCache.unpin(this.page);
}
-
+
this.page = page;
recordNum = 0;
frame.setPage(page);
boolean leafExists = positionToNextLeaf(false);
- if (!leafExists) {
- throw new HyracksDataException(
- "Failed to open disk-order scan cursor for B-tree. Traget B-tree has no leaves.");
+ if(!leafExists) {
+ throw new AsterixException("Failed to open disk-order scan cursor for B-tree. Traget B-tree has no leaves.");
}
}
-
+
@Override
public void reset() {
recordNum = 0;
recordOffset = 0;
currentPageId = -1;
maxPageId = -1;
- page = null;
+ page = null;
}
@Override
public void setBufferCache(IBufferCache bufferCache) {
- this.bufferCache = bufferCache;
+ this.bufferCache = bufferCache;
}
@Override
public void setFileId(int fileId) {
this.fileId = fileId;
- }
-
+ }
+
public void setCurrentPageId(int currentPageId) {
this.currentPageId = currentPageId;
}
-
+
public void setMaxPageId(int maxPageId) {
this.maxPageId = maxPageId;
}
-}
\ No newline at end of file
+}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeException.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeException.java
index 4e6d9d6..68c8c92 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeException.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeException.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
public class BTreeException extends Exception {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMeta.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMeta.java
index 696a5be..8ddb04a 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMeta.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMeta.java
@@ -1,23 +1,9 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameMeta;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameMeta;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
// all meta pages of this kind have a negative level
// the first meta page has level -1, all other meta pages have level -2
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMetaFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMetaFactory.java
index 88d8bc9..fc12b2a 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMetaFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeMetaFactory.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameMeta;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameMetaFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameMeta;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameMetaFactory;
public class BTreeMetaFactory implements IBTreeFrameMetaFactory {
@Override
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSM.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSM.java
index 77dbd62..cd47eee 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSM.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSM.java
@@ -1,20 +1,6 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrame;
public abstract class BTreeNSM extends NSMFrame implements IBTreeFrame {
@@ -54,13 +40,10 @@
@Override
public void setSmFlag(boolean smFlag) {
- if(smFlag)
- buf.put(smFlagOff, (byte)1);
- else
- buf.put(smFlagOff, (byte)0);
+ if(smFlag)buf.put(smFlagOff, (byte)1);
+ else buf.put(smFlagOff, (byte)0);
}
- // TODO: remove
@Override
public int getFreeSpaceOff() {
return buf.getInt(freeSpaceOff);
@@ -69,9 +52,5 @@
@Override
public void setFreeSpaceOff(int freeSpace) {
buf.putInt(freeSpaceOff, freeSpace);
- }
-
- @Override
- public void compress(MultiComparator cmp) {
- }
+ }
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInterior.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInterior.java
index 18d53f8..eb0aeb6 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInterior.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInterior.java
@@ -1,25 +1,12 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInterior;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInterior;
+import edu.uci.ics.asterix.om.AInt32;
public class BTreeNSMInterior extends BTreeNSM implements IBTreeFrameInterior {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInteriorFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInteriorFactory.java
index 5360f7d..82b3544 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInteriorFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMInteriorFactory.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInterior;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInteriorFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInterior;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInteriorFactory;
public class BTreeNSMInteriorFactory implements IBTreeFrameInteriorFactory {
@Override
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeaf.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeaf.java
index 852dc31..6f17876 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeaf.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeaf.java
@@ -1,23 +1,9 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
public class BTreeNSMLeaf extends BTreeNSM implements IBTreeFrameLeaf {
protected static final int prevLeafOff = smFlagOff + 1;
@@ -74,7 +60,7 @@
buf.putInt(numRecordsOff, buf.getInt(numRecordsOff) + 1);
buf.putInt(freeSpaceOff, buf.getInt(freeSpaceOff) + data.length);
buf.putInt(totalFreeSpaceOff, buf.getInt(totalFreeSpaceOff) - data.length - slotManager.getSlotSize());
- }
+ }
}
@Override
@@ -89,6 +75,7 @@
@Override
public int split(IBTreeFrame rightFrame, byte[] data, MultiComparator cmp, SplitKey splitKey) throws Exception {
+
// before doing anything check if key already exists
int slotOff = slotManager.findSlot(buf, data, cmp, true);
if (slotOff >= 0) {
@@ -137,7 +124,7 @@
int keySize = cmp.getKeySize(buf.array(), recOff);
splitKey.initData(keySize);
System.arraycopy(buf.array(), recOff, splitKey.getData(), 0, keySize);
-
+
return 0;
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeafFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeafFactory.java
index 7691b7d..622ebbd 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeafFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeNSMLeafFactory.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeafFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeafFactory;
public class BTreeNSMLeafFactory implements IBTreeFrameLeafFactory {
@Override
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOp.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOp.java
index 27fe7cd..fb31065 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOp.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTreeOp.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
public enum BTreeOp {
BTO_INSERT,
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 9262b89..2f6b9ba 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
@@ -1,26 +1,12 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.util.ArrayList;
import java.util.Stack;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeCursor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameInterior;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameMeta;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeCursor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameInterior;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameMeta;
public final class BTreeOpContext {
public BTreeOp op;
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 fc97363..17dcd93 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
@@ -1,25 +1,11 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeCursor;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IBTreeFrameLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISearchPredicate;
-import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
-import edu.uci.ics.hyracks.storage.common.file.FileInfo;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeCursor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IBTreeFrameLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISearchPredicate;
+import edu.uci.ics.asterix.storage.buffercache.IBufferCache;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.file.FileInfo;
public class BTreeRangeSearchCursor implements IBTreeCursor {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldIterator.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldIterator.java
index 1c903b5..bff83cb 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldIterator.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldIterator.java
@@ -1,26 +1,13 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.frames.FieldPrefixNSMLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFieldAccessor;
+import edu.uci.ics.asterix.indexing.btree.frames.FieldPrefixNSMLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFieldAccessor;
//TODO: make members private, only for debugging now
public class FieldIterator {
public int recSlotOff = -1;
public int recOff = -1;
+ public int prefixSlotNum = FieldPrefixSlotManager.RECORD_UNCOMPRESSED;
public int numPrefixFields = 0;
public IFieldAccessor[] fields;
public FieldPrefixNSMLeaf frame;
@@ -55,7 +42,7 @@
currentField = 0;
numPrefixFields = 0;
int recSlot = frame.getBuffer().getInt(recSlotOff);
- int prefixSlotNum = frame.slotManager.decodeFirstSlotField(recSlot);
+ prefixSlotNum = frame.slotManager.decodeFirstSlotField(recSlot);
recOff = frame.slotManager.decodeSecondSlotField(recSlot);
// position to prefix records first (if record is compressed)
@@ -67,14 +54,15 @@
}
else {
recOffRunner = recOff;
- }
+ }
}
public void nextField() {
- // if we have passed the prefix fields of any of the two records, position them to the suffix record
+
+ // if we have passed the prefix fields of any of the two records, position them to the suffix record
if(currentField+1 == numPrefixFields) recOffRunner = recOff;
else recOffRunner += fields[currentField].getLength(frame.getBuffer().array(), recOffRunner);
- currentField++;
+ currentField++;
}
public int getFieldOff() {
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 920964e..6de959c 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
@@ -1,24 +1,10 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.frames.FieldPrefixNSMLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IComparator;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IPrefixSlotManager;
+import edu.uci.ics.asterix.indexing.btree.frames.FieldPrefixNSMLeaf;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IComparator;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IPrefixSlotManager;
public class FieldPrefixSlotManager implements IPrefixSlotManager {
@@ -66,10 +52,9 @@
return FieldPrefixSlotManager.RECORD_UNCOMPRESSED;
}
-
public int findSlot(ByteBuffer buf, byte[] data, MultiComparator multiCmp, boolean exact) {
if(frame.getNumRecords() <= 0) encodeSlotFields(RECORD_UNCOMPRESSED, GREATEST_SLOT);
-
+
int prefixMid;
int prefixBegin = 0;
int prefixEnd = frame.getNumPrefixRecords() - 1;
@@ -80,29 +65,27 @@
int recPrefixSlotNumUbound = prefixEnd;
// binary search on the prefix slots to determine upper and lower bounds for the prefixSlotNums in record slots
- if(frame.getNumPrefixRecords() > 0) {
- while(prefixBegin <= prefixEnd) {
- prefixMid = (prefixBegin + prefixEnd) / 2;
- int prefixSlotOff = getPrefixSlotOff(prefixMid);
- int prefixSlot = buf.getInt(prefixSlotOff);
- int numPrefixFields = decodeFirstSlotField(prefixSlot);
- int prefixRecOff = decodeSecondSlotField(prefixSlot);
- //System.out.println("PREFIX: " + prefixRecOff + " " + buf.getInt(prefixRecOff) + " " + buf.getInt(prefixRecOff+4));
- int cmp = multiCmp.fieldRangeCompare(data, 0, buf.array(), prefixRecOff, 0, numPrefixFields);
- if(cmp < 0) {
- prefixEnd = prefixMid - 1;
- recPrefixSlotNumLbound = prefixMid - 1;
- }
- else if(cmp > 0) {
- prefixBegin = prefixMid + 1;
- recPrefixSlotNumUbound = prefixMid + 1;
- }
- else {
- recPrefixSlotNumLbound = prefixMid;
- recPrefixSlotNumUbound = prefixMid;
- prefixMatch = prefixMid;
- break;
- }
+ while(prefixBegin <= prefixEnd) {
+ prefixMid = (prefixBegin + prefixEnd) / 2;
+ int prefixSlotOff = getPrefixSlotOff(prefixMid);
+ int prefixSlot = buf.getInt(prefixSlotOff);
+ int numPrefixFields = decodeFirstSlotField(prefixSlot);
+ int prefixRecOff = decodeSecondSlotField(prefixSlot);
+ //System.out.println("PREFIX: " + prefixRecOff + " " + buf.getInt(prefixRecOff) + " " + buf.getInt(prefixRecOff+4));
+ int cmp = multiCmp.fieldRangeCompare(data, 0, buf.array(), prefixRecOff, 0, numPrefixFields);
+ if(cmp < 0) {
+ prefixEnd = prefixMid - 1;
+ recPrefixSlotNumLbound = prefixMid - 1;
+ }
+ else if(cmp > 0) {
+ prefixBegin = prefixMid + 1;
+ recPrefixSlotNumUbound = prefixMid + 1;
+ }
+ else {
+ recPrefixSlotNumLbound = prefixMid;
+ recPrefixSlotNumUbound = prefixMid;
+ prefixMatch = prefixMid;
+ break;
}
}
@@ -129,7 +112,7 @@
else {
if(prefixSlotNum < recPrefixSlotNumLbound) cmp = 1;
else if(prefixSlotNum > recPrefixSlotNumUbound) cmp = -1;
- else cmp = compareCompressed(data, buf.array(), prefixSlotNum, recMid, multiCmp);
+ else cmp = compareCompressed(data, buf.array(), prefixSlotNum, recMid, multiCmp);
}
if(cmp < 0) recEnd = recMid - 1;
@@ -139,8 +122,8 @@
//System.out.println("RECS: " + recBegin + " " + recMid + " " + recEnd);
- if(exact) return encodeSlotFields(prefixMatch, GREATEST_SLOT);
- if(recBegin > frame.getNumRecords() - 1) encodeSlotFields(prefixMatch, GREATEST_SLOT);
+ if(exact) return encodeSlotFields(prefixMatch, GREATEST_SLOT);
+ if(recBegin > (frame.getNumRecords() - 1)) 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
int recSlotOff = getRecSlotOff(recBegin);
@@ -154,7 +137,7 @@
if(cmp < 0) return encodeSlotFields(prefixMatch, recBegin);
else return encodeSlotFields(prefixMatch, GREATEST_SLOT);
- }
+ }
public int compareCompressed(byte[] record, byte[] page, int prefixSlotNum, int recSlotNum, MultiComparator multiCmp) {
IComparator[] cmps = multiCmp.getComparators();
@@ -164,8 +147,8 @@
int recRunner = 0;
int cmp = 0;
- for(int i = 0; i < multiCmp.getKeyLength(); i++) {
- cmp = cmps[i].compare(record, recRunner, buf.array(), fieldIter.getFieldOff());
+ for(int i = 0; i < multiCmp.getKeyLength(); i++) {
+ cmp = cmps[i].compare(record, recRunner, buf.array(), fieldIter.getFieldOff());
if(cmp < 0) return -1;
else if(cmp > 0) return 1;
fieldIter.nextField();
@@ -211,7 +194,9 @@
int slotEndOff = getRecSlotEndOff();
int slotOff = getRecSlotOff(slotNum);
int length = (slotOff - slotEndOff) + slotSize;
- System.arraycopy(frame.getBuffer().array(), slotEndOff, frame.getBuffer().array(), slotEndOff - slotSize, length);
+ System.arraycopy(frame.getBuffer().array(), slotEndOff, frame.getBuffer().array(), slotEndOff - slotSize, length);
+ //System.out.println("MOVING SLOTS: " + length + " " + (frame.getNumRecords()*4));
+
int newSlot = encodeSlotFields(decodeFirstSlotField(slot), recOff);
setSlot(slotOff, newSlot);
//System.out.println("SETTING B: " + slotOff + " " + recOff);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/MultiComparator.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/MultiComparator.java
index d126b59..25a7186 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/MultiComparator.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/MultiComparator.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IComparator;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFieldAccessor;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IComparator;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFieldAccessor;
public class MultiComparator {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NSMFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NSMFrame.java
index 97721db..66577e2 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NSMFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NSMFrame.java
@@ -1,27 +1,13 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.SpaceStatus;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.SpaceStatus;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public class NSMFrame implements IFrame {
@@ -214,9 +200,9 @@
public int getTotalFreeSpace() {
return buf.getInt(totalFreeSpaceOff);
}
-
+
@Override
- public void compress(MultiComparator cmp) {
-
+ public boolean compress(MultiComparator cmp) {
+ return false;
}
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NodeFrontier.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NodeFrontier.java
index cd27d97..5b5de07 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NodeFrontier.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/NodeFrontier.java
@@ -1,20 +1,6 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public class NodeFrontier {
public int bytesInserted;
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManager.java
index 9cb2c24..8717b50 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManager.java
@@ -1,29 +1,15 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.IFrame;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.IFrame;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManager;
public class OrderedSlotManager implements ISlotManager {
private static final int slotSize = 4;
private IFrame frame;
-
+
// TODO: mix in interpolation search
@Override
public int findSlot(ByteBuffer buf, byte[] data, MultiComparator multiCmp, boolean exact) {
@@ -90,7 +76,7 @@
else {
int slotStartOff = getSlotStartOff();
int length = (slotOff - slotStartOff) + slotSize;
- System.arraycopy(frame.getBuffer().array(), slotStartOff, frame.getBuffer().array(), slotStartOff - slotSize, length);
+ System.arraycopy(frame.getBuffer().array(), slotStartOff, frame.getBuffer().array(), slotStartOff - slotSize, length);
setSlot(slotOff, recOff);
return slotOff;
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManagerFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManagerFactory.java
index 2daa514..af7da1c 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManagerFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/OrderedSlotManagerFactory.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManager;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISlotManagerFactory;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManager;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISlotManagerFactory;
public class OrderedSlotManagerFactory implements ISlotManagerFactory {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/RangePredicate.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/RangePredicate.java
index 8f85a1f..7caeda8 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/RangePredicate.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/RangePredicate.java
@@ -1,20 +1,6 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
-import edu.uci.ics.hyracks.storage.am.btree.interfaces.ISearchPredicate;
+import edu.uci.ics.asterix.indexing.btree.interfaces.ISearchPredicate;
public class RangePredicate implements ISearchPredicate {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SlotOffRecOff.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SlotOffRecOff.java
index c198527..0d10052 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SlotOffRecOff.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SlotOffRecOff.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
public class SlotOffRecOff implements Comparable<SlotOffRecOff> {
public int slotOff;
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SplitKey.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SplitKey.java
index 0088277..dda30b5 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SplitKey.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/SplitKey.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.impls;
+package edu.uci.ics.asterix.indexing.btree.impls;
import java.nio.ByteBuffer;
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeCursor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeCursor.java
index e05dbb7..5956e67 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeCursor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeCursor.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.buffercache.IBufferCache;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public interface IBTreeCursor {
public void reset();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrame.java
index 8afe219..be68796 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrame.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
-import edu.uci.ics.hyracks.storage.am.btree.impls.SplitKey;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.impls.SplitKey;
public interface IBTreeFrame extends IFrame {
// TODO; what if records more than half-page size?
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameFactory.java
index e0fd99f..e9747d0 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameFactory.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IBTreeFrameFactory {
public IBTreeFrame getFrame(ISlotManager slotManager);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInterior.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInterior.java
index 677a2a9..f5af6d2 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInterior.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInterior.java
@@ -1,21 +1,7 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
-import edu.uci.ics.hyracks.storage.am.btree.impls.RangePredicate;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.impls.RangePredicate;
public interface IBTreeFrameInterior extends IBTreeFrame {
//public int getChildPageId(IFieldAccessor[] fields, MultiComparator cmp);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInteriorFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInteriorFactory.java
index 4296607..53df368 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInteriorFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameInteriorFactory.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IBTreeFrameInteriorFactory {
public IBTreeFrameInterior getFrame();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeaf.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeaf.java
index f66ce73..f7e2d1c 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeaf.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeaf.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IBTreeFrameLeaf extends IBTreeFrame {
public void setNextLeaf(int nextPage);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeafFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeafFactory.java
index fb15046..5a4e593 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeafFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameLeafFactory.java
@@ -1,19 +1,5 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-public interface IBTreeFrameLeafFactory {
- public IBTreeFrameLeaf getFrame();
+public interface IBTreeFrameLeafFactory {
+ public IBTreeFrameLeaf getFrame();
}
\ No newline at end of file
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMeta.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMeta.java
index f430d38..435aff8 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMeta.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMeta.java
@@ -1,20 +1,6 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public interface IBTreeFrameMeta {
public void initBuffer(int level);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMetaFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMetaFactory.java
index 27b61cd..a8ced77 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMetaFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeFrameMetaFactory.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IBTreeFrameMetaFactory {
public IBTreeFrameMeta getFrame();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeSlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeSlotManager.java
index 443ffc4..b7bea46 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeSlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IBTreeSlotManager.java
@@ -1,22 +1,8 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
// a slot consists of two fields:
// first field is 1 byte, it indicates the slot number of a prefix record
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IComparator.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IComparator.java
index b26f799..2577602 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IComparator.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IComparator.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IComparator {
public int compare(byte[] dataA, int recOffA, byte[] dataB, int recOffB);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessor.java
index 65d4802..2441965 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessor.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IFieldAccessor {
public int getLength(byte[] data, int offset); // skip to next field (equivalent to adding length of field to offset)
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessorFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessorFactory.java
index a5a4603..4088376 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessorFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFieldAccessorFactory.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface IFieldAccessorFactory {
public IFieldAccessor getKey();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrame.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrame.java
index 90142e4..e3a2291 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrame.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrame.java
@@ -1,23 +1,9 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
-import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.storage.buffercache.ICachedPage;
public interface IFrame {
public void setPage(ICachedPage page);
@@ -29,7 +15,7 @@
public void delete(byte[] data, MultiComparator cmp, boolean exactDelete) throws Exception;
public void compact(MultiComparator cmp);
- public void compress(MultiComparator cmp) throws Exception;
+ public boolean compress(MultiComparator cmp) throws Exception;
public void initBuffer(byte level);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrameCompressor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrameCompressor.java
index 88f3fae..c267643 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrameCompressor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IFrameCompressor.java
@@ -1,22 +1,8 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
-import edu.uci.ics.hyracks.storage.am.btree.frames.FieldPrefixNSMLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.frames.FieldPrefixNSMLeaf;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
public interface IFrameCompressor {
- public void compress(FieldPrefixNSMLeaf frame, MultiComparator cmp) throws Exception;
+ public boolean compress(FieldPrefixNSMLeaf frame, MultiComparator cmp) throws Exception;
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IPrefixSlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IPrefixSlotManager.java
index 7996f1a..d107995 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IPrefixSlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/IPrefixSlotManager.java
@@ -1,23 +1,9 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.frames.FieldPrefixNSMLeaf;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.frames.FieldPrefixNSMLeaf;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
// a slot consists of two fields:
// first field is 1 byte, it indicates the slot number of a prefix record
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISearchPredicate.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISearchPredicate.java
index b04bca1..80629f0 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISearchPredicate.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISearchPredicate.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface ISearchPredicate {
public boolean isForward();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManager.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManager.java
index 45aa5e1..f0cc594 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManager.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManager.java
@@ -1,22 +1,8 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
import java.nio.ByteBuffer;
-import edu.uci.ics.hyracks.storage.am.btree.impls.MultiComparator;
+import edu.uci.ics.asterix.indexing.btree.impls.MultiComparator;
public interface ISlotManager {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManagerFactory.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManagerFactory.java
index fc8b8b4..d738626 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManagerFactory.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/ISlotManagerFactory.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public interface ISlotManagerFactory {
public ISlotManager getSlotManager();
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/SpaceStatus.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/SpaceStatus.java
index 15496dd..a1ccb5f 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/SpaceStatus.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/interfaces/SpaceStatus.java
@@ -1,18 +1,4 @@
-/*
- * 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.btree.interfaces;
+package edu.uci.ics.asterix.indexing.btree.interfaces;
public enum SpaceStatus {
INSUFFICIENT_SPACE,