Search in sources :

Example 1 with LSMComponentFilterReference

use of org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterReference in project asterixdb by apache.

the class LSMComponentFilterReferenceTest method test.

@Test
public void test() throws HyracksDataException {
    LSMComponentFilterReference filter = new LSMComponentFilterReference(new TypeAwareTupleWriter(new ITypeTraits[] { IntegerPointable.TYPE_TRAITS }));
    Assert.assertEquals(filter.getLength(), 0);
    Assert.assertFalse(filter.isMaxTupleSet() || filter.isMinTupleSet());
    filter.writeMaxTuple(TupleUtils.createIntegerTuple(false, Integer.MAX_VALUE));
    Assert.assertFalse(filter.isMinTupleSet());
    Assert.assertTrue(filter.isMaxTupleSet());
    Assert.assertTrue(filter.getLength() == 11);
    filter.writeMinTuple(TupleUtils.createIntegerTuple(false, Integer.MIN_VALUE));
    Assert.assertTrue(filter.isMinTupleSet() && filter.isMaxTupleSet());
    Assert.assertTrue(filter.getLength() == 20);
    byte[] serFilter = filter.getByteArray();
    LSMComponentFilterReference deserFilter = new LSMComponentFilterReference(new TypeAwareTupleWriter((new ITypeTraits[] { IntegerPointable.TYPE_TRAITS })));
    deserFilter.set(serFilter, 0, 20);
    Assert.assertTrue(deserFilter.isMaxTupleSet() && deserFilter.isMinTupleSet());
    Assert.assertEquals(TupleUtils.deserializeTuple(deserFilter.getMinTuple(), new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE })[0], Integer.MIN_VALUE);
    Assert.assertEquals(TupleUtils.deserializeTuple(deserFilter.getMaxTuple(), new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE })[0], Integer.MAX_VALUE);
}
Also used : ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) LSMComponentFilterReference(org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterReference) TypeAwareTupleWriter(org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriter) Test(org.junit.Test)

Aggregations

ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)1 TypeAwareTupleWriter (org.apache.hyracks.storage.am.common.tuples.TypeAwareTupleWriter)1 LSMComponentFilterReference (org.apache.hyracks.storage.am.lsm.common.frames.LSMComponentFilterReference)1 Test (org.junit.Test)1