Search in sources :

Example 1 with VirtualFreePageManager

use of org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager in project asterixdb by apache.

the class InMemoryBTreeRunner method init.

protected void init(int pageSize, int numPages, ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories) throws HyracksDataException {
    bufferCache = new VirtualBufferCache(new HeapBufferAllocator(), pageSize, numPages);
    TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(typeTraits);
    ITreeIndexFrameFactory leafFrameFactory = new BTreeNSMLeafFrameFactory(tupleWriterFactory);
    ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
    IPageManager freePageManager = new VirtualFreePageManager(bufferCache);
    btree = new BTree(bufferCache, new TransientFileMapManager(), freePageManager, interiorFrameFactory, leafFrameFactory, cmpFactories, typeTraits.length, file);
}
Also used : BTreeNSMLeafFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory) IPageManager(org.apache.hyracks.storage.am.common.api.IPageManager) HeapBufferAllocator(org.apache.hyracks.storage.common.buffercache.HeapBufferAllocator) VirtualBufferCache(org.apache.hyracks.storage.am.lsm.common.impls.VirtualBufferCache) TypeAwareTupleWriterFactory(org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory) BTree(org.apache.hyracks.storage.am.btree.impls.BTree) BTreeNSMInteriorFrameFactory(org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory) ITreeIndexFrameFactory(org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory) VirtualFreePageManager(org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager) TransientFileMapManager(org.apache.hyracks.storage.common.file.TransientFileMapManager)

Example 2 with VirtualFreePageManager

use of org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager in project asterixdb by apache.

the class LSMInvertedIndexTestContext method create.

