use of com.facebook.presto.accumulo.model.Row in project presto by prestodb.
the class AccumuloPageSink method appendPage.
@Override
public CompletableFuture<?> appendPage(Page page) {
// For each position within the page, i.e. row
for (int position = 0; position < page.getPositionCount(); ++position) {
Row row = new Row();
// For each channel within the page, i.e. column
for (int channel = 0; channel < page.getChannelCount(); ++channel) {
// Get the type for this channel
Type type = columns.get(channel).getType();
// Read the value from the page and append the field to the row
row.addField(TypeUtils.readNativeValue(type, page.getBlock(channel), position), type);
}
try {
// Convert row to a Mutation, writing and indexing it
Mutation mutation = toMutation(row, rowIdOrdinal, columns, serializer);
writer.addMutation(mutation);
if (indexer.isPresent()) {
indexer.get().index(mutation);
}
++numRows;
} catch (MutationsRejectedException e) {
throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Mutation rejected by server", e);
}
// TODO Fix arbitrary flush every 100k rows
if (numRows % 100_000 == 0) {
flush();
}
}
return NOT_BLOCKED;
}
Aggregations