Search in sources :

Example 46 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class VirtualFreePageManagerTest method test01.

@Test
public void test01() throws HyracksDataException {
    VirtualBufferCache bufferCache = new VirtualBufferCache(new HeapBufferAllocator(), 4096, 128);
    bufferCache.open();
    FileReference fileRef = new FileReference(new IODeviceHandle(new File("target"), "workspace"), "tempfile.tmp");
    bufferCache.createFile(fileRef);
    int fileId = bufferCache.getFileMapProvider().lookupFileId(fileRef);
    bufferCache.openFile(fileId);
    VirtualFreePageManager virtualFreePageManager = new VirtualFreePageManager(bufferCache);
    virtualFreePageManager.open(fileId);
    virtualFreePageManager.init(null, null);
    testInMemoryFreePageManager(virtualFreePageManager);
    // We expect exactly the same behavior after a reset().
    virtualFreePageManager.init(null, null);
    testInMemoryFreePageManager(virtualFreePageManager);
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) HeapBufferAllocator(org.apache.hyracks.storage.common.buffercache.HeapBufferAllocator) VirtualBufferCache(org.apache.hyracks.storage.am.lsm.common.impls.VirtualBufferCache) FileReference(org.apache.hyracks.api.io.FileReference) File(java.io.File) VirtualFreePageManager(org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager) Test(org.junit.Test)

Example 47 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class InvertedIndexUtils method createLSMInvertedIndex.

public static LSMInvertedIndex createLSMInvertedIndex(IIOManager ioManager, List<IVirtualBufferCache> virtualBufferCaches, IFileMapProvider diskFileMapProvider, ITypeTraits[] invListTypeTraits, IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits, IBinaryComparatorFactory[] tokenCmpFactories, IBinaryTokenizerFactory tokenizerFactory, IBufferCache diskBufferCache, String absoluteOnDiskDir, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallback ioOpCallback, int[] invertedIndexFields, ITypeTraits[] filterTypeTraits, IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields, int[] filterFieldsForNonBulkLoadOps, int[] invertedIndexFieldsForNonBulkLoadOps, boolean durable, IMetadataPageManagerFactory pageManagerFactory) throws HyracksDataException {
    BTreeFactory deletedKeysBTreeFactory = createDeletedKeysBTreeFactory(ioManager, diskFileMapProvider, invListTypeTraits, invListCmpFactories, diskBufferCache, pageManagerFactory);
    int[] bloomFilterKeyFields = new int[invListCmpFactories.length];
    for (int i = 0; i < invListCmpFactories.length; i++) {
        bloomFilterKeyFields[i] = i;
    }
    BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, diskFileMapProvider, bloomFilterKeyFields);
    FileReference onDiskDirFileRef = ioManager.resolveAbsolutePath(absoluteOnDiskDir);
    LSMInvertedIndexFileManager fileManager = new LSMInvertedIndexFileManager(ioManager, diskFileMapProvider, onDiskDirFileRef, deletedKeysBTreeFactory);
    IInvertedListBuilderFactory invListBuilderFactory = new FixedSizeElementInvertedListBuilderFactory(invListTypeTraits);
    OnDiskInvertedIndexFactory invIndexFactory = new OnDiskInvertedIndexFactory(ioManager, diskBufferCache, diskFileMapProvider, invListBuilderFactory, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, fileManager, pageManagerFactory);
    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);
    }
    return new LSMInvertedIndex(ioManager, virtualBufferCaches, invIndexFactory, deletedKeysBTreeFactory, bloomFilterFactory, filterHelper, filterFrameFactory, filterManager, bloomFilterFalsePositiveRate, fileManager, diskFileMapProvider, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, mergePolicy, opTracker, ioScheduler, ioOpCallback, invertedIndexFields, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, durable);
}
Also used : TypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory) PartitionedLSMInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.impls.PartitionedLSMInvertedIndex) LSMInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.impls.LSMInvertedIndex) LSMComponentFilterFrameFactory(org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterFrameFactory) LSMComponentFilterManager(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager) LSMInvertedIndexFileManager(org.apache.hyracks.storage.am.lsm.invertedindex.impls.LSMInvertedIndexFileManager) BTreeFactory(org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory) FixedSizeElementInvertedListBuilderFactory(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.FixedSizeElementInvertedListBuilderFactory) PartitionedOnDiskInvertedIndexFactory(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.PartitionedOnDiskInvertedIndexFactory) OnDiskInvertedIndexFactory(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.OnDiskInvertedIndexFactory) BloomFilterFactory(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory) FileReference(org.apache.hyracks.api.io.FileReference) ComponentFilterHelper(org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper) IInvertedListBuilderFactory(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilderFactory)

Example 48 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class InvertedIndexUtils method createOnDiskInvertedIndex.

public static OnDiskInvertedIndex createOnDiskInvertedIndex(IIOManager ioManager, IBufferCache bufferCache, IFileMapProvider fileMapProvider, ITypeTraits[] invListTypeTraits, IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits, IBinaryComparatorFactory[] tokenCmpFactories, FileReference invListsFile, IPageManagerFactory pageManagerFactory) throws HyracksDataException {
    IInvertedListBuilder builder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
    FileReference btreeFile = getBTreeFile(ioManager, invListsFile);
    return new OnDiskInvertedIndex(bufferCache, fileMapProvider, builder, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, btreeFile, invListsFile, pageManagerFactory);
}
Also used : OnDiskInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.OnDiskInvertedIndex) PartitionedOnDiskInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.PartitionedOnDiskInvertedIndex) IInvertedListBuilder(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilder) FixedSizeElementInvertedListBuilder(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.FixedSizeElementInvertedListBuilder) FileReference(org.apache.hyracks.api.io.FileReference)

