Search in sources :

Example 1 with IMetadataPageManager

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

Example 2 with IMetadataPageManager

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();
}
Also used : LongPointable(org.apache.hyracks.data.std.primitive.LongPointable) IMetadataPageManager(org.apache.hyracks.storage.am.common.api.IMetadataPageManager)

Example 3 with IMetadataPageManager

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

Example 4 with IMetadataPageManager

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

Example 5 with IMetadataPageManager

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();
}
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)

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