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);
}
Aggregations