Codota Logo
StreamExecutionEnvironment.readFile
Code IndexAdd Codota to your IDE (free)

How to use
readFile
method
in
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment

Best Java code snippets using org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.readFile (Showing top 20 results out of 315)

  • Common ways to obtain StreamExecutionEnvironment
private void myMethod () {
StreamExecutionEnvironment s =
  • Codota IconStreamExecutionEnvironment.getExecutionEnvironment()
  • Codota IconStreamExecutionEnvironment.createLocalEnvironment()
  • Smart code suggestions by Codota
}
origin: apache/flink

/**
 * Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
 *
 * <p>Since all data streams need specific information about their types, this method needs to determine the
 * type of the data produced by the input format. It will attempt to determine the data type by reflection,
 * unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
 * In the latter case, this method will invoke the
 * {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
 * type produced by the input format.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param inputFormat
 *         The input format used to create the data stream
 * @param <OUT>
 *         The type of the returned data stream
 * @return The data stream that represents the data read from the given file
 */
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
                      String filePath) {
  return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
origin: apache/flink

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: apache/flink

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: apache/flink

/**
 * Reads the given file line-by-line and creates a data stream that contains a string with the
 * contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
 * used to read the files.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param charsetName
 *         The name of the character set used to read the file
 * @return The data stream that represents the data read from the given file as text lines
 */
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
  Preconditions.checkNotNull(filePath, "The file path must not be null.");
  Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
  TextInputFormat format = new TextInputFormat(new Path(filePath));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
  format.setCharsetName(charsetName);
  return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
}
origin: apache/flink

@Override
public void testProgram(StreamExecutionEnvironment env) {
  // set the restart strategy.
  env.getConfig().setRestartStrategy(RestartStrategies.fixedDelayRestart(NO_OF_RETRIES, 0));
  env.enableCheckpointing(10);
  // create and start the file creating thread.
  fc = new FileCreator();
  fc.start();
  // create the monitoring source along with the necessary readers.
  TextInputFormat format = new TextInputFormat(new org.apache.flink.core.fs.Path(localFsURI));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  DataStream<String> inputStream = env.readFile(format, localFsURI,
    FileProcessingMode.PROCESS_CONTINUOUSLY, INTERVAL);
  TestingSinkFunction sink = new TestingSinkFunction();
  inputStream.flatMap(new FlatMapFunction<String, String>() {
    @Override
    public void flatMap(String value, Collector<String> out) throws Exception {
      out.collect(value);
    }
  }).addSink(sink).setParallelism(1);
}
origin: DTStack/flinkx

/**
 * Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
 *
 * <p>Since all data streams need specific information about their types, this method needs to determine the
 * type of the data produced by the input format. It will attempt to determine the data type by reflection,
 * unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
 * In the latter case, this method will invoke the
 * {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
 * type produced by the input format.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param inputFormat
 *         The input format used to create the data stream
 * @param <OUT>
 *         The type of the returned data stream
 * @return The data stream that represents the data read from the given file
 */
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
                      String filePath) {
  return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
origin: org.apache.flink/flink-streaming-java

/**
 * Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
 *
 * <p>Since all data streams need specific information about their types, this method needs to determine the
 * type of the data produced by the input format. It will attempt to determine the data type by reflection,
 * unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
 * In the latter case, this method will invoke the
 * {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
 * type produced by the input format.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param inputFormat
 *         The input format used to create the data stream
 * @param <OUT>
 *         The type of the returned data stream
 * @return The data stream that represents the data read from the given file
 */
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
                      String filePath) {
  return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
origin: org.apache.flink/flink-streaming-java_2.11

/**
 * Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
 *
 * <p>Since all data streams need specific information about their types, this method needs to determine the
 * type of the data produced by the input format. It will attempt to determine the data type by reflection,
 * unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
 * In the latter case, this method will invoke the
 * {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
 * type produced by the input format.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param inputFormat
 *         The input format used to create the data stream
 * @param <OUT>
 *         The type of the returned data stream
 * @return The data stream that represents the data read from the given file
 */
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
                      String filePath) {
  return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
origin: org.apache.flink/flink-streaming-java_2.10

/**
 * Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
 *
 * <p>Since all data streams need specific information about their types, this method needs to determine the
 * type of the data produced by the input format. It will attempt to determine the data type by reflection,
 * unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
 * In the latter case, this method will invoke the
 * {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
 * type produced by the input format.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param inputFormat
 *         The input format used to create the data stream
 * @param <OUT>
 *         The type of the returned data stream
 * @return The data stream that represents the data read from the given file
 */
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
                      String filePath) {
  return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
origin: DTStack/flinkx

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: org.apache.flink/flink-streaming-java_2.11

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: org.apache.flink/flink-streaming-java

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: org.apache.flink/flink-streaming-java_2.10

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: org.apache.flink/flink-streaming-java_2.11

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: org.apache.flink/flink-streaming-java

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: DTStack/flinkx

      "explicitly by using the 'createInput(InputFormat, TypeInformation)' method instead.");
