use of org.apache.accumulo.core.data.Value in project hive by apache.
the class HiveAccumuloRecordReader method pushToValue.
// flatten key/value pairs into row object for use in Serde.
private void pushToValue(List<Key> keys, List<Value> values, AccumuloHiveRow row) throws IOException {
Iterator<Key> kIter = keys.iterator();
Iterator<Value> vIter = values.iterator();
while (kIter.hasNext()) {
Key k = kIter.next();
Value v = vIter.next();
row.add(k.getColumnFamily().toString(), k.getColumnQualifier().toString(), v.get());
}
}
use of org.apache.accumulo.core.data.Value in project presto by prestodb.
the class IndexLookup method getIndexRanges.
private List<Range> getIndexRanges(String indexTable, Multimap<AccumuloColumnConstraint, Range> constraintRanges, Collection<Range> rowIDRanges, Authorizations auths) throws TableNotFoundException {
Set<Range> finalRanges = null;
// For each column/constraint pair
for (Entry<AccumuloColumnConstraint, Collection<Range>> constraintEntry : constraintRanges.asMap().entrySet()) {
// Create a batch scanner against the index table, setting the ranges
BatchScanner scanner = connector.createBatchScanner(indexTable, auths, 10);
scanner.setRanges(constraintEntry.getValue());
// Fetch the column family for this specific column
Text family = new Text(Indexer.getIndexColumnFamily(constraintEntry.getKey().getFamily().getBytes(UTF_8), constraintEntry.getKey().getQualifier().getBytes(UTF_8)).array());
scanner.fetchColumnFamily(family);
// For each entry in the scanner
Text tmpQualifier = new Text();
Set<Range> columnRanges = new HashSet<>();
for (Entry<Key, Value> entry : scanner) {
entry.getKey().getColumnQualifier(tmpQualifier);
// Add to our column ranges if it is in one of the row ID ranges
if (inRange(tmpQualifier, rowIDRanges)) {
columnRanges.add(new Range(tmpQualifier));
}
}
LOG.debug("Retrieved %d ranges for column %s", columnRanges.size(), constraintEntry.getKey().getName());
// If finalRanges is null, we have not yet added any column ranges
if (finalRanges == null) {
finalRanges = new HashSet<>();
finalRanges.addAll(columnRanges);
} else {
// Retain only the row IDs for this column that have already been added
// This is your set intersection operation!
finalRanges.retainAll(columnRanges);
}
// Close the scanner
scanner.close();
}
// Return the final ranges for all constraint pairs
if (finalRanges != null) {
return ImmutableList.copyOf(finalRanges);
} else {
return ImmutableList.of();
}
}
use of org.apache.accumulo.core.data.Value in project presto by prestodb.
the class IndexLookup method getNumRowsInTable.
private long getNumRowsInTable(String metricsTable, Authorizations auths) throws TableNotFoundException {
// Create scanner against the metrics table, pulling the special column and the rows column
Scanner scanner = connector.createScanner(metricsTable, auths);
scanner.setRange(METRICS_TABLE_ROWID_RANGE);
scanner.fetchColumn(Indexer.METRICS_TABLE_ROWS_CF_AS_TEXT, Indexer.CARDINALITY_CQ_AS_TEXT);
// Scan the entry and get the number of rows
long numRows = -1;
for (Entry<Key, Value> entry : scanner) {
if (numRows > 0) {
throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Should have received only one entry when scanning for number of rows in metrics table");
}
numRows = Long.parseLong(entry.getValue().toString());
}
scanner.close();
LOG.debug("Number of rows in table is %d", numRows);
return numRows;
}
use of org.apache.accumulo.core.data.Value in project presto by prestodb.
the class AbstractTestAccumuloRowSerializer method deserializeData.
protected void deserializeData(AccumuloRowSerializer serializer, byte[] data) throws Exception {
Mutation m = new Mutation("row");
m.put(b("a"), b("a"), data);
Key key = new Key(b("row"), b("a"), b("b"), b(), 0, false);
Value value = new Value(data);
serializer.setMapping(COLUMN_NAME, "a", "b");
serializer.deserialize(new SimpleImmutableEntry<>(key, value));
}
use of org.apache.accumulo.core.data.Value in project YCSB by brianfrankcooper.
the class AccumuloClient method deleteRow.
/**
* Deletes a row, given a Scanner of JUST that row.
*/
private void deleteRow(Scanner scanner) throws MutationsRejectedException {
Mutation deleter = null;
// iterate through the keys
for (Entry<Key, Value> entry : scanner) {
// create a mutation for the row
if (deleter == null) {
deleter = new Mutation(entry.getKey().getRow());
}
// the remove function adds the key with the delete flag set to true
deleter.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier());
}
bw.addMutation(deleter);
}
Aggregations