Search in sources :

Example 6 with ILSMIndexFileManager

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager in project asterixdb by apache.

the class LSMRTreeUtils method createExternalRTree.

public static ExternalRTree createExternalRTree(IIOManager ioManager, FileReference file, IBufferCache diskBufferCache, IFileMapProvider diskFileMapProvider, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] rtreeCmpFactories, IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories, RTreePolicyType rtreePolicyType, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallback ioOpCallback, ILinearizeComparatorFactory linearizeCmpFactory, int[] buddyBTreeFields, boolean durable, boolean isPointMBR, IMetadataPageManagerFactory freePageManagerFactory) throws HyracksDataException {
    int keyFieldCount = rtreeCmpFactories.length;
    int valueFieldCount = typeTraits.length - keyFieldCount;
    ITypeTraits[] btreeTypeTraits = new ITypeTraits[valueFieldCount];
    for (int i = 0; i < buddyBTreeFields.length; i++) {
        btreeTypeTraits[i] = typeTraits[buddyBTreeFields[i]];
    }
    ITreeIndexTupleWriterFactory rtreeInteriorFrameTupleWriterFactory = new LSMTypeAwareTupleWriterFactory(typeTraits, false);
    ITreeIndexTupleWriterFactory rtreeLeafFrameTupleWriterFactory = null;
    if (isPointMBR) {
        rtreeLeafFrameTupleWriterFactory = new LSMRTreeTupleWriterFactoryForPointMBR(typeTraits, keyFieldCount, valueFieldCount, false, false);
    } else {
        rtreeLeafFrameTupleWriterFactory = rtreeInteriorFrameTupleWriterFactory;
    }
    ITreeIndexTupleWriterFactory btreeTupleWriterFactory = new LSMTypeAwareTupleWriterFactory(btreeTypeTraits, true);
    ITreeIndexFrameFactory rtreeInteriorFrameFactory = new RTreeNSMInteriorFrameFactory(rtreeInteriorFrameTupleWriterFactory, valueProviderFactories, rtreePolicyType, isPointMBR);
    ITreeIndexFrameFactory rtreeLeafFrameFactory = new RTreeNSMLeafFrameFactory(rtreeLeafFrameTupleWriterFactory, valueProviderFactories, rtreePolicyType, isPointMBR);
    ITreeIndexFrameFactory btreeInteriorFrameFactory = new BTreeNSMInteriorFrameFactory(btreeTupleWriterFactory);
    ITreeIndexFrameFactory btreeLeafFrameFactory = new BTreeNSMLeafFrameFactory(btreeTupleWriterFactory);
    TreeIndexFactory<RTree> diskRTreeFactory = new RTreeFactory(ioManager, diskBufferCache, diskFileMapProvider, freePageManagerFactory, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, typeTraits.length, isPointMBR);
    TreeIndexFactory<BTree> diskBTreeFactory = new BTreeFactory(ioManager, diskBufferCache, diskFileMapProvider, freePageManagerFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, btreeTypeTraits.length);
    int[] comparatorFields = { 0 };
    IBinaryComparatorFactory[] linearizerArray = { linearizeCmpFactory };
    int[] bloomFilterKeyFields = new int[btreeCmpFactories.length];
    for (int i = 0; i < btreeCmpFactories.length; i++) {
        bloomFilterKeyFields[i] = i;
    }
    BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, diskFileMapProvider, bloomFilterKeyFields);
    ILSMIndexFileManager fileNameManager = new LSMRTreeFileManager(ioManager, diskFileMapProvider, file, diskRTreeFactory, diskBTreeFactory);
    ExternalRTree lsmTree = new ExternalRTree(ioManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, fileNameManager, diskRTreeFactory, diskBTreeFactory, bloomFilterFactory, bloomFilterFalsePositiveRate, diskFileMapProvider, typeTraits.length, rtreeCmpFactories, btreeCmpFactories, linearizeCmpFactory, comparatorFields, linearizerArray, mergePolicy, opTracker, ioScheduler, ioOpCallback, buddyBTreeFields, durable, isPointMBR);
    return lsmTree;
}
Also used : ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) ILSMIndexFileManager(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager) ITreeIndexTupleWriterFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexTupleWriterFactory) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) RTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.rtree.frames.RTreeNSMInteriorFrameFactory) BTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory) ITreeIndexFrameFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory) BTreeFactory(org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory) BTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory) LSMTypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.lsm.rtree.tuples.LSMTypeAwareTupleWriterFactory) LSMRTreeTupleWriterFactoryForPointMBR(org.apache.hyracks.storage.am.lsm.rtree.tuples.LSMRTreeTupleWriterFactoryForPointMBR) RTreeFactory(org.apache.hyracks.storage.am.lsm.rtree.impls.RTreeFactory) LSMRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTree) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree) ExternalRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree) LSMRTreeFileManager(org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTreeFileManager) ExternalRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree) BloomFilterFactory(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory) RTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.rtree.frames.RTreeNSMLeafFrameFactory)

