org.apache.flink.graph.asm.translate.TranslateFunction Java Examples
The following examples show how to use
org.apache.flink.graph.asm.translate.TranslateFunction.
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 File: TertiaryResultBase.java From flink with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicTertiaryResult<>(); } K vertexId0 = this.getVertexId0(); K vertexId1 = this.getVertexId1(); K vertexId2 = this.getVertexId2(); TertiaryResult<T> translatable = (TertiaryResult<T>) reuse; TertiaryResult<T> translated = (TertiaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1())); translated.setVertexId2(translator.translate(this.getVertexId2(), translatable.getVertexId2())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); this.setVertexId1(vertexId1); this.setVertexId2(vertexId2); return reuse; }
Example #2
Source File: BinaryResultBase.java From flink with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicBinaryResult<>(); } K vertexId0 = this.getVertexId0(); K vertexId1 = this.getVertexId1(); BinaryResult<T> translatable = (BinaryResult<T>) reuse; BinaryResult<T> translated = (BinaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); this.setVertexId1(vertexId1); return reuse; }
Example #3
Source File: UnaryResultBase.java From flink with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicUnaryResult<>(); } K vertexId0 = this.getVertexId0(); UnaryResult<T> translatable = (UnaryResult<T>) reuse; UnaryResult<T> translated = (UnaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); return reuse; }
Example #4
Source File: UnaryResultBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicUnaryResult<>(); } K vertexId0 = this.getVertexId0(); UnaryResult<T> translatable = (UnaryResult<T>) reuse; UnaryResult<T> translated = (UnaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); return reuse; }
Example #5
Source File: BinaryResultBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicBinaryResult<>(); } K vertexId0 = this.getVertexId0(); K vertexId1 = this.getVertexId1(); BinaryResult<T> translatable = (BinaryResult<T>) reuse; BinaryResult<T> translated = (BinaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); this.setVertexId1(vertexId1); return reuse; }
Example #6
Source File: TertiaryResultBase.java From flink with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicTertiaryResult<>(); } K vertexId0 = this.getVertexId0(); K vertexId1 = this.getVertexId1(); K vertexId2 = this.getVertexId2(); TertiaryResult<T> translatable = (TertiaryResult<T>) reuse; TertiaryResult<T> translated = (TertiaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1())); translated.setVertexId2(translator.translate(this.getVertexId2(), translatable.getVertexId2())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); this.setVertexId1(vertexId1); this.setVertexId2(vertexId2); return reuse; }
Example #7
Source File: UnaryResultBase.java From flink with Apache License 2.0 | 6 votes |
@Override public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception { if (reuse == null) { reuse = new BasicUnaryResult<>(); } K vertexId0 = this.getVertexId0(); UnaryResult<T> translatable = (UnaryResult<T>) reuse; UnaryResult<T> translated = (UnaryResult<T>) this; translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0())); out.collect((TranslatableResult<T>) translated); this.setVertexId0(vertexId0); return reuse; }
Example #8
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@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 #9
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToInt() throws Exception { TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt(); Assert.assertEquals(Integer.valueOf(0), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE), translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null)); Assert.assertEquals(Integer.valueOf(-1), translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null)); }
Example #10
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToDoubleValue() throws Exception { TranslateFunction<LongValue, DoubleValue> translator = new LongValueToDoubleValue(); Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(0L)), translator.translate(new LongValue(0L), doubleValue)); Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(Long.MIN_VALUE)), translator.translate(new LongValue(Long.MIN_VALUE), doubleValue)); Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(Long.MAX_VALUE)), translator.translate(new LongValue(Long.MAX_VALUE), doubleValue)); }
Example #11
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToCharacter() throws Exception { TranslateFunction<LongValue, Character> translator = new LongValueToChar(); Assert.assertEquals(Character.valueOf((char) 0), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Character.valueOf(Character.MAX_VALUE), translator.translate(new LongValue(LongValueToChar.MAX_VERTEX_COUNT - 1), null)); }
Example #12
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromShortValue() throws Exception { TranslateFunction<ShortValue, LongValueWithProperHashCode> translator = new UnsignedShortValueToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(new ShortValue((short) 0), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1), translator.translate(new ShortValue(Short.MIN_VALUE), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1), translator.translate(new ShortValue((short) -1), longValueWithProperHashCode)); }
Example #13
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToShort() throws Exception { TranslateFunction<LongValue, Short> translator = new LongValueToUnsignedShort(); Assert.assertEquals(Short.valueOf((short) 0), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Short.valueOf(Short.MIN_VALUE), translator.translate(new LongValue((long) Short.MAX_VALUE + 1), null)); Assert.assertEquals(Short.valueOf((short) -1), translator.translate(new LongValue(LongValueToUnsignedShort.MAX_VERTEX_COUNT - 1), null)); }
Example #14
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromShort() throws Exception { TranslateFunction<Short, LongValueWithProperHashCode> translator = new UnsignedShortToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate((short) 0, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1), translator.translate(Short.MIN_VALUE, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShort.MAX_VERTEX_COUNT - 1), translator.translate((short) -1, longValueWithProperHashCode)); }
Example #15
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToCharValue() throws Exception { TranslateFunction<LongValue, CharValue> translator = new LongValueToCharValue(); Assert.assertEquals(new CharValue((char) 0), translator.translate(new LongValue(0L), charValue)); Assert.assertEquals(new CharValue(Character.MAX_VALUE), translator.translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT - 1), charValue)); }
Example #16
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromInt() throws Exception { TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(0, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1), translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), translator.translate(-1, longValueWithProperHashCode)); }
Example #17
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromLongValue() throws Exception { TranslateFunction<LongValue, LongValueWithProperHashCode> translator = new LongValueToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(new LongValue(0), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE), translator.translate(new LongValue(Long.MIN_VALUE), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE), translator.translate(new LongValue(Long.MAX_VALUE), longValueWithProperHashCode)); }
Example #18
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@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)); }
Example #19
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToDouble() throws Exception { TranslateFunction<LongValue, Double> translator = new LongValueToDouble(); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(0L)), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MIN_VALUE)), translator.translate(new LongValue(Long.MIN_VALUE), null)); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MAX_VALUE)), translator.translate(new LongValue(Long.MAX_VALUE), null)); }
Example #20
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToDouble() throws Exception { TranslateFunction<LongValue, Double> translator = new LongValueToDouble(); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(0L)), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MIN_VALUE)), translator.translate(new LongValue(Long.MIN_VALUE), null)); Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MAX_VALUE)), translator.translate(new LongValue(Long.MAX_VALUE), null)); }
Example #21
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromFloatValue() throws Exception { TranslateFunction<FloatValue, LongValueWithProperHashCode> translator = new UnsignedFloatValueToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(new FloatValue(Float.intBitsToFloat(0)), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1), translator.translate(new FloatValue(Float.intBitsToFloat(Integer.MIN_VALUE)), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloatValue.MAX_VERTEX_COUNT - 1), translator.translate(new FloatValue(Float.intBitsToFloat(-1)), longValueWithProperHashCode)); }
Example #22
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToFloatValue() throws Exception { TranslateFunction<LongValue, FloatValue> translator = new LongValueToUnsignedFloatValue(); Assert.assertEquals(new FloatValue(Float.intBitsToFloat(0)), translator.translate(new LongValue(0L), floatValue)); Assert.assertEquals(new FloatValue(Float.intBitsToFloat(Integer.MIN_VALUE)), translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), floatValue)); Assert.assertEquals(new FloatValue(Float.intBitsToFloat(-1)), translator.translate(new LongValue(LongValueToUnsignedFloatValue.MAX_VERTEX_COUNT - 1), floatValue)); }
Example #23
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromLongValue() throws Exception { TranslateFunction<LongValue, LongValueWithProperHashCode> translator = new LongValueToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(new LongValue(0), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE), translator.translate(new LongValue(Long.MIN_VALUE), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE), translator.translate(new LongValue(Long.MAX_VALUE), longValueWithProperHashCode)); }
Example #24
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromInt() throws Exception { TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(0, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1), translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), translator.translate(-1, longValueWithProperHashCode)); }
Example #25
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToInt() throws Exception { TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt(); Assert.assertEquals(Integer.valueOf(0), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE), translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null)); Assert.assertEquals(Integer.valueOf(-1), translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null)); }
Example #26
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testToCharacter() throws Exception { TranslateFunction<LongValue, Character> translator = new LongValueToChar(); Assert.assertEquals(Character.valueOf((char) 0), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Character.valueOf(Character.MAX_VALUE), translator.translate(new LongValue(LongValueToChar.MAX_VERTEX_COUNT - 1), null)); }
Example #27
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testLongValueToLongTranslation() throws Exception { TranslateFunction<LongValue, Long> translator = new LongValueToLong(); Assert.assertEquals(Long.valueOf(0L), translator.translate(new LongValue(0L), null)); Assert.assertEquals(Long.valueOf(Long.MIN_VALUE), translator.translate(new LongValue(Long.MIN_VALUE), null)); Assert.assertEquals(Long.valueOf(Long.MAX_VALUE), translator.translate(new LongValue(Long.MAX_VALUE), null)); }
Example #28
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromShort() throws Exception { TranslateFunction<Short, LongValueWithProperHashCode> translator = new UnsignedShortToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate((short) 0, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1), translator.translate(Short.MIN_VALUE, longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShort.MAX_VERTEX_COUNT - 1), translator.translate((short) -1, longValueWithProperHashCode)); }
Example #29
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFromShortValue() throws Exception { TranslateFunction<ShortValue, LongValueWithProperHashCode> translator = new UnsignedShortValueToLongValueWithProperHashCode(); Assert.assertEquals(new LongValueWithProperHashCode(0L), translator.translate(new ShortValue((short) 0), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1), translator.translate(new ShortValue(Short.MIN_VALUE), longValueWithProperHashCode)); Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1), translator.translate(new ShortValue((short) -1), longValueWithProperHashCode)); }
Example #30
Source File: GraphKeyTypeTransformTest.java From flink with Apache License 2.0 | 5 votes |
@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)); }