use of io.trino.orc.OrcDataSourceId in project trino by trinodb.
the class SortingFileWriter method mergeFiles.
private void mergeFiles(Iterable<TempFile> files, Consumer<Page> consumer) {
try (Closer closer = Closer.create()) {
Collection<Iterator<Page>> iterators = new ArrayList<>();
for (TempFile tempFile : files) {
Path file = tempFile.getPath();
OrcDataSource dataSource = new HdfsOrcDataSource(new OrcDataSourceId(file.toString()), fileSystem.getFileStatus(file).getLen(), new OrcReaderOptions(), fileSystem.open(file), new FileFormatDataSourceStats());
closer.register(dataSource);
iterators.add(new TempFileReader(types, dataSource));
}
new MergingPageIterator(iterators, types, sortFields, sortOrders, typeOperators).forEachRemaining(consumer);
for (TempFile tempFile : files) {
Path file = tempFile.getPath();
if (!fileSystem.delete(file, false)) {
throw new IOException("Failed to delete temporary file: " + file);
}
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of io.trino.orc.OrcDataSourceId in project trino by trinodb.
the class TestLongDecode method assertVIntRoundTrip.
private static void assertVIntRoundTrip(SliceOutput output, long value, boolean signed) throws IOException {
// write using Hive's code
output.reset();
if (signed) {
writeVslong(output, value);
} else {
writeVulong(output, value);
}
Slice hiveBytes = Slices.copyOf(output.slice());
// write using Trino's code, and verify they are the same
output.reset();
writeVLong(output, value, signed);
Slice trinoBytes = Slices.copyOf(output.slice());
if (!trinoBytes.equals(hiveBytes)) {
assertEquals(trinoBytes, hiveBytes);
}
// read using Hive's code
if (signed) {
long readValueOld = readVslong(hiveBytes.getInput());
assertEquals(readValueOld, value);
} else {
long readValueOld = readVulong(hiveBytes.getInput());
assertEquals(readValueOld, value);
}
// read using Trino's code
long readValueNew = readVInt(signed, new OrcInputStream(OrcChunkLoader.create(new OrcDataSourceId("test"), hiveBytes, Optional.empty(), newSimpleAggregatedMemoryContext())));
assertEquals(readValueNew, value);
}
Aggregations