本文整理汇总了Java中org.apache.flink.core.fs.FileInputSplit.getStart方法的典型用法代码示例。如果您正苦于以下问题:Java FileInputSplit.getStart方法的具体用法?Java FileInputSplit.getStart怎么用?Java FileInputSplit.getStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.core.fs.FileInputSplit
的用法示例。
在下文中一共展示了FileInputSplit.getStart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initReader
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
private DataFileReader<E> initReader(FileInputSplit split) throws IOException {
DatumReader<E> datumReader;
if (org.apache.avro.generic.GenericRecord.class == avroValueType) {
datumReader = new GenericDatumReader<E>();
} else {
datumReader = org.apache.avro.specific.SpecificRecordBase.class.isAssignableFrom(avroValueType)
? new SpecificDatumReader<E>(avroValueType) : new ReflectDatumReader<E>(avroValueType);
}
if (LOG.isInfoEnabled()) {
LOG.info("Opening split {}", split);
}
SeekableInput in = new FSDataInputStreamWrapper(stream, split.getPath().getFileSystem().getFileStatus(split.getPath()).getLen());
DataFileReader<E> dataFileReader = (DataFileReader) DataFileReader.openReader(in, datumReader);
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded SCHEMA: {}", dataFileReader.getSchema());
}
end = split.getStart() + split.getLength();
recordsReadSinceLastSync = 0;
return dataFileReader;
}
示例2: getOffsetAndLengthForSplit
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
private Tuple2<Long, Long> getOffsetAndLengthForSplit(FileInputSplit split, List<StripeInformation> stripes) {
long splitStart = split.getStart();
long splitEnd = splitStart + split.getLength();
long readStart = Long.MAX_VALUE;
long readEnd = Long.MIN_VALUE;
for (StripeInformation s : stripes) {
if (splitStart <= s.getOffset() && s.getOffset() < splitEnd) {
// stripe starts in split, so it is included
readStart = Math.min(readStart, s.getOffset());
readEnd = Math.max(readEnd, s.getOffset() + s.getLength());
}
}
if (readStart < Long.MAX_VALUE) {
// at least one split is included
return Tuple2.of(readStart, readEnd - readStart);
} else {
return Tuple2.of(0L, 0L);
}
}
示例3: reopen
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
@PublicEvolving
@Override
public void reopen(FileInputSplit split, Long state) throws IOException {
Preconditions.checkNotNull(split, "reopen() cannot be called on a null split.");
Preconditions.checkNotNull(state, "reopen() cannot be called with a null initial state.");
Preconditions.checkArgument(state == -1 || state >= split.getStart(),
" Illegal offset "+ state +", smaller than the splits start=" + split.getStart());
try {
this.open(split);
} finally {
this.offset = state;
}
if (state > this.splitStart + split.getLength()) {
this.end = true;
} else if (state > split.getStart()) {
initBuffers();
this.stream.seek(this.offset);
if (split.getLength() == -1) {
// this is the case for unsplittable files
fillBuffer();
} else {
this.splitLength = this.splitStart + split.getLength() - this.offset;
if (splitLength <= 0) {
this.end = true;
}
}
}
}
示例4: open
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
/**
* Opens an input stream to the file defined in the input format.
* The stream is positioned at the beginning of the given split.
* <p>
* The stream is actually opened in an asynchronous thread to make sure any interruptions to the thread
* working on the input format do not reach the file system.
*/
@Override
public void open(FileInputSplit fileSplit) throws IOException {
this.currentSplit = fileSplit;
this.splitStart = fileSplit.getStart();
this.splitLength = fileSplit.getLength();
if (LOG.isDebugEnabled()) {
LOG.debug("Opening input split " + fileSplit.getPath() + " [" + this.splitStart + "," + this.splitLength + "]");
}
// open the split in an asynchronous thread
final InputSplitOpenThread isot = new InputSplitOpenThread(fileSplit, this.openTimeout);
isot.start();
try {
this.stream = isot.waitForCompletion();
this.stream = decorateInputStream(this.stream, fileSplit);
}
catch (Throwable t) {
throw new IOException("Error opening the Input Split " + fileSplit.getPath() +
" [" + splitStart + "," + splitLength + "]: " + t.getMessage(), t);
}
// get FSDataInputStream
if (this.splitStart != 0) {
this.stream.seek(this.splitStart);
}
}
示例5: reopen
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
@PublicEvolving
@Override
public void reopen(FileInputSplit split, Long state) throws IOException {
Preconditions.checkNotNull(split, "reopen() cannot be called on a null split.");
Preconditions.checkNotNull(state, "reopen() cannot be called with a null initial state.");
Preconditions.checkArgument(state == -1 || state >= split.getStart(),
" Illegal offset "+ state +", smaller than the splits start=" + split.getStart());
try {
this.open(split);
} finally {
this.offset = state;
}
if (state > this.splitStart + split.getLength()) {
this.end = true;
} else if (state > split.getStart()) {
initBuffers();
this.stream.seek(this.offset);
if (split.getLength() == -1) {
// this is the case for unsplittable files
fillBuffer(0);
} else {
this.splitLength = this.splitStart + split.getLength() - this.offset;
if (splitLength <= 0) {
this.end = true;
}
}
}
}
示例6: getTimestampedSplit
import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
private TimestampedFileInputSplit getTimestampedSplit(long modTime, FileInputSplit split) {
Preconditions.checkNotNull(split);
return new TimestampedFileInputSplit(
modTime,
split.getSplitNumber(),
split.getPath(),
split.getStart(),
split.getLength(),
split.getHostnames());
}