Search in sources :

Example 11 with IMetadataPageManager

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();
}
Also used : IBTreeInteriorFrame(org.apache.hyracks.storage.am.btree.api.IBTreeInteriorFrame) ArrayTupleReference(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) ArrayList(java.util.ArrayList) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) BTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory) IMetadataPageManager(org.apache.hyracks.storage.am.common.api.IMetadataPageManager) ITreeIndexFrameFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory) LinkedMetaDataPageManager(org.apache.hyracks.storage.am.common.freepage.LinkedMetaDataPageManager) ITreeIndexAccessor(org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) BTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory) IBTreeLeafFrame(org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame) IBufferCache(org.apache.hyracks.storage.common.buffercache.IBufferCache) Test(org.junit.Test) AbstractBTreeTest(org.apache.hyracks.storage.am.btree.util.AbstractBTreeTest)

Example 12 with IMetadataPageManager

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;
}
Also used : ArrayList(java.util.ArrayList) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) IMetadataPageManager(org.apache.hyracks.storage.am.common.api.IMetadataPageManager) ILSMComponentFilterReference(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentFilterReference)

Example 13 with IMetadataPageManager

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;
}
Also used : LSMBTreeDiskComponent(org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeDiskComponent) IMetadataPageManager(org.apache.hyracks.storage.am.common.api.IMetadataPageManager)

Example 14 with IMetadataPageManager

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;
}
Also used : LSMBTreeWithBuddyDiskComponent(org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTreeWithBuddyDiskComponent) IMetadataPageManager(org.apache.hyracks.storage.am.common.api.IMetadataPageManager)

Aggregations

IMetadataPageManager (org.apache.hyracks.storage.am.common.api.IMetadataPageManager)14 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)6 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)6 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)6 ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)6 ITreeIndexFrameFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory)6 LinkedMetaDataPageManager (org.apache.hyracks.storage.am.common.freepage.LinkedMetaDataPageManager)6 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 ArrayTupleReference (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference)5 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)5 BTreeNSMInteriorFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory)5 BTreeNSMLeafFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory)5 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)5 AbstractBTreeTest (org.apache.hyracks.storage.am.btree.util.AbstractBTreeTest)5 IBTreeInteriorFrame (org.apache.hyracks.storage.am.btree.api.IBTreeInteriorFrame)4 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)3 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)3 ITreeIndexMetadataFrameFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrameFactory)3