Search in sources :

Example 6 with LSMDiskComponentId

use of org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId in project asterixdb by apache.

the class CorrelatedPrefixMergePolicyTest method testSecondaryNotFound.

@Test
public void testSecondaryNotFound() {
    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(ILSMDiskComponentId.NOT_FOUND, ILSMDiskComponentId.NOT_FOUND), 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(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)

Example 7 with LSMDiskComponentId

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

Aggregations

ILSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId)7 LSMDiskComponentId (org.apache.hyracks.storage.am.lsm.common.impls.LSMDiskComponentId)7 ArrayList (java.util.ArrayList)6 IndexInfo (org.apache.asterix.common.context.IndexInfo)6 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)6 ILSMMergePolicy (org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)6 Test (org.junit.Test)6 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)1 ILSMDiskComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponent)1