use of com.nearinfinity.honeycomb.Table in project honeycomb by altamiracorp.
the class HandlerProxy method dropTable.
/**
* Drop the table with the given specifications. The table is not open when
* this is called.
*
* @param tableName Name of the table to be dropped
*/
public void dropTable(String tableName) {
Verify.isNotNullOrEmpty(tableName);
Store store = storeFactory.createStore(tableName);
Table table = store.openTable(tableName);
table.deleteAllRows();
Util.closeQuietly(table);
store.deleteTable(tableName);
}
use of com.nearinfinity.honeycomb.Table 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