Java Code Examples for org.apache.flink.types.Record#getField()
The following examples show how to use
org.apache.flink.types.Record#getField() .
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: ReduceTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 2
Source File: RecordComparator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compare(Record first, Record second) { int i = 0; try { for (; i < this.keyFields.length; i++) { Comparable k1 = (Comparable) first.getField(this.keyFields[i], this.keyHolders[i]); Comparable k2 = (Comparable) second.getField(this.keyFields[i], this.transientKeyHolders[i]); int cmp = k1.compareTo(k2); if (cmp != 0) { return cmp; } } return 0; } catch (NullPointerException e) { throw new NullKeyFieldException(this.keyFields[i]); } }
Example 3
Source File: CombineTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } if (++this.cnt >= 10) { throw new ExpectedTestException(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 4
Source File: CombineTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } if (++this.cnt >= 10) { throw new ExpectedTestException(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 5
Source File: ReduceTaskTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int valCnt = 0; for (Record next : records) { element = next; valCnt++; } if (++this.cnt >= 10) { throw new ExpectedTestException(); } element.getField(0, this.key); this.value.setValue(valCnt - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 6
Source File: ReduceTaskTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 7
Source File: ReduceTaskTest.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 8
Source File: ReduceTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.value); sum += this.value.getValue(); } element.getField(0, this.key); this.value.setValue(sum - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 9
Source File: RecordPairComparator.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int compareToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Comparable k = (Comparable) candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else { final int comp = k.compareTo(this.keyHolders1[i]); if (comp != 0) { return comp; } } } return 0; }
Example 10
Source File: ReduceTaskExternalITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.value); sum += this.value.getValue(); } element.getField(0, this.key); this.value.setValue(sum - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 11
Source File: CombineTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.value); sum += this.value.getValue(); } element.getField(0, this.key); this.value.setValue(sum - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 12
Source File: ReduceTaskTest.java From flink with Apache License 2.0 | 6 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.value); sum += this.value.getValue(); } element.getField(0, this.key); this.value.setValue(sum - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 13
Source File: CombineTaskExternalITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } if (++this.cnt >= 10) { throw new ExpectedTestException(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 14
Source File: DataSourceTaskTest.java From flink with Apache License 2.0 | 6 votes |
public static void prepareInputFile(MutableObjectIterator<Record> inIt, File inputFile, boolean insertInvalidData) throws IOException { try (BufferedWriter bw = new BufferedWriter(new FileWriter(inputFile))) { if (insertInvalidData) { bw.write("####_I_AM_INVALID_########\n"); } Record rec = new Record(); while ((rec = inIt.next(rec)) != null) { IntValue key = rec.getField(0, IntValue.class); IntValue value = rec.getField(1, IntValue.class); bw.write(key.getValue() + "_" + value.getValue() + "\n"); } if (insertInvalidData) { bw.write("####_I_AM_INVALID_########\n"); } bw.flush(); } }
Example 15
Source File: ReduceTaskExternalITCase.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 16
Source File: ReduceTaskTest.java From flink with Apache License 2.0 | 6 votes |
@Override public void combine(Iterable<Record> records, Collector<Record> out) { Record element = null; int sum = 0; for (Record next : records) { element = next; element.getField(1, this.combineValue); sum += this.combineValue.getValue(); } this.combineValue.setValue(sum); element.setField(1, this.combineValue); out.collect(element); }
Example 17
Source File: ReduceTaskTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<Record> records, Collector<Record> out) { Record element = null; int cnt = 0; for (Record next : records) { element = next; cnt++; } element.getField(0, this.key); this.value.setValue(cnt - this.key.getValue()); element.setField(1, this.value); out.collect(element); }
Example 18
Source File: RecordPairComparator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields2.length; i++) { final Value k = candidate.getField(this.keyFields2[i], this.keyHolders2[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields2[i]); } else if (!k.equals(this.keyHolders1[i])) { return false; } } return true; }
Example 19
Source File: RecordComparator.java From flink with Apache License 2.0 | 5 votes |
@Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields.length; i++) { final Value k = candidate.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields[i]); } else if (!k.equals(this.keyHolders[i])) { return false; } } return true; }
Example 20
Source File: DataSinkTaskTest.java From flink with Apache License 2.0 | 5 votes |
@Override public void writeRecord(Record rec) throws IOException { IntValue key = rec.getField(0, IntValue.class); IntValue value = rec.getField(1, IntValue.class); this.bld.setLength(0); this.bld.append(key.getValue()); this.bld.append('_'); this.bld.append(value.getValue()); this.bld.append('\n'); byte[] bytes = this.bld.toString().getBytes(ConfigConstants.DEFAULT_CHARSET); this.stream.write(bytes); }