return readFile(inputFormat, filePath, watchType, interval, typeInformation);
origin: DTStack/flinkx

/**
 * Reads the given file line-by-line and creates a data stream that contains a string with the
 * contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
 * used to read the files.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param charsetName
 *         The name of the character set used to read the file
 * @return The data stream that represents the data read from the given file as text lines
 */
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
  Preconditions.checkNotNull(filePath, "The file path must not be null.");
  Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
  TextInputFormat format = new TextInputFormat(new Path(filePath));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
  format.setCharsetName(charsetName);
  return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
}
origin: org.apache.flink/flink-streaming-java_2.11

/**
 * Reads the given file line-by-line and creates a data stream that contains a string with the
 * contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
 * used to read the files.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param charsetName
 *         The name of the character set used to read the file
 * @return The data stream that represents the data read from the given file as text lines
 */
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
  Preconditions.checkNotNull(filePath, "The file path must not be null.");
  Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
  TextInputFormat format = new TextInputFormat(new Path(filePath));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
  format.setCharsetName(charsetName);
  return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
}
origin: org.apache.flink/flink-streaming-java

/**
 * Reads the given file line-by-line and creates a data stream that contains a string with the
 * contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
 * used to read the files.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param charsetName
 *         The name of the character set used to read the file
 * @return The data stream that represents the data read from the given file as text lines
 */
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
  Preconditions.checkNotNull(filePath, "The file path must not be null.");
  Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
  TextInputFormat format = new TextInputFormat(new Path(filePath));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
  format.setCharsetName(charsetName);
  return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
}
origin: org.apache.flink/flink-streaming-java_2.10

/**
 * Reads the given file line-by-line and creates a data stream that contains a string with the
 * contents of each such line. The {@link java.nio.charset.Charset} with the given name will be
 * used to read the files.
 *
 * <p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
 * {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
 * forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
 * and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
 * barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
 *
 * @param filePath
 *         The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
 * @param charsetName
 *         The name of the character set used to read the file
 * @return The data stream that represents the data read from the given file as text lines
 */
public DataStreamSource<String> readTextFile(String filePath, String charsetName) {
  Preconditions.checkNotNull(filePath, "The file path must not be null.");
  Preconditions.checkNotNull(filePath.isEmpty(), "The file path must not be empty.");
  TextInputFormat format = new TextInputFormat(new Path(filePath));
  format.setFilesFilter(FilePathFilter.createDefaultFilter());
  TypeInformation<String> typeInfo = BasicTypeInfo.STRING_TYPE_INFO;
  format.setCharsetName(charsetName);
  return readFile(format, filePath, FileProcessingMode.PROCESS_ONCE, -1, typeInfo);
}
org.apache.flink.streaming.api.environmentStreamExecutionEnvironmentreadFile

Javadoc

Reads the contents of the user-specified filePath based on the given FileInputFormat.

Since all data streams need specific information about their types, this method needs to determine the type of the data produced by the input format. It will attempt to determine the data type by reflection, unless the input format implements the org.apache.flink.api.java.typeutils.ResultTypeQueryable interface. In the latter case, this method will invoke the org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType() method to determine data type produced by the input format.

NOTES ON CHECKPOINTING: The source monitors the path, creates the org.apache.flink.core.fs.FileInputSplit to be processed, forwards them to the downstream ContinuousFileReaderOperator to read the actual data, and exits, without waiting for the readers to finish reading. This implies that no more checkpoint barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.

Popular methods of StreamExecutionEnvironment

  • execute
  • getExecutionEnvironment
    Creates an execution environment that represents the context in which the program is currently execu
  • addSource
    Ads a data source with a custom type information thus opening a DataStream. Only in very special cas
  • getConfig
    Gets the config object.
  • enableCheckpointing
    Enables checkpointing for the streaming job. The distributed state of the streaming dataflow will be
  • setStreamTimeCharacteristic
    Sets the time characteristic for all streams create from this environment, e.g., processing time, ev
  • setParallelism
    Sets the parallelism for operations executed through this environment. Setting a parallelism of x he
  • fromElements
    Creates a new data stream that contains the given elements. The elements must all be of the same typ
  • setStateBackend
    Sets the state backend that describes how to store and checkpoint operator state. It defines both wh
  • createLocalEnvironment
    Creates a LocalStreamEnvironment. The local execution environment will run the program in a multi-th
  • fromCollection
    Creates a data stream from the given iterator.Because the iterator will remain unmodified until the
  • getCheckpointConfig
    Gets the checkpoint config, which defines values like checkpoint interval, delay between checkpoints
  • fromCollection,
  • getCheckpointConfig,
  • getParallelism,
  • getStreamGraph,
  • setRestartStrategy,
  • socketTextStream,
  • readTextFile,
  • generateSequence,
  • clean,
  • getStreamTimeCharacteristic

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • setContentView (Activity)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • ImageIO (javax.imageio)
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now