use of org.apache.kudu.client.Upsert in project presto by prestodb.
the class SchemaEmulationByTableNameConvention method createSchema.
@Override
public void createSchema(KuduClient client, String schemaName) {
if (DEFAULT_SCHEMA.equals(schemaName)) {
throw new SchemaAlreadyExistsException(schemaName);
} else {
try {
KuduTable schemasTable = getSchemasTable(client);
KuduSession session = client.newSession();
try {
Upsert upsert = schemasTable.newUpsert();
upsert.getRow().addString(0, schemaName);
session.apply(upsert);
} finally {
session.close();
}
} catch (KuduException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
}
use of org.apache.kudu.client.Upsert in project presto by prestodb.
the class KuduPageSink method appendPage.
@Override
public CompletableFuture<?> appendPage(Page page) {
for (int position = 0; position < page.getPositionCount(); position++) {
Upsert upsert = table.newUpsert();
PartialRow row = upsert.getRow();
int start = 0;
if (generateUUID) {
String id = String.format("%s-%08x", uuid, nextSubId++);
row.addString(0, id);
start = 1;
}
for (int channel = 0; channel < page.getChannelCount(); channel++) {
appendColumn(row, page, position, channel, channel + start);
}
try {
session.apply(upsert);
} catch (KuduException e) {
throw new RuntimeException(e);
}
}
return NOT_BLOCKED;
}
Aggregations