Example 7 with ILSMIndexFileManager

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager in project asterixdb by apache.

the class LSMRTreeUtils method createLSMTree.

public static LSMRTree createLSMTree(IIOManager ioManager, List<IVirtualBufferCache> virtualBufferCaches, FileReference file, IBufferCache diskBufferCache, IFileMapProvider diskFileMapProvider, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] rtreeCmpFactories, IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories, RTreePolicyType rtreePolicyType, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallback ioOpCallback, ILinearizeComparatorFactory linearizeCmpFactory, int[] rtreeFields, int[] buddyBTreeFields, ITypeTraits[] filterTypeTraits, IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields, boolean durable, boolean isPointMBR, IMetadataPageManagerFactory freePageManagerFactory) throws HyracksDataException {
    int valueFieldCount = buddyBTreeFields.length;
    int keyFieldCount = typeTraits.length - valueFieldCount;
    ITypeTraits[] btreeTypeTraits = new ITypeTraits[valueFieldCount];
    for (int i = 0; i < valueFieldCount; i++) {
        btreeTypeTraits[i] = typeTraits[buddyBTreeFields[i]];
    }
    ITreeIndexTupleWriterFactory rtreeInteriorFrameTupleWriterFactory = new LSMTypeAwareTupleWriterFactory(typeTraits, false);
    ITreeIndexTupleWriterFactory rtreeLeafFrameTupleWriterFactory = null;
    if (isPointMBR) {
        rtreeLeafFrameTupleWriterFactory = new LSMRTreeTupleWriterFactoryForPointMBR(typeTraits, keyFieldCount, valueFieldCount, false, false);
    } else {
        rtreeLeafFrameTupleWriterFactory = rtreeInteriorFrameTupleWriterFactory;
    }
    ITreeIndexTupleWriterFactory btreeTupleWriterFactory = new LSMTypeAwareTupleWriterFactory(btreeTypeTraits, true);
    ITreeIndexFrameFactory rtreeInteriorFrameFactory = new RTreeNSMInteriorFrameFactory(rtreeInteriorFrameTupleWriterFactory, valueProviderFactories, rtreePolicyType, isPointMBR);
    ITreeIndexFrameFactory rtreeLeafFrameFactory = new RTreeNSMLeafFrameFactory(rtreeLeafFrameTupleWriterFactory, valueProviderFactories, rtreePolicyType, isPointMBR);
    ITreeIndexFrameFactory btreeInteriorFrameFactory = new BTreeNSMInteriorFrameFactory(btreeTupleWriterFactory);
    ITreeIndexFrameFactory btreeLeafFrameFactory = new BTreeNSMLeafFrameFactory(btreeTupleWriterFactory);
    TreeIndexFactory<RTree> diskRTreeFactory = new RTreeFactory(ioManager, diskBufferCache, diskFileMapProvider, freePageManagerFactory, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, typeTraits.length, isPointMBR);
    TreeIndexFactory<BTree> diskBTreeFactory = new BTreeFactory(ioManager, diskBufferCache, diskFileMapProvider, freePageManagerFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, btreeTypeTraits.length);
    int[] comparatorFields = { 0 };
    IBinaryComparatorFactory[] linearizerArray = { linearizeCmpFactory };
    int[] bloomFilterKeyFields = new int[btreeCmpFactories.length];
    for (int i = 0; i < btreeCmpFactories.length; i++) {
        bloomFilterKeyFields[i] = i;
    }
    BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, diskFileMapProvider, bloomFilterKeyFields);
    ComponentFilterHelper filterHelper = null;
    LSMComponentFilterFrameFactory filterFrameFactory = null;
    LSMComponentFilterManager filterManager = null;
    if (filterCmpFactories != null) {
        TypeAwareTupleWriterFactory filterTupleWriterFactory = new TypeAwareTupleWriterFactory(filterTypeTraits);
        filterHelper = new ComponentFilterHelper(filterTupleWriterFactory, filterCmpFactories);
        filterFrameFactory = new LSMComponentFilterFrameFactory(filterTupleWriterFactory);
        filterManager = new LSMComponentFilterManager(filterFrameFactory);
    }
    ILSMIndexFileManager fileNameManager = new LSMRTreeFileManager(ioManager, diskFileMapProvider, file, diskRTreeFactory, diskBTreeFactory);
    return new LSMRTree(ioManager, virtualBufferCaches, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, fileNameManager, diskRTreeFactory, diskBTreeFactory, bloomFilterFactory, filterHelper, filterFrameFactory, filterManager, bloomFilterFalsePositiveRate, diskFileMapProvider, typeTraits.length, rtreeCmpFactories, btreeCmpFactories, linearizeCmpFactory, comparatorFields, linearizerArray, mergePolicy, opTracker, ioScheduler, ioOpCallback, rtreeFields, buddyBTreeFields, filterFields, durable, isPointMBR);
}
Also used : ILSMIndexFileManager(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) LSMComponentFilterFrameFactory(org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterFrameFactory) LSMComponentFilterManager(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager) BTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory) ITreeIndexFrameFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory) BTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory) LSMTypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.lsm.rtree.tuples.LSMTypeAwareTupleWriterFactory) LSMRTreeTupleWriterFactoryForPointMBR(org.apache.hyracks.storage.am.lsm.rtree.tuples.LSMRTreeTupleWriterFactoryForPointMBR) LSMRTreeFileManager(org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTreeFileManager) RTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.rtree.frames.RTreeNSMLeafFrameFactory) ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) LSMRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTree) LSMTypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.lsm.rtree.tuples.LSMTypeAwareTupleWriterFactory) TypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory) ITreeIndexTupleWriterFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexTupleWriterFactory) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) RTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.rtree.frames.RTreeNSMInteriorFrameFactory) BTreeFactory(org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory) RTreeFactory(org.apache.hyracks.storage.am.lsm.rtree.impls.RTreeFactory) LSMRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTree) RTree(org.apache.hyracks.storage.am.rtree.impls.RTree) ExternalRTree(org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree) BloomFilterFactory(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory) ComponentFilterHelper(org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper)

