Java Code Examples for org.apache.flink.api.java.tuple.Tuple4#of()
The following examples show how to use
org.apache.flink.api.java.tuple.Tuple4#of() .
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: BucketingSinkTestProgram.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public Tuple4<Integer, Long, Integer, String> map(Tuple3<Integer, Long, String> value) throws IOException { // update counter Integer counterValue = counter.value(); if (counterValue == null) { counterValue = 0; } counter.update(counterValue + 1); // save last value Long lastValue = last.value(); if (lastValue == null) { lastValue = initialValue; } last.update(value.f1); return Tuple4.of(value.f0, value.f1 - lastValue, counterValue, value.f2); }
Example 2
Source File: BucketingSinkTestProgram.java From flink with Apache License 2.0 | 6 votes |
@Override public Tuple4<Integer, Long, Integer, String> map(Tuple3<Integer, Long, String> value) throws IOException { // update counter Integer counterValue = counter.value(); if (counterValue == null) { counterValue = 0; } counter.update(counterValue + 1); // save last value Long lastValue = last.value(); if (lastValue == null) { lastValue = initialValue; } last.update(value.f1); return Tuple4.of(value.f0, value.f1 - lastValue, counterValue, value.f2); }
Example 3
Source File: BucketingSinkTestProgram.java From flink with Apache License 2.0 | 6 votes |
@Override public Tuple4<Integer, Long, Integer, String> map(Tuple3<Integer, Long, String> value) throws IOException { // update counter Integer counterValue = counter.value(); if (counterValue == null) { counterValue = 0; } counter.update(counterValue + 1); // save last value Long lastValue = last.value(); if (lastValue == null) { lastValue = initialValue; } last.update(value.f1); return Tuple4.of(value.f0, value.f1 - lastValue, counterValue, value.f2); }
Example 4
Source File: VectorStandardScalerModelDataConverter.java From Alink with Apache License 2.0 | 5 votes |
/** * Deserialize the model data. * * @param meta The model meta data. * @param data The model concrete data. * @param additionData The additional data. * @return The model data used by mapper. */ @Override public Tuple4<Boolean, Boolean, double[], double[]> deserializeModel(Params meta, Iterable<String> data, Iterable<Row> additionData) { double[] means = JsonConverter.fromJson(data.iterator().next(), double[].class); double[] stdDevs = JsonConverter.fromJson(data.iterator().next(), double[].class); Boolean withMean = meta.get(VectorStandardTrainParams.WITH_MEAN); Boolean withStd = meta.get(VectorStandardTrainParams.WITH_STD); return Tuple4.of(withMean, withStd, means, stdDevs); }
Example 5
Source File: VectorMinMaxScalerModelDataConverter.java From Alink with Apache License 2.0 | 5 votes |
/** * Deserialize the model data. * * @param meta The model meta data. * @param data The model concrete data. * @param additionData The additional data. * @return The model data used by mapper. */ @Override public Tuple4<Double, Double, double[], double[]> deserializeModel(Params meta, Iterable<String> data, Iterable<Row> additionData) { double min = meta.get(VectorMinMaxScalerTrainParams.MIN); double max = meta.get(VectorMinMaxScalerTrainParams.MAX); double[] eMins = JsonConverter.fromJson(data.iterator().next(), double[].class); double[] eMaxs = JsonConverter.fromJson(data.iterator().next(), double[].class); return Tuple4.of(min, max, eMins, eMaxs); }
Example 6
Source File: ChiSquareTest.java From Alink with Apache License 2.0 | 5 votes |
/** * @param crossTabWithId: f0 is id, f1 is cross table * @return tuple4: f0 is id which is id of cross table, f1 is pValue, f2 is chi-square Value, f3 is df */ protected static Tuple4<Integer, Double, Double, Double> test(Tuple2<Integer, Crosstab> crossTabWithId) { int colIdx = crossTabWithId.f0; Crosstab crosstab = crossTabWithId.f1; int rowLen = crosstab.rowTags.size(); int colLen = crosstab.colTags.size(); //compute row sum and col sum double[] rowSum = crosstab.rowSum(); double[] colSum = crosstab.colSum(); double n = crosstab.sum(); //compute statistic value double chiSq = 0; for (int i = 0; i < rowLen; i++) { for (int j = 0; j < colLen; j++) { double nij = rowSum[i] * colSum[j] / n; double temp = crosstab.data[i][j] - nij; chiSq += temp * temp / nij; } } //set result double p; if (rowLen <= 1 || colLen <= 1) { p = 1; } else { ChiSquaredDistribution distribution = new ChiSquaredDistribution(null, (rowLen - 1) * (colLen - 1)); p = 1.0 - distribution.cumulativeProbability(Math.abs(chiSq)); } return Tuple4.of(colIdx, p, chiSq, (double)(rowLen - 1) * (colLen - 1)); }
Example 7
Source File: LinkedData.java From Alink with Apache License 2.0 | 5 votes |
public Tuple4<Float, Double, Double, Float> getData() { int currentIndex = this.iteratorArray.getPoint() * 24; return Tuple4.of(buffer.getFloat(currentIndex), buffer.getDouble(currentIndex + 4), buffer.getDouble(currentIndex + 12), buffer.getFloat(currentIndex + 20)); }
Example 8
Source File: StreamSerializerTest.java From flink-siddhi with Apache License 2.0 | 5 votes |
@Test public void testTupleType() { Tuple4 row = Tuple4.of(1, "test", 56.7, CURRENT); StreamSchema<Tuple4> schema = new StreamSchema<>(new TupleTypeInfo<>( TypeExtractor.createTypeInfo(Integer.class), TypeExtractor.createTypeInfo(String.class), TypeExtractor.createTypeInfo(Double.class), TypeExtractor.createTypeInfo(Long.class)) , "id", "name", "price", "timestamp"); StreamSerializer<Tuple4> reader = new StreamSerializer<>(schema); Assert.assertArrayEquals(new Object[]{1, "test", 56.7, CURRENT}, reader.getRow(row)); }
Example 9
Source File: LocalitySensitiveHashApproxFunctions.java From Alink with Apache License 2.0 | 4 votes |
@Override public Tuple4 <Long, Row, Row, Double> join(Tuple3 <Vector, Long, Row> left, Tuple3 <Vector, Row, Long> right) throws Exception { return Tuple4.of(left.f1, left.f2, right.f1, lsh.keyDistance(left.f0, right.f0)); }