Skip to content

Commit

Permalink
Merge pull request #73 from nineinchnick/stream-record-set
Browse files Browse the repository at this point in the history
Iterable for record set
  • Loading branch information
nineinchnick committed Jul 8, 2021
2 parents 4ede777 + 7ac02fe commit 4d5cf4b
Show file tree
Hide file tree
Showing 21 changed files with 167 additions and 137 deletions.
3 changes: 1 addition & 2 deletions trino-rest-base/src/main/java/pl/net/was/rest/Rest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import io.trino.spi.statistics.TableStatistics;
import io.trino.spi.type.Type;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -61,7 +60,7 @@ default List<SchemaTableName> listTables()

Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(SchemaTablePrefix schemaTablePrefix);

Collection<? extends List<?>> getRows(RestTableHandle table);
Iterable<List<?>> getRows(RestTableHandle table);

Consumer<List> createRowSink(SchemaTableName schemaTableName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package pl.net.was.rest;

import com.google.common.collect.Iterables;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.connector.ConnectorRecordSetProvider;
Expand All @@ -28,7 +29,6 @@

import javax.inject.Inject;

import java.util.Collection;
import java.util.List;

import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -60,7 +60,7 @@ public RecordSet getRecordSet(

// use the split's table handle, since
RestTableHandle restTable = split.getTableHandle();
Collection<? extends List<?>> rows = rest.getRows(restTable);
Iterable<List<?>> rows = rest.getRows(restTable);
ConnectorTableMetadata tableMetadata = rest.getTableMetadata(restTable.getSchemaTableName());

List<Integer> columnIndexes = restColumnHandles
Expand All @@ -77,13 +77,11 @@ public RecordSet getRecordSet(
})
.collect(toList());

Collection<? extends List<?>> mappedRows = rows
//noinspection StaticPseudoFunctionalStyleMethod
Iterable<List<?>> mappedRows = Iterables.transform(rows, row -> columnIndexes
.stream()
.map(row -> columnIndexes
.stream()
.map(row::get)
.collect(toList()))
.collect(toList());
.map(row::get)
.collect(toList()));

List<Type> mappedTypes = restColumnHandles
.stream()
Expand Down
Loading

0 comments on commit 4d5cf4b

Please sign in to comment.