Example 8 with ILSMIndexFileManager

use of org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager in project asterixdb by apache.

the class LSMIndexFileManagerTest method sortOrderTest.

public void sortOrderTest(boolean testFlushFileName) throws InterruptedException, HyracksDataException {
    ILSMIndexFileManager fileManager = new TestLsmIndexFileManager(ioManager, fileMapProvider, file);
    LinkedList<String> fileNames = new LinkedList<>();
    int numFileNames = 100;
    long sleepTime = 5;
    for (int i = 0; i < numFileNames; i++) {
        String flushFileName = fileManager.getRelFlushFileReference().getInsertIndexFileReference().getFile().getName();
        if (testFlushFileName) {
            fileNames.addFirst(flushFileName);
        }
        Thread.sleep(sleepTime);
        if (!testFlushFileName) {
            String secondFlushFileName = fileManager.getRelFlushFileReference().getInsertIndexFileReference().getFile().getName();
            String mergeFileName = getMergeFileName(fileManager, flushFileName, secondFlushFileName);
            fileNames.addFirst(mergeFileName);
            Thread.sleep(sleepTime);
        }
    }
    List<String> sortedFileNames = new ArrayList<>();
    sortedFileNames.addAll(fileNames);
    // Make sure the comparator sorts in the correct order (i.e., the
    // reverse insertion order in this case).
    Comparator<String> cmp = fileManager.getFileNameComparator();
    Collections.sort(sortedFileNames, cmp);
    for (int i = 0; i < numFileNames; i++) {
        assertEquals(fileNames.get(i), sortedFileNames.get(i));
    }
}
Also used : ILSMIndexFileManager(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager) ArrayList(java.util.ArrayList) TestLsmIndexFileManager(org.apache.hyracks.storage.am.lsm.common.component.TestLsmIndexFileManager) LinkedList(java.util.LinkedList)

Aggregations

ILSMIndexFileManager (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexFileManager)8 BTreeNSMInteriorFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory)6 BTreeNSMLeafFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory)6 ITreeIndexFrameFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory)6 BloomFilterFactory (org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory)5 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)5 BTreeFactory (org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory)5 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)4 TypeAwareTupleWriterFactory (org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory)4 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)3 ITreeIndexTupleWriterFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexTupleWriterFactory)3 ExternalBTree (org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree)3 LSMBTree (org.apache.hyracks.storage.am.lsm.btree.impls.LSMBTree)3 LSMBTreeCopyTupleWriterFactory (org.apache.hyracks.storage.am.lsm.btree.tuples.LSMBTreeCopyTupleWriterFactory)3 LSMBTreeTupleWriterFactory (org.apache.hyracks.storage.am.lsm.btree.tuples.LSMBTreeTupleWriterFactory)3 LSMComponentFilterFrameFactory (org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterFrameFactory)3 ComponentFilterHelper (org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper)3 LSMComponentFilterManager (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager)3 ExternalRTree (org.apache.hyracks.storage.am.lsm.rtree.impls.ExternalRTree)3 LSMRTree (org.apache.hyracks.storage.am.lsm.rtree.impls.LSMRTree)3