use of org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy 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());
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy 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());
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy 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());
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy in project asterixdb by apache.
the class CorrelatedPrefixMergePolicyTest method testMultiPartition.
@Test
public void testMultiPartition() {
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);
List<ILSMDiskComponentId> resultSecondaryIDs1 = new ArrayList<>();
IndexInfo secondary1 = mockIndex(false, componentIDs, resultSecondaryIDs, 1);
ILSMMergePolicy policy = mockMergePolicy(primary, secondary, secondary1);
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);
Assert.assertTrue(resultSecondaryIDs1.isEmpty());
} catch (HyracksDataException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy 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());
}
}
Aggregations