org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedFloat Java Examples

The following examples show how to use org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedFloat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Flink-CEPplus   Author: ljygz   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToFloat() throws Exception {
	TranslateFunction<LongValue, Float> translator = new LongValueToUnsignedFloat();

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(0)),
		translator.translate(new LongValue(0L), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(Integer.MIN_VALUE)),
		translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(-1)),
		translator.translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1), null));
}
 
Example #2
Source Project: Flink-CEPplus   Author: ljygz   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testFromFloat() throws Exception {
	TranslateFunction<Float, LongValueWithProperHashCode> translator = new UnsignedFloatToLongValueWithProperHashCode();

	Assert.assertEquals(new LongValueWithProperHashCode(0L),
		translator.translate(Float.intBitsToFloat(0), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
		translator.translate(Float.intBitsToFloat(Integer.MIN_VALUE), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1),
		translator.translate(Float.intBitsToFloat(-1), longValueWithProperHashCode));
}
 
Example #3
Source Project: flink   Author: flink-tpc-ds   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToFloat() throws Exception {
	TranslateFunction<LongValue, Float> translator = new LongValueToUnsignedFloat();

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(0)),
		translator.translate(new LongValue(0L), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(Integer.MIN_VALUE)),
		translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(-1)),
		translator.translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1), null));
}
 
Example #4
Source Project: flink   Author: flink-tpc-ds   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testFromFloat() throws Exception {
	TranslateFunction<Float, LongValueWithProperHashCode> translator = new UnsignedFloatToLongValueWithProperHashCode();

	Assert.assertEquals(new LongValueWithProperHashCode(0L),
		translator.translate(Float.intBitsToFloat(0), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
		translator.translate(Float.intBitsToFloat(Integer.MIN_VALUE), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1),
		translator.translate(Float.intBitsToFloat(-1), longValueWithProperHashCode));
}
 
Example #5
Source Project: flink   Author: apache   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToFloat() throws Exception {
	TranslateFunction<LongValue, Float> translator = new LongValueToUnsignedFloat();

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(0)),
		translator.translate(new LongValue(0L), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(Integer.MIN_VALUE)),
		translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));

	Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(-1)),
		translator.translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1), null));
}
 
Example #6
Source Project: flink   Author: apache   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testFromFloat() throws Exception {
	TranslateFunction<Float, LongValueWithProperHashCode> translator = new UnsignedFloatToLongValueWithProperHashCode();

	Assert.assertEquals(new LongValueWithProperHashCode(0L),
		translator.translate(Float.intBitsToFloat(0), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
		translator.translate(Float.intBitsToFloat(Integer.MIN_VALUE), longValueWithProperHashCode));

	Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1),
		translator.translate(Float.intBitsToFloat(-1), longValueWithProperHashCode));
}
 
Example #7
Source Project: Flink-CEPplus   Author: ljygz   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatUpperOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT), null);
}
 
Example #8
Source Project: Flink-CEPplus   Author: ljygz   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatLowerOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(-1), null);
}
 
Example #9
Source Project: flink   Author: flink-tpc-ds   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatUpperOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT), null);
}
 
Example #10
Source Project: flink   Author: flink-tpc-ds   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatLowerOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(-1), null);
}
 
Example #11
Source Project: flink   Author: apache   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatUpperOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT), null);
}
 
Example #12
Source Project: flink   Author: apache   File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testToFloatLowerOutOfRange() throws Exception {
	new LongValueToUnsignedFloat().translate(new LongValue(-1), null);
}