use of com.nearinfinity.honeycomb.Scanner in project honeycomb by altamiracorp.
the class HBaseTable method insertTableIndex.
@Override
public void insertTableIndex(final IndexSchema indexSchema) {
checkNotNull(indexSchema, "The index schema is invalid");
final Collection<IndexSchema> indices = ImmutableList.of(indexSchema);
final Scanner scanner = tableScan();
while (scanner.hasNext()) {
HBaseOperations.performPut(hTable, mutationFactory.insertIndices(tableId, Row.deserialize(scanner.next()), indices));
}
Util.closeQuietly(scanner);
}
use of com.nearinfinity.honeycomb.Scanner in project honeycomb by altamiracorp.
the class HandlerProxy method indexContainsDuplicate.
/**
* Check whether the index contains a row with the same field values and a
* distinct UUID.
*
* @param indexName
* @param serializedRow
* @return True If a duplicate is found, False otherwise
*/
public boolean indexContainsDuplicate(String indexName, byte[] serializedRow) {
// This method must get its own table because it may be called during
// a full table scan.
Verify.isNotNullOrEmpty(indexName);
checkNotNull(serializedRow);
Row row = Row.deserialize(serializedRow);
Table t = store.openTable(tableName);
TableSchema schema = store.getSchema(tableName);
IndexSchema indexSchema = schema.getIndexSchema(indexName);
QueryKey key = new QueryKey(indexName, QueryType.EXACT_KEY, row.getRecords());
Scanner scanner = t.indexScanExact(key);
try {
while (scanner.hasNext()) {
Row next = Row.deserialize(scanner.next());
if (!next.getUUID().equals(row.getUUID())) {
// Special case for inserting nulls
for (String column : indexSchema.getColumns()) {
boolean isNullInRecord = !row.getRecords().containsKey(column);
if (isNullInRecord) {
return false;
}
}
return true;
}
}
return false;
} finally {
Util.closeQuietly(scanner);
Util.closeQuietly(t);
}
}
Aggregations