use of org.apache.kudu.client.Update in project gora by apache.
the class KuduStore method deleteByQuery.
@Override
public long deleteByQuery(Query<K, T> query) throws GoraException {
try {
long count = 0;
Column pkc = kuduMapping.getPrimaryKey().get(0);
ColumnSchema column = table.getSchema().getColumn(pkc.getName());
List<String> dbFields = new ArrayList<>();
dbFields.add(pkc.getName());
List<KuduPredicate> rangePredicates = KuduClientUtils.createRangePredicate(column, query.getStartKey(), query.getEndKey());
rangePredicates.add(KuduPredicate.newIsNotNullPredicate(column));
KuduScanner build = createScanner(rangePredicates, dbFields, query.getLimit());
while (build.hasMoreRows()) {
RowResultIterator nextRows = build.nextRows();
for (RowResult it : nextRows) {
count++;
K key = (K) KuduClientUtils.getObjectRow(it, pkc);
if (query.getFields() != null && query.getFields().length < kuduMapping.getFields().size()) {
Update updateOp = table.newUpdate();
PartialRow row = updateOp.getRow();
String[] avFields = getFieldsToQuery(query.getFields());
KuduClientUtils.addObjectRow(row, pkc, key);
for (String af : avFields) {
row.setNull(kuduMapping.getFields().get(af).getName());
}
session.apply(updateOp);
} else {
delete(key);
}
}
}
build.close();
return count;
} catch (Exception e) {
throw new GoraException(e);
}
}
use of org.apache.kudu.client.Update in project apex-malhar by apache.
the class AbstractKuduOutputOperator method processForUpdate.
protected void processForUpdate(KuduExecutionContext kuduExecutionContext) {
Update thisUpdate = kuduTable.newUpdate();
performCommonProcessing(thisUpdate, kuduExecutionContext);
}
Aggregations