Search in sources :

Example 1 with IndexInfo

use of org.apache.asterix.common.context.IndexInfo 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 2 with IndexInfo

use of org.apache.asterix.common.context.IndexInfo 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 3 with IndexInfo

use of org.apache.asterix.common.context.IndexInfo in project asterixdb by apache.

the class CorrelatedPrefixMergePolicyTest method testBasic.

@Test
public void testBasic() {
    try {
        List<ILSMDiskComponentId> componentIDs = Arrays.asList(new LSMDiskComponentId(5, 5), new LSMDiskComponentId(4, 4), new LSMDiskComponentId(3, 3), new LSMDiskComponentId(2, 2), new LSMDiskComponentId(1, 1));
        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(4, 4), new LSMDiskComponentId(3, 3), new LSMDiskComponentId(2, 2), new LSMDiskComponentId(1, 1)), resultPrimaryIDs);
        Assert.assertEquals(Arrays.asList(new LSMDiskComponentId(4, 4), new LSMDiskComponentId(3, 3), new LSMDiskComponentId(2, 2), new LSMDiskComponentId(1, 1)), 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 4 with IndexInfo

use of org.apache.asterix.common.context.IndexInfo in project asterixdb by apache.

the class CorrelatedPrefixMergePolicyTest method testPrimaryNotFound.

@Test
public void testPrimaryNotFound() {
    try {
        List<ILSMDiskComponentId> primaryComponentIDs = Arrays.asList(new LSMDiskComponentId(40, 50), new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(ILSMDiskComponentId.NOT_FOUND, ILSMDiskComponentId.NOT_FOUND), new LSMDiskComponentId(10, 19));
        List<ILSMDiskComponentId> resultPrimaryIDs = new ArrayList<>();
        IndexInfo primary = mockIndex(true, primaryComponentIDs, resultPrimaryIDs, 0);
        List<ILSMDiskComponentId> secondaryComponentIDs = Arrays.asList(new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(20, 24));
        List<ILSMDiskComponentId> resultSecondaryIDs = new ArrayList<>();
        IndexInfo secondary = mockIndex(false, secondaryComponentIDs, 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(40, 50), new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29)), resultPrimaryIDs);
        Assert.assertEquals(Arrays.asList(new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29)), 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 IndexInfo

use of org.apache.asterix.common.context.IndexInfo in project asterixdb by apache.

the class CorrelatedPrefixMergePolicyTest method testSecondaryMissing.

@Test
public void testSecondaryMissing() {
    try {
        List<ILSMDiskComponentId> primaryComponentIDs = 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, primaryComponentIDs, resultPrimaryIDs, 0);
        List<ILSMDiskComponentId> secondaryComponentIDs = Arrays.asList(new LSMDiskComponentId(30, 35), new LSMDiskComponentId(25, 29), new LSMDiskComponentId(20, 24));
        List<ILSMDiskComponentId> resultSecondaryIDs = new ArrayList<>();
        IndexInfo secondary = mockIndex(false, secondaryComponentIDs, 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)), 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)

Aggregations

IndexInfo (org.apache.asterix.common.context.IndexInfo)8 ILSMMergePolicy (org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)8 ArrayList (java.util.ArrayList)7 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)7 ILSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId)7 LSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)2 CorrelatedPrefixMergePolicy (org.apache.asterix.common.context.CorrelatedPrefixMergePolicy)2 DatasetInfo (org.apache.asterix.common.context.DatasetInfo)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TestCase (junit.framework.TestCase)1 CorrelatedPrefixMergePolicyFactory (org.apache.asterix.common.context.CorrelatedPrefixMergePolicyFactory)1 ComponentState (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent.ComponentState)1 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)1