use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class LSMComponentFilterManager method writeFilter.
@Override
public void writeFilter(ILSMComponentFilter filter, ITreeIndex treeIndex) throws HyracksDataException {
IMetadataPageManager treeMetaManager = (IMetadataPageManager) treeIndex.getPageManager();
ILSMComponentFilterReference filterFrame = filterFrameFactory.createFrame();
try {
if (filter.getMinTuple() != null) {
filterFrame.writeMinTuple(filter.getMinTuple());
}
if (filter.getMaxTuple() != null) {
filterFrame.writeMaxTuple(filter.getMaxTuple());
}
} finally {
treeMetaManager.put(treeMetaManager.createMetadataFrame(), FILTER_KEY, filterFrame);
}
}
use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class AbstractLSMIOOperationCallback method getTreeIndexLSN.
public static long getTreeIndexLSN(DiskComponentMetadata md) throws HyracksDataException {
LongPointable pointable = new LongPointable();
IMetadataPageManager metadataPageManager = md.getMetadataPageManager();
metadataPageManager.get(metadataPageManager.createMetadataFrame(), LSN_KEY, pointable);
return pointable.getLength() == 0 ? INVALID : pointable.longValue();
}
use of org.apache.hyracks.storage.am.common.api.IMetadataPageManager in project asterixdb by apache.
the class LSMInvertedIndexIOOperationCallback method getComponentFileLSNOffset.
@Override
public long getComponentFileLSNOffset(ILSMDiskComponent diskComponent, String diskComponentFilePath) throws HyracksDataException {
if (diskComponentFilePath.endsWith(LSMInvertedIndexFileManager.DELETED_KEYS_BTREE_SUFFIX)) {
LSMInvertedIndexDiskComponent invIndexComponent = (LSMInvertedIndexDiskComponent) diskComponent;
IMetadataPageManager metadataPageManager = (IMetadataPageManager) invIndexComponent.getDeletedKeysBTree().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 LSMRTreeIOOperationCallback method getComponentFileLSNOffset.
@Override
public long getComponentFileLSNOffset(ILSMDiskComponent diskComponent, String diskComponentFilePath) throws HyracksDataException {
if (diskComponentFilePath.endsWith(LSMRTreeFileManager.RTREE_STRING)) {
LSMRTreeDiskComponent rtreeComponent = (LSMRTreeDiskComponent) diskComponent;
IMetadataPageManager metadataPageManager = (IMetadataPageManager) rtreeComponent.getRTree().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 BTreeSearchCursorTest method nonUniqueIndexTest.
@Test
public void nonUniqueIndexTest() throws Exception {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("TESTING RANGE SEARCH CURSOR ON NONUNIQUE 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();
}
Aggregations