use of org.apache.flink.types.ShortValue in project flink by apache.
the class ShortValueComparator method compareToReference.
@Override
public int compareToReference(TypeComparator<ShortValue> referencedComparator) {
ShortValue otherRef = ((ShortValueComparator) referencedComparator).reference;
int comp = otherRef.compareTo(reference);
return ascendingComparison ? comp : -comp;
}
use of org.apache.flink.types.ShortValue in project flink by apache.
the class BoxedWrapperRowData method setShort.
@Override
public void setShort(int pos, short value) {
ShortValue wrap;
if ((wrap = (ShortValue) fields[pos]) == null) {
wrap = new ShortValue();
fields[pos] = wrap;
}
wrap.setValue(value);
}
use of org.apache.flink.types.ShortValue in project flink by apache.
the class ShortValueArrayComparatorTest method getSortedTestData.
@Override
protected ShortValueArray[] getSortedTestData() {
ShortValueArray lva0 = new ShortValueArray();
ShortValueArray lva1 = new ShortValueArray();
lva1.add(new ShortValue((short) 5));
ShortValueArray lva2 = new ShortValueArray();
lva2.add(new ShortValue((short) 5));
lva2.add(new ShortValue((short) 10));
return new ShortValueArray[] { lva0, lva1 };
}
use of org.apache.flink.types.ShortValue in project flink by apache.
the class ShortValueArrayTest method testBoundedArray.
@Test
public void testBoundedArray() {
int count = ShortValueArray.DEFAULT_CAPACITY_IN_BYTES / ShortValueArray.ELEMENT_LENGTH_IN_BYTES;
ValueArray<ShortValue> lva = new ShortValueArray(ShortValueArray.DEFAULT_CAPACITY_IN_BYTES);
// fill the array
for (int i = 0; i < count; i++) {
assertFalse(lva.isFull());
assertEquals(i, lva.size());
assertTrue(lva.add(new ShortValue((short) i)));
assertEquals(i + 1, lva.size());
}
// array is now full
assertTrue(lva.isFull());
assertEquals(count, lva.size());
// verify the array values
int idx = 0;
for (ShortValue lv : lva) {
assertEquals((short) idx++, lv.getValue());
}
// add element past end of array
assertFalse(lva.add(new ShortValue((short) count)));
assertFalse(lva.addAll(lva));
// test copy
assertEquals(lva, lva.copy());
// test copyTo
ShortValueArray lvaTo = new ShortValueArray();
lva.copyTo(lvaTo);
assertEquals(lva, lvaTo);
// test clear
lva.clear();
assertEquals(0, lva.size());
}
use of org.apache.flink.types.ShortValue in project flink by apache.
the class GraphKeyTypeTransformTest method testToShortValue.
// ShortValue
@Test
public void testToShortValue() throws Exception {
TranslateFunction<LongValue, ShortValue> translator = new LongValueToUnsignedShortValue();
Assert.assertEquals(new ShortValue((short) 0), translator.translate(new LongValue(0L), shortValue));
Assert.assertEquals(new ShortValue(Short.MIN_VALUE), translator.translate(new LongValue((long) Short.MAX_VALUE + 1), shortValue));
Assert.assertEquals(new ShortValue((short) -1), translator.translate(new LongValue(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1), shortValue));
}
Aggregations