Search in sources :

Example 1 with ILSMMergePolicy

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

the class NoMergePolicyFactory method createMergePolicy.

@Override
public ILSMMergePolicy createMergePolicy(Map<String, String> configuration, INCServiceContext ctx) {
    ILSMMergePolicy policy = new NoMergePolicy();
    policy.configure(configuration);
    return policy;
}
Also used : ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)

Example 2 with ILSMMergePolicy

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

the class CorrelatedPrefixMergePolicyTest method mockMergePolicy.

private ILSMMergePolicy mockMergePolicy(IndexInfo... indexes) {
    Map<String, String> properties = new HashMap<>();
    properties.put(CorrelatedPrefixMergePolicyFactory.KEY_MAX_COMPONENT_COUNT, String.valueOf(MAX_COMPONENT_COUNT));
    properties.put(CorrelatedPrefixMergePolicyFactory.KEY_MAX_COMPONENT_SIZE, String.valueOf(MAX_COMPONENT_SIZE));
    Set<IndexInfo> indexInfos = new HashSet<>();
    for (IndexInfo info : indexes) {
        indexInfos.add(info);
    }
    DatasetInfo dsInfo = Mockito.mock(DatasetInfo.class);
    Mockito.when(dsInfo.getDatsetIndexInfos()).thenReturn(indexInfos);
    IDatasetLifecycleManager manager = Mockito.mock(IDatasetLifecycleManager.class);
    Mockito.when(manager.getDatasetInfo(DATASET_ID)).thenReturn(dsInfo);
    ILSMMergePolicy policy = new CorrelatedPrefixMergePolicy(manager, DATASET_ID);
    policy.configure(properties);
    return policy;
}
Also used : IDatasetLifecycleManager(org.apache.asterix.common.api.IDatasetLifecycleManager) HashMap(java.util.HashMap) DatasetInfo(org.apache.asterix.common.context.DatasetInfo) IndexInfo(org.apache.asterix.common.context.IndexInfo) ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy) HashSet(java.util.HashSet) CorrelatedPrefixMergePolicy(org.apache.asterix.common.context.CorrelatedPrefixMergePolicy)

Example 3 with ILSMMergePolicy

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

the class LSMInvertedIndexLocalResource method createInstance.

@Override
public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
    IIOManager ioManager = serviceCtx.getIoManager();
    FileReference file = ioManager.resolve(path);
    List<IVirtualBufferCache> virtualBufferCaches = vbcProvider.getVirtualBufferCaches(serviceCtx, file);
    IBufferCache bufferCache = storageManager.getBufferCache(serviceCtx);
    IFileMapProvider fileMapManager = storageManager.getFileMapProvider(serviceCtx);
    ILSMMergePolicy mergePolicy = mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx);
    ILSMIOOperationScheduler ioScheduler = ioSchedulerProvider.getIoScheduler(serviceCtx);
    if (isPartitioned) {
        return InvertedIndexUtils.createPartitionedLSMInvertedIndex(ioManager, virtualBufferCaches, fileMapManager, typeTraits, cmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, bufferCache, file.getAbsolutePath(), bloomFilterFalsePositiveRate, mergePolicy, opTrackerProvider.getOperationTracker(serviceCtx), ioScheduler, ioOpCallbackFactory.createIoOpCallback(), invertedIndexFields, filterTypeTraits, filterCmpFactories, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, durable, metadataPageManagerFactory);
    } else {
        return InvertedIndexUtils.createLSMInvertedIndex(ioManager, virtualBufferCaches, fileMapManager, typeTraits, cmpFactories, tokenTypeTraits, tokenCmpFactories, tokenizerFactory, bufferCache, file.getAbsolutePath(), bloomFilterFalsePositiveRate, mergePolicy, opTrackerProvider.getOperationTracker(serviceCtx), ioScheduler, ioOpCallbackFactory.createIoOpCallback(), invertedIndexFields, filterTypeTraits, filterCmpFactories, filterFields, filterFieldsForNonBulkLoadOps, invertedIndexFieldsForNonBulkLoadOps, durable, metadataPageManagerFactory);
    }
}
Also used : IFileMapProvider(org.apache.hyracks.storage.common.file.IFileMapProvider) ILSMIOOperationScheduler(org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler) IVirtualBufferCache(org.apache.hyracks.storage.am.lsm.common.api.IVirtualBufferCache) FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager) ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy) IBufferCache(org.apache.hyracks.storage.common.buffercache.IBufferCache)

Example 4 with ILSMMergePolicy

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

the class CorrelatedPrefixMergePolicyTest method testIDIntervals.

@Test
public void testIDIntervals() {
    try {
        List<ILSMDiskComponentId> componentIDs = Arrays.asList(new LSMDiskComponentId(40, 50), new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(20, 24), new LSMDiskComponentId(10, 19));
        List<ILSMDiskComponentId> resultPrimaryIDs = new ArrayList<>();
        IndexInfo primary = mockIndex(true, componentIDs, resultPrimaryIDs, 0);
        List<ILSMDiskComponentId> resultSecondaryIDs = new ArrayList<>();
        IndexInfo secondary = mockIndex(false, componentIDs, resultSecondaryIDs, 0);
        ILSMMergePolicy policy = mockMergePolicy(primary, secondary);
        policy.diskComponentAdded(secondary.getIndex(), false);
        Assert.assertTrue(resultPrimaryIDs.isEmpty());
        Assert.assertTrue(resultSecondaryIDs.isEmpty());
        policy.diskComponentAdded(primary.getIndex(), false);
        Assert.assertEquals(Arrays.asList(new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(20, 24), new LSMDiskComponentId(10, 19)), resultPrimaryIDs);
        Assert.assertEquals(Arrays.asList(new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(20, 24), new LSMDiskComponentId(10, 19)), resultSecondaryIDs);
    } catch (HyracksDataException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : LSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId) ILSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId) ILSMDiskComponentId(org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId) ArrayList(java.util.ArrayList) IndexInfo(org.apache.asterix.common.context.IndexInfo) ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Test(org.junit.Test)

Example 5 with ILSMMergePolicy

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

the class CorrelatedPrefixMergePolicyFactory method createMergePolicy.

@Override
public ILSMMergePolicy createMergePolicy(Map<String, String> configuration, INCServiceContext ctx) {
    IDatasetLifecycleManager dslcManager = ((INcApplicationContext) ctx.getApplicationContext()).getDatasetLifecycleManager();
    int datasetId = Integer.parseInt(configuration.get(KEY_DATASET_ID));
    ILSMMergePolicy policy = new CorrelatedPrefixMergePolicy(dslcManager, datasetId);
    policy.configure(configuration);
    return policy;
}
Also used : IDatasetLifecycleManager(org.apache.asterix.common.api.IDatasetLifecycleManager) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)

Aggregations

ILSMMergePolicy (org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)12 IndexInfo (org.apache.asterix.common.context.IndexInfo)7 ArrayList (java.util.ArrayList)6 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)6 ILSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId)6 LSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId)6 Test (org.junit.Test)6 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)1 CorrelatedPrefixMergePolicy (org.apache.asterix.common.context.CorrelatedPrefixMergePolicy)1 DatasetInfo (org.apache.asterix.common.context.DatasetInfo)1 FileReference (org.apache.hyracks.api.io.FileReference)1 IIOManager (org.apache.hyracks.api.io.IIOManager)1 ILSMIOOperationScheduler (org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationScheduler)1 IVirtualBufferCache (org.apache.hyracks.storage.am.lsm.common.api.IVirtualBufferCache)1 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)1 IFileMapProvider (org.apache.hyracks.storage.common.file.IFileMapProvider)1