public static LSMInvertedIndexTestContext create(LSMInvertedIndexTestHarness harness, ISerializerDeserializer[] fieldSerdes, int tokenFieldCount, IBinaryTokenizerFactory tokenizerFactory, InvertedIndexType invIndexType, int[] invertedIndexFields, ITypeTraits[] filterTypeTraits, IBinaryComparatorFactory[] filterCmpFactories, int[] filterFields, int[] filterFieldsForNonBulkLoadOps, int[] invertedIndexFieldsForNonBulkLoadOps) throws HyracksDataException {
    ITypeTraits[] allTypeTraits = SerdeUtils.serdesToTypeTraits(fieldSerdes);
    IOManager ioManager = harness.getIOManager();
    IBinaryComparatorFactory[] allCmpFactories = SerdeUtils.serdesToComparatorFactories(fieldSerdes, fieldSerdes.length);
    // Set token type traits and comparators.
    ITypeTraits[] tokenTypeTraits = new ITypeTraits[tokenFieldCount];
    IBinaryComparatorFactory[] tokenCmpFactories = new IBinaryComparatorFactory[tokenFieldCount];
    for (int i = 0; i < tokenTypeTraits.length; i++) {
        tokenTypeTraits[i] = allTypeTraits[i];
        tokenCmpFactories[i] = allCmpFactories[i];
    }
    // Set inverted-list element type traits and comparators.
    int invListFieldCount = fieldSerdes.length - tokenFieldCount;
    ITypeTraits[] invListTypeTraits = new ITypeTraits[invListFieldCount];
    IBinaryComparatorFactory[] invListCmpFactories = new IBinaryComparatorFactory[invListFieldCount];
    for (int i = 0; i < invListTypeTraits.length; i++) {
        invListTypeTraits[i] = allTypeTraits[i + tokenFieldCount];
        invListCmpFactories[i] = allCmpFactories[i + tokenFieldCount];
    }
    // Create index and test context.
    IInvertedIndex invIndex;
    assert harness.getVirtualBufferCaches().size() > 0;
    switch(invIndexType) {
        case INMEMORY:
            {
                invIndex = InvertedIndexUtils.createInMemoryBTreeInvertedindex(harness.getVirtualBufferCaches().get(0), new VirtualFreePageManager(harness.getVirtualBufferCaches().get(0)), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, ioManager.resolveAbsolutePath(harness.getOnDiskDir()));
                break;
            }
        case PARTITIONED_INMEMORY:
            {
                invIndex = InvertedIndexUtils.createPartitionedInMemoryBTreeInvertedindex(harness.getVirtualBufferCaches().get(0), new VirtualFreePageManager(harness.getVirtualBufferCaches().get(0)), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, ioManager.resolveAbsolutePath(harness.getOnDiskDir()));
                break;
            }
        case ONDISK:
            {
                invIndex = InvertedIndexUtils.createOnDiskInvertedIndex(ioManager, harness.getDiskBufferCache(), harness.getDiskFileMapProvider(), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, harness.getInvListsFileRef(), harness.getMetadataPageManagerFactory());
                break;
            }
        case PARTITIONED_ONDISK:
            {
                invIndex = InvertedIndexUtils.createPartitionedOnDiskInvertedIndex(ioManager, harness.getDiskBufferCache(), harness.getDiskFileMapProvider(), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, harness.getInvListsFileRef(), harness.getMetadataPageManagerFactory());
                break;
            }
        case LSM:
            {
                invIndex = InvertedIndexUtils.createLSMInvertedIndex(ioManager, harness.getVirtualBufferCaches(), harness.getDiskFileMapProvider(), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, harness.getDiskBufferCache(), harness.getOnDiskDir(), harness.getBoomFilterFalsePositiveRate(), harness.getMergePolicy(), harness.getOperationTracker(), harness.getIOScheduler(), harness.getIOOperationCallback(), invertedIndexFields, filterTypeTraits, filterCmpFactories, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, true, harness.getMetadataPageManagerFactory());
                break;
            }
        case PARTITIONED_LSM:
            {
                invIndex = InvertedIndexUtils.createPartitionedLSMInvertedIndex(ioManager, harness.getVirtualBufferCaches(), harness.getDiskFileMapProvider(), invListTypeTraits, invListCmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, harness.getDiskBufferCache(), harness.getOnDiskDir(), harness.getBoomFilterFalsePositiveRate(), harness.getMergePolicy(), harness.getOperationTracker(), harness.getIOScheduler(), harness.getIOOperationCallback(), invertedIndexFields, filterTypeTraits, filterCmpFactories, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, true, harness.getMetadataPageManagerFactory());
                break;
            }
        default:
            {
                throw HyracksDataException.create(ErrorCode.UNKNOWN_INVERTED_INDEX_TYPE, invIndexType);
            }
    }
    InvertedIndexTokenizingTupleIterator indexTupleIter = null;
    switch(invIndexType) {
        case INMEMORY:
        case ONDISK:
        case LSM:
            {
                indexTupleIter = new InvertedIndexTokenizingTupleIterator(invIndex.getTokenTypeTraits().length, invIndex.getInvListTypeTraits().length, tokenizerFactory.createTokenizer());
                break;
            }
        case PARTITIONED_INMEMORY:
        case PARTITIONED_ONDISK:
        case PARTITIONED_LSM:
            {
                indexTupleIter = new PartitionedInvertedIndexTokenizingTupleIterator(invIndex.getTokenTypeTraits().length, invIndex.getInvListTypeTraits().length, tokenizerFactory.createTokenizer());
                break;
            }
        default:
            {
                throw HyracksDataException.create(ErrorCode.UNKNOWN_INVERTED_INDEX_TYPE, invIndexType);
            }
    }
    LSMInvertedIndexTestContext testCtx = new LSMInvertedIndexTestContext(fieldSerdes, invIndex, tokenizerFactory, invIndexType, indexTupleIter);
    return testCtx;
}
Also used : ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) IOManager(org.apache.hyracks.control.nc.io.IOManager) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) IInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedIndex) VirtualFreePageManager(org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager)

Example 3 with VirtualFreePageManager

use of org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager 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)

Aggregations

VirtualFreePageManager (org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager)3 VirtualBufferCache (org.apache.hyracks.storage.am.lsm.common.impls.VirtualBufferCache)2 HeapBufferAllocator (org.apache.hyracks.storage.common.buffercache.HeapBufferAllocator)2 File (java.io.File)1 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)1 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)1 FileReference (org.apache.hyracks.api.io.FileReference)1 IODeviceHandle (org.apache.hyracks.api.io.IODeviceHandle)1 IOManager (org.apache.hyracks.control.nc.io.IOManager)1 BTreeNSMInteriorFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory)1 BTreeNSMLeafFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory)1 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)1 IPageManager (org.apache.hyracks.storage.am.common.api.IPageManager)1 ITreeIndexFrameFactory (org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory)1 TypeAwareTupleWriterFactory (org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory)1 IInvertedIndex (org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedIndex)1 TransientFileMapManager (org.apache.hyracks.storage.common.file.TransientFileMapManager)1 Test (org.junit.Test)1