Java Code Examples for org.apache.iceberg.io.InputFile#getLength()

The following examples show how to use org.apache.iceberg.io.InputFile#getLength() . 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: TestMetricsRowGroupFilter.java    From iceberg with Apache License 2.0 6 votes vote down vote up
private org.apache.parquet.io.InputFile parquetInputFile(InputFile inFile) {
  return new org.apache.parquet.io.InputFile() {
    @Override
    public long getLength() throws IOException {
      return inFile.getLength();
    }

    @Override
    public org.apache.parquet.io.SeekableInputStream newStream() throws IOException {
      SeekableInputStream stream = inFile.newStream();
      return new DelegatingSeekableInputStream(stream) {
        @Override
        public long getPos() throws IOException {
          return stream.getPos();
        }

        @Override
        public void seek(long newPos) throws IOException {
          stream.seek(newPos);
        }
      };
    }
  };
}
 
Example 2
Source File: TestMetricsRowGroupFilterTypes.java    From iceberg with Apache License 2.0 6 votes vote down vote up
private org.apache.parquet.io.InputFile parquetInputFile(InputFile inFile) {
  return new org.apache.parquet.io.InputFile() {
    @Override
    public long getLength() throws IOException {
      return inFile.getLength();
    }

    @Override
    public org.apache.parquet.io.SeekableInputStream newStream() throws IOException {
      SeekableInputStream stream = inFile.newStream();
      return new DelegatingSeekableInputStream(stream) {
        @Override
        public long getPos() throws IOException {
          return stream.getPos();
        }

        @Override
        public void seek(long newPos) throws IOException {
          stream.seek(newPos);
        }
      };
    }
  };
}
 
Example 3
Source File: FileMetadata.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public Builder withInputFile(InputFile file) {
  if (file instanceof HadoopInputFile) {
    return withStatus(((HadoopInputFile) file).getStat());
  }

  this.filePath = file.location();
  this.fileSizeInBytes = file.getLength();
  return this;
}
 
Example 4
Source File: DataFiles.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public static DataFile fromInputFile(InputFile file, PartitionData partition, long rowCount) {
  if (file instanceof HadoopInputFile) {
    return fromStat(((HadoopInputFile) file).getStat(), partition, rowCount);
  }

  String location = file.location();
  FileFormat format = FileFormat.fromFileName(location);
  return new GenericDataFile(
      location, format, partition, rowCount, file.getLength());
}
 
Example 5
Source File: DataFiles.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public static DataFile fromInputFile(InputFile file, long rowCount) {
  if (file instanceof HadoopInputFile) {
    return fromStat(((HadoopInputFile) file).getStat(), rowCount);
  }

  String location = file.location();
  FileFormat format = FileFormat.fromFileName(location);
  return new GenericDataFile(location, format, rowCount, file.getLength());
}
 
Example 6
Source File: DataFiles.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public static DataFile fromEncryptedOutputFile(EncryptedOutputFile encryptedFile, PartitionData partition,
                                              Metrics metrics, List<Long> splitOffsets) {
  EncryptionKeyMetadata keyMetadata = encryptedFile.keyMetadata();
  InputFile file = encryptedFile.encryptingOutputFile().toInputFile();
  if (encryptedFile instanceof HadoopInputFile) {
    return fromStat(((HadoopInputFile) file).getStat(), partition, metrics, keyMetadata, splitOffsets);
  }

  String location = file.location();
  FileFormat format = FileFormat.fromFileName(location);
  return new GenericDataFile(
      location, format, partition, file.getLength(), metrics, keyMetadata.buffer(), splitOffsets);
}
 
Example 7
Source File: DataFiles.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public Builder withInputFile(InputFile file) {
  if (file instanceof HadoopInputFile) {
    return withStatus(((HadoopInputFile) file).getStat());
  }

  this.filePath = file.location();
  this.fileSizeInBytes = file.getLength();
  return this;
}
 
Example 8
Source File: DataFiles.java    From iceberg with Apache License 2.0 4 votes vote down vote up
public static DataFile fromManifestList(InputFile manifestList) {
  return new GenericDataFile(manifestList.location(), FileFormat.AVRO, 1, manifestList.getLength());
}