use of io.airlift.tpch.NationColumn in project hetu-core by openlookeng.
the class TestOrcAcidPageSource method readFile.
private static List<Nation> readFile(Map<NationColumn, Integer> columns, TupleDomain<HiveColumnHandle> tupleDomain, Optional<DeleteDeltaLocations> deleteDeltaLocations) {
List<HiveColumnHandle> columnHandles = columns.entrySet().stream().map(column -> toHiveColumnHandle(column.getKey(), column.getValue())).collect(toImmutableList());
List<String> columnNames = columnHandles.stream().map(HiveColumnHandle::getName).collect(toImmutableList());
// This file has the contains the TPC-H nation table which each row repeated 1000 times
File nationFileWithReplicatedRows = new File(TestOrcAcidPageSource.class.getClassLoader().getResource("nationFile25kRowsSortedOnNationKey/bucket_00000").getPath());
ConnectorPageSource pageSource = PAGE_SOURCE_FACTORY.createPageSource(new JobConf(new Configuration(false)), HiveTestUtils.SESSION, new Path(nationFileWithReplicatedRows.getAbsoluteFile().toURI()), 0, nationFileWithReplicatedRows.length(), nationFileWithReplicatedRows.length(), createSchema(), columnHandles, tupleDomain, Optional.empty(), deleteDeltaLocations, Optional.empty(), Optional.empty(), null, false, -1L).get();
int nationKeyColumn = columnNames.indexOf("n_nationkey");
int nameColumn = columnNames.indexOf("n_name");
int regionKeyColumn = columnNames.indexOf("n_regionkey");
int commentColumn = columnNames.indexOf("n_comment");
ImmutableList.Builder<Nation> rows = ImmutableList.builder();
while (!pageSource.isFinished()) {
Page page = pageSource.getNextPage();
if (page == null) {
continue;
}
page = page.getLoadedPage();
for (int position = 0; position < page.getPositionCount(); position++) {
long nationKey = -42;
if (nationKeyColumn >= 0) {
nationKey = BIGINT.getLong(page.getBlock(nationKeyColumn), position);
}
String name = "<not read>";
if (nameColumn >= 0) {
name = VARCHAR.getSlice(page.getBlock(nameColumn), position).toStringUtf8();
}
long regionKey = -42;
if (regionKeyColumn >= 0) {
regionKey = BIGINT.getLong(page.getBlock(regionKeyColumn), position);
}
String comment = "<not read>";
if (commentColumn >= 0) {
comment = VARCHAR.getSlice(page.getBlock(commentColumn), position).toStringUtf8();
}
rows.add(new Nation(position, nationKey, name, regionKey, comment));
}
}
return rows.build();
}
use of io.airlift.tpch.NationColumn in project boostkit-bigdata by kunpengcompute.
the class TestOrcAcidPageSource method readFile.
private static List<Nation> readFile(Map<NationColumn, Integer> columns, TupleDomain<HiveColumnHandle> tupleDomain, Optional<DeleteDeltaLocations> deleteDeltaLocations) {
List<HiveColumnHandle> columnHandles = columns.entrySet().stream().map(column -> toHiveColumnHandle(column.getKey(), column.getValue())).collect(toImmutableList());
List<String> columnNames = columnHandles.stream().map(HiveColumnHandle::getName).collect(toImmutableList());
// This file has the contains the TPC-H nation table which each row repeated 1000 times
File nationFileWithReplicatedRows = new File(TestOrcAcidPageSource.class.getClassLoader().getResource("nationFile25kRowsSortedOnNationKey/bucket_00000").getPath());
ConnectorPageSource pageSource = PAGE_SOURCE_FACTORY.createPageSource(new JobConf(new Configuration(false)), HiveTestUtils.SESSION, new Path(nationFileWithReplicatedRows.getAbsoluteFile().toURI()), 0, nationFileWithReplicatedRows.length(), nationFileWithReplicatedRows.length(), createSchema(), columnHandles, tupleDomain, Optional.empty(), deleteDeltaLocations, Optional.empty(), Optional.empty(), null, false, -1L).get();
int nationKeyColumn = columnNames.indexOf("n_nationkey");
int nameColumn = columnNames.indexOf("n_name");
int regionKeyColumn = columnNames.indexOf("n_regionkey");
int commentColumn = columnNames.indexOf("n_comment");
ImmutableList.Builder<Nation> rows = ImmutableList.builder();
while (!pageSource.isFinished()) {
Page page = pageSource.getNextPage();
if (page == null) {
continue;
}
page = page.getLoadedPage();
for (int position = 0; position < page.getPositionCount(); position++) {
long nationKey = -42;
if (nationKeyColumn >= 0) {
nationKey = BIGINT.getLong(page.getBlock(nationKeyColumn), position);
}
String name = "<not read>";
if (nameColumn >= 0) {
name = VARCHAR.getSlice(page.getBlock(nameColumn), position).toStringUtf8();
}
long regionKey = -42;
if (regionKeyColumn >= 0) {
regionKey = BIGINT.getLong(page.getBlock(regionKeyColumn), position);
}
String comment = "<not read>";
if (commentColumn >= 0) {
comment = VARCHAR.getSlice(page.getBlock(commentColumn), position).toStringUtf8();
}
rows.add(new Nation(position, nationKey, name, regionKey, comment));
}
}
return rows.build();
}
Aggregations