org.apache.flink.core.io.GenericInputSplit Java Examples
The following examples show how to use
org.apache.flink.core.io.GenericInputSplit.
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: Generator.java From flink with Apache License 2.0 | 6 votes |
@Override public void open(GenericInputSplit split) throws IOException { this.partitionId = split.getSplitNumber(); // total number of partitions int numPartitions = split.getTotalNumberOfSplits(); // ensure even distribution of records and keys Preconditions.checkArgument( numRecords % numPartitions == 0, "Records cannot be evenly distributed among partitions"); Preconditions.checkArgument( numKeys % numPartitions == 0, "Keys cannot be evenly distributed among partitions"); this.recordsPerPartition = numRecords / numPartitions; this.keysPerPartition = numKeys / numPartitions; this.recordCnt = 0; }
Example #2
Source File: Generator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void open(GenericInputSplit split) throws IOException { this.partitionId = split.getSplitNumber(); // total number of partitions int numPartitions = split.getTotalNumberOfSplits(); // ensure even distribution of records and keys Preconditions.checkArgument( numRecords % numPartitions == 0, "Records cannot be evenly distributed among partitions"); Preconditions.checkArgument( numKeys % numPartitions == 0, "Keys cannot be evenly distributed among partitions"); this.recordsPerPartition = numRecords / numPartitions; this.keysPerPartition = numKeys / numPartitions; this.recordCnt = 0; }
Example #3
Source File: ReplicatingDataSourceITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testReplicatedSourceToJoin() throws Exception { /* * Test replicated source going into join */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit> (new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0L, 1000L))), BasicTypeInfo.LONG_TYPE_INFO) .map(new ToTuple()); DataSet<Tuple1<Long>> source2 = env.generateSequence(0L, 1000L).map(new ToTuple()); DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0) .projectFirst(0) .sum(0); List<Tuple> result = pairs.collect(); String expectedResult = "(500500)"; compareResultAsText(result, expectedResult); }
Example #4
Source File: DefaultSplitAssignerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSerialSplitAssignment() { try { final int NUM_SPLITS = 50; Set<InputSplit> splits = new HashSet<InputSplit>(); for (int i = 0; i < NUM_SPLITS; i++) { splits.add(new GenericInputSplit(i, NUM_SPLITS)); } DefaultInputSplitAssigner ia = new DefaultInputSplitAssigner(splits); InputSplit is = null; while ((is = ia.getNextInputSplit("", 0)) != null) { assertTrue(splits.remove(is)); } assertTrue(splits.isEmpty()); assertNull(ia.getNextInputSplit("", 0)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #5
Source File: DefaultSplitAssignerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSerialSplitAssignment() { try { final int NUM_SPLITS = 50; Set<InputSplit> splits = new HashSet<InputSplit>(); for (int i = 0; i < NUM_SPLITS; i++) { splits.add(new GenericInputSplit(i, NUM_SPLITS)); } DefaultInputSplitAssigner ia = new DefaultInputSplitAssigner(splits); InputSplit is = null; while ((is = ia.getNextInputSplit("", 0)) != null) { assertTrue(splits.remove(is)); } assertTrue(splits.isEmpty()); assertNull(ia.getNextInputSplit("", 0)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #6
Source File: Generator.java From flink with Apache License 2.0 | 6 votes |
@Override public void open(GenericInputSplit split) throws IOException { this.partitionId = split.getSplitNumber(); // total number of partitions int numPartitions = split.getTotalNumberOfSplits(); // ensure even distribution of records and keys Preconditions.checkArgument( numRecords % numPartitions == 0, "Records cannot be evenly distributed among partitions"); Preconditions.checkArgument( numKeys % numPartitions == 0, "Keys cannot be evenly distributed among partitions"); this.recordsPerPartition = numRecords / numPartitions; this.keysPerPartition = numKeys / numPartitions; this.recordCnt = 0; }
Example #7
Source File: ReplicatingDataSourceITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testReplicatedSourceToJoin() throws Exception { /* * Test replicated source going into join */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit> (new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0L, 1000L))), BasicTypeInfo.LONG_TYPE_INFO) .map(new ToTuple()); DataSet<Tuple1<Long>> source2 = env.generateSequence(0L, 1000L).map(new ToTuple()); DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0) .projectFirst(0) .sum(0); List<Tuple> result = pairs.collect(); String expectedResult = "(500500)"; compareResultAsText(result, expectedResult); }
Example #8
Source File: ReplicatingDataSourceITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testReplicatedSourceToJoin() throws Exception { /* * Test replicated source going into join */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit> (new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0L, 1000L))), BasicTypeInfo.LONG_TYPE_INFO) .map(new ToTuple()); DataSet<Tuple1<Long>> source2 = env.generateSequence(0L, 1000L).map(new ToTuple()); DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0) .projectFirst(0) .sum(0); List<Tuple> result = pairs.collect(); String expectedResult = "(500500)"; compareResultAsText(result, expectedResult); }
Example #9
Source File: DefaultSplitAssignerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSerialSplitAssignment() { try { final int NUM_SPLITS = 50; Set<InputSplit> splits = new HashSet<InputSplit>(); for (int i = 0; i < NUM_SPLITS; i++) { splits.add(new GenericInputSplit(i, NUM_SPLITS)); } DefaultInputSplitAssigner ia = new DefaultInputSplitAssigner(splits); InputSplit is = null; while ((is = ia.getNextInputSplit("", 0)) != null) { assertTrue(splits.remove(is)); } assertTrue(splits.isEmpty()); assertNull(ia.getNextInputSplit("", 0)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #10
Source File: NonRichGenericInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #11
Source File: Generator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int minNumSplits) { GenericInputSplit[] splits = new GenericInputSplit[minNumSplits]; for (int i = 0; i < minNumSplits; i++) { splits[i] = new GenericInputSplit(i, minNumSplits); } return splits; }
Example #12
Source File: NonRichGenericInputFormat.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #13
Source File: GenericInputFormat.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #14
Source File: JDBCInputFormat.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public InputSplit[] createInputSplits(int minNumSplits) throws IOException { if (parameterValues == null) { return new GenericInputSplit[]{new GenericInputSplit(0, 1)}; } GenericInputSplit[] ret = new GenericInputSplit[parameterValues.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new GenericInputSplit(i, ret.length); } return ret; }
Example #15
Source File: NonRichGenericInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #16
Source File: JDBCInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public InputSplit[] createInputSplits(int minNumSplits) throws IOException { if (parameterValues == null) { return new GenericInputSplit[]{new GenericInputSplit(0, 1)}; } GenericInputSplit[] ret = new GenericInputSplit[parameterValues.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new GenericInputSplit(i, ret.length); } return ret; }
Example #17
Source File: ValuesInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public void open(GenericInputSplit split) { LOG.debug("Compiling GenericInputFormat: $name \n\n Code:\n$code", generatedInput.getClassName(), generatedInput.getCode()); LOG.debug("Instantiating GenericInputFormat."); format = generatedInput.newInstance(getRuntimeContext().getUserCodeClassLoader()); generatedInput = null; }
Example #18
Source File: Generator.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int minNumSplits) { GenericInputSplit[] splits = new GenericInputSplit[minNumSplits]; for (int i = 0; i < minNumSplits; i++) { splits[i] = new GenericInputSplit(i, minNumSplits); } return splits; }
Example #19
Source File: JobTaskVertexTest.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) { if (!isConfigured) { throw new IllegalStateException("InputFormat was not configured before createInputSplits was called."); } return new GenericInputSplit[] { new TestSplit(0, 1) }; }
Example #20
Source File: GenericInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #21
Source File: JobTaskVertexTest.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) { if (!isConfigured) { throw new IllegalStateException("InputFormat was not configured before createInputSplits was called."); } return new GenericInputSplit[] { new TestSplit(0, 1) }; }
Example #22
Source File: Generator.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int minNumSplits) { GenericInputSplit[] splits = new GenericInputSplit[minNumSplits]; for (int i = 0; i < minNumSplits; i++) { splits[i] = new GenericInputSplit(i, minNumSplits); } return splits; }
Example #23
Source File: JdbcInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public InputSplit[] createInputSplits(int minNumSplits) throws IOException { if (parameterValues == null) { return new GenericInputSplit[]{new GenericInputSplit(0, 1)}; } GenericInputSplit[] ret = new GenericInputSplit[parameterValues.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new GenericInputSplit(i, ret.length); } return ret; }
Example #24
Source File: JdbcRowDataInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public InputSplit[] createInputSplits(int minNumSplits) throws IOException { if (parameterValues == null) { return new GenericInputSplit[]{new GenericInputSplit(0, 1)}; } GenericInputSplit[] ret = new GenericInputSplit[parameterValues.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new GenericInputSplit(i, ret.length); } return ret; }
Example #25
Source File: ValuesInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public void open(GenericInputSplit split) { LOG.debug("Compiling GenericInputFormat: {} \n\n Code:\n{}", generatedInput.getClassName(), generatedInput.getCode()); LOG.debug("Instantiating GenericInputFormat."); format = generatedInput.newInstance(getRuntimeContext().getUserCodeClassLoader()); generatedInput = null; }
Example #26
Source File: GenericInputFormat.java From flink with Apache License 2.0 | 5 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { if (numSplits < 1) { throw new IllegalArgumentException("Number of input splits has to be at least 1."); } numSplits = (this instanceof NonParallelInput) ? 1 : numSplits; GenericInputSplit[] splits = new GenericInputSplit[numSplits]; for (int i = 0; i < splits.length; i++) { splits[i] = new GenericInputSplit(i, numSplits); } return splits; }
Example #27
Source File: CollectionInputFormat.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void open(GenericInputSplit split) throws IOException { super.open(split); this.iterator = this.dataSet.iterator(); }
Example #28
Source File: RemoteEnvironmentITCase.java From flink with Apache License 2.0 | 4 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { assertEquals(USER_DOP, numSplits); return super.createInputSplits(numSplits); }
Example #29
Source File: ExecutionEnvironmentITCase.java From flink with Apache License 2.0 | 4 votes |
@Override public GenericInputSplit[] createInputSplits(int numSplits) throws IOException { assertEquals(PARALLELISM, numSplits); return super.createInputSplits(numSplits); }
Example #30
Source File: ParallelIteratorInputFormat.java From flink with Apache License 2.0 | 4 votes |
@Override public void open(GenericInputSplit split) throws IOException { super.open(split); this.splitIterator = this.source.getSplit(split.getSplitNumber(), split.getTotalNumberOfSplits()); }