Example 49 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class InvertedIndexUtils method createPartitionedOnDiskInvertedIndex.

public static PartitionedOnDiskInvertedIndex createPartitionedOnDiskInvertedIndex(IIOManager ioManager, IBufferCache bufferCache, IFileMapProvider fileMapProvider, ITypeTraits[] invListTypeTraits, IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits, IBinaryComparatorFactory[] tokenCmpFactories, FileReference invListsFile, IPageManagerFactory pageManagerFactory) throws HyracksDataException {
    IInvertedListBuilder builder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
    FileReference btreeFile = getBTreeFile(ioManager, invListsFile);
    return new PartitionedOnDiskInvertedIndex(bufferCache, fileMapProvider, builder, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, btreeFile, invListsFile, pageManagerFactory);
}
Also used : IInvertedListBuilder(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilder) PartitionedOnDiskInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.PartitionedOnDiskInvertedIndex) FixedSizeElementInvertedListBuilder(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.FixedSizeElementInvertedListBuilder) FileReference(org.apache.hyracks.api.io.FileReference)

Example 50 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class InvertedIndexUtils method createPartitionedLSMInvertedIndex.

public static PartitionedLSMInvertedIndex createPartitionedLSMInvertedIndex(IIOManager ioManager, List<IVirtualBufferCache> virtualBufferCaches, IFileMapProvider diskFileMapProvider, ITypeTraits[] invListTypeTraits, IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits, IBinaryComparatorFactory[] tokenCmpFactories, IBinaryTokenizerFactory tokenizerFactory, IBufferCache diskBufferCache, String absoluteOnDiskDir, double bloomFilterFalsePositiveRate, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOOperationScheduler ioScheduler, ILSMIOOperationCallback ioOpCallback, int[] invertedIndexFields, ITypeTraits[] filterTypeTraits, IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields, int[] filterFieldsForNonBulkLoadOps, int[] invertedIndexFieldsForNonBulkLoadOps, boolean durable, IPageManagerFactory pageManagerFactory) throws HyracksDataException {
    BTreeFactory deletedKeysBTreeFactory = createDeletedKeysBTreeFactory(ioManager, diskFileMapProvider, invListTypeTraits, invListCmpFactories, diskBufferCache, pageManagerFactory);
    int[] bloomFilterKeyFields = new int[invListCmpFactories.length];
    for (int i = 0; i < invListCmpFactories.length; i++) {
        bloomFilterKeyFields[i] = i;
    }
    BloomFilterFactory bloomFilterFactory = new BloomFilterFactory(diskBufferCache, diskFileMapProvider, bloomFilterKeyFields);
    FileReference onDiskDirFileRef = ioManager.resolveAbsolutePath(absoluteOnDiskDir);
    LSMInvertedIndexFileManager fileManager = new LSMInvertedIndexFileManager(ioManager, diskFileMapProvider, onDiskDirFileRef, deletedKeysBTreeFactory);
    IInvertedListBuilderFactory invListBuilderFactory = new FixedSizeElementInvertedListBuilderFactory(invListTypeTraits);
    PartitionedOnDiskInvertedIndexFactory invIndexFactory = new PartitionedOnDiskInvertedIndexFactory(ioManager, diskBufferCache, diskFileMapProvider, invListBuilderFactory, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, fileManager, pageManagerFactory);
    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);
    }
    return new PartitionedLSMInvertedIndex(ioManager, virtualBufferCaches, invIndexFactory, deletedKeysBTreeFactory, bloomFilterFactory, filterHelper, filterFrameFactory, filterManager, bloomFilterFalsePositiveRate, fileManager, diskFileMapProvider, invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, mergePolicy, opTracker, ioScheduler, ioOpCallback, invertedIndexFields, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, durable);
}
Also used : TypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory) LSMComponentFilterFrameFactory(org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterFrameFactory) LSMComponentFilterManager(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFilterManager) PartitionedLSMInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.impls.PartitionedLSMInvertedIndex) LSMInvertedIndexFileManager(org.apache.hyracks.storage.am.lsm.invertedindex.impls.LSMInvertedIndexFileManager) BTreeFactory(org.apache.hyracks.storage.am.lsm.common.impls.BTreeFactory) FixedSizeElementInvertedListBuilderFactory(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.FixedSizeElementInvertedListBuilderFactory) PartitionedOnDiskInvertedIndexFactory(org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.PartitionedOnDiskInvertedIndexFactory) BloomFilterFactory(org.apache.hyracks.storage.am.bloomfilter.impls.BloomFilterFactory) FileReference(org.apache.hyracks.api.io.FileReference) ComponentFilterHelper(org.apache.hyracks.storage.am.lsm.common.impls.ComponentFilterHelper) IInvertedListBuilderFactory(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilderFactory)

Aggregations

FileReference (org.apache.hyracks.api.io.FileReference)52 IIOManager (org.apache.hyracks.api.io.IIOManager)16 File (java.io.File)10 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)9 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)7 IOException (java.io.IOException)6 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)6 IFileMapProvider (org.apache.hyracks.storage.common.file.IFileMapProvider)6 IInvertedListBuilder (org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilder)5 Test (org.junit.Test)5 FilenameFilter (java.io.FilenameFilter)4 IVirtualBufferCache (org.apache.hyracks.storage.am.lsm.common.api.IVirtualBufferCache)4 ArrayList (java.util.ArrayList)3 IODeviceHandle (org.apache.hyracks.api.io.IODeviceHandle)3 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)3 LocalResource (org.apache.hyracks.storage.common.LocalResource)3 FileOutputStream (java.io.FileOutputStream)2 HashMap (java.util.HashMap)2 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)2 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)2