use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class BTreeSearchCursorTest method nonUniqueFieldPrefixIndexTest.
@Test
public void nonUniqueFieldPrefixIndexTest() throws Exception {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("TESTING RANGE SEARCH CURSOR ON NONUNIQUE FIELD-PREFIX COMPRESSED INDEX");
}
IBufferCache bufferCache = harness.getBufferCache();
// declare keys
int keyFieldCount = 2;
IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
cmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
cmpFactories[1] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
ITreeIndexFrameFactory leafFrameFactory = new BTreeNSMLeafFrameFactory(tupleWriterFactory);
ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) leafFrameFactory.createFrame();
IBTreeInteriorFrame interiorFrame = (IBTreeInteriorFrame) interiorFrameFactory.createFrame();
IMetadataPageManager freePageManager = new LinkedMetaDataPageManager(bufferCache, metaFrameFactory);
BTree btree = new BTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory, leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
btree.create();
btree.activate();
ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
ITreeIndexAccessor indexAccessor = btree.createAccessor(TestOperationCallback.INSTANCE, TestOperationCallback.INSTANCE);
// generate keys
int numKeys = 50;
int maxKey = 10;
ArrayList<Integer> keys = new ArrayList<>();
for (int i = 0; i < numKeys; i++) {
int k = rnd.nextInt() % maxKey;
keys.add(k);
}
Collections.sort(keys);
// insert keys into btree
for (int i = 0; i < keys.size(); i++) {
TupleUtils.createIntegerTuple(tupleBuilder, tuple, keys.get(i), i);
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
try {
indexAccessor.insert(tuple);
} catch (Exception e) {
e.printStackTrace();
}
}
int minSearchKey = -100;
int maxSearchKey = 100;
// forward searches
Assert.assertTrue(performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, true, false));
Assert.assertTrue(performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, false, true, false));
Assert.assertTrue(performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, false, false));
Assert.assertTrue(performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, true, false));
btree.deactivate();
btree.destroy();
}
use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class LSMComponentFilterManager method readFilter.
@Override
public boolean readFilter(ILSMComponentFilter filter, ITreeIndex treeIndex) throws HyracksDataException {
IMetadataPageManager treeMetaManager = (IMetadataPageManager) treeIndex.getPageManager();
ILSMComponentFilterReference filterFrame = filterFrameFactory.createFrame();
treeMetaManager.get(treeMetaManager.createMetadataFrame(), FILTER_KEY, filterFrame);
// TODO: Filters never have one of min/max set and the other not
if (!filterFrame.isMinTupleSet() || !filterFrame.isMaxTupleSet()) {
return false;
}
List<ITupleReference> filterTuples = new ArrayList<>();
filterTuples.add(filterFrame.getMinTuple());
filterTuples.add(filterFrame.getMaxTuple());
updateFilter(filter, filterTuples);
return true;
}
use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class LSMBTreeIOOperationCallback method getComponentFileLSNOffset.
@Override
public long getComponentFileLSNOffset(ILSMDiskComponent diskComponent, String diskComponentFilePath) throws HyracksDataException {
if (diskComponentFilePath.endsWith(LSMBTreeFileManager.BTREE_STRING)) {
LSMBTreeDiskComponent btreeComponent = (LSMBTreeDiskComponent) diskComponent;
IMetadataPageManager metadataPageManager = (IMetadataPageManager) btreeComponent.getBTree().getPageManager();
return metadataPageManager.getFileOffset(metadataPageManager.createMetadataFrame(), LSN_KEY);
}
return INVALID;
}
use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class LSMBTreeWithBuddyIOOperationCallback method getComponentFileLSNOffset.
@Override
public long getComponentFileLSNOffset(ILSMDiskComponent diskComponent, String diskComponentFilePath) throws HyracksDataException {
if (diskComponentFilePath.endsWith(LSMBTreeWithBuddyFileManager.BTREE_STRING)) {
LSMBTreeWithBuddyDiskComponent btreeComponent = (LSMBTreeWithBuddyDiskComponent) diskComponent;
IMetadataPageManager metadataPageManager = (IMetadataPageManager) btreeComponent.getBTree().getPageManager();
return metadataPageManager.getFileOffset(metadataPageManager.createMetadataFrame(), LSN_KEY);
}
return INVALID;
}
Aggregations