use of com.thinkaurelius.titan.diskstorage.StaticBuffer in project titan by thinkaurelius.
the class HBaseKeyColumnValueStore method makeDeletionCommand.
/**
* Convert deletions to a Delete command.
*
* @param cfName The name of the ColumnFamily deletions belong to
* @param key The row key
* @param deletions The name of the columns to delete (a.k.a deletions)
* @return Delete command or null if deletions were null or empty.
*/
private static Delete makeDeletionCommand(byte[] cfName, byte[] key, List<StaticBuffer> deletions) {
Preconditions.checkArgument(!deletions.isEmpty());
Delete deleteCommand = new Delete(key);
for (StaticBuffer del : deletions) {
deleteCommand.deleteColumn(cfName, del.as(StaticBuffer.ARRAY_FACTORY));
}
return deleteCommand;
}
use of com.thinkaurelius.titan.diskstorage.StaticBuffer in project titan by thinkaurelius.
the class HBaseStoreManager method convertToCommands.
/**
* Convert Titan internal Mutation representation into HBase native commands.
*
* @param mutations Mutations to convert into HBase commands.
* @param putTimestamp The timestamp to use for Put commands.
* @param delTimestamp The timestamp to use for Delete commands.
* @return Commands sorted by key converted from Titan internal representation.
* @throws PermanentStorageException
*/
private Map<StaticBuffer, Pair<Put, Delete>> convertToCommands(Map<String, Map<StaticBuffer, KCVMutation>> mutations, final long putTimestamp, final long delTimestamp) throws PermanentStorageException {
Map<StaticBuffer, Pair<Put, Delete>> commandsPerKey = new HashMap<StaticBuffer, Pair<Put, Delete>>();
for (Map.Entry<String, Map<StaticBuffer, KCVMutation>> entry : mutations.entrySet()) {
String cfString = getCfNameForStoreName(entry.getKey());
byte[] cfName = cfString.getBytes();
for (Map.Entry<StaticBuffer, KCVMutation> m : entry.getValue().entrySet()) {
StaticBuffer key = m.getKey();
KCVMutation mutation = m.getValue();
Pair<Put, Delete> commands = commandsPerKey.get(key);
if (commands == null) {
commands = new Pair<Put, Delete>();
commandsPerKey.put(key, commands);
}
if (mutation.hasDeletions()) {
if (commands.getSecond() == null)
commands.setSecond(new Delete(key.as(StaticBuffer.ARRAY_FACTORY), delTimestamp, null));
for (StaticBuffer b : mutation.getDeletions()) {
commands.getSecond().deleteColumns(cfName, b.as(StaticBuffer.ARRAY_FACTORY), delTimestamp);
}
}
if (mutation.hasAdditions()) {
if (commands.getFirst() == null)
commands.setFirst(new Put(key.as(StaticBuffer.ARRAY_FACTORY), putTimestamp));
for (Entry e : mutation.getAdditions()) {
commands.getFirst().add(cfName, e.getArrayColumn(), putTimestamp, e.getArrayValue());
}
}
}
}
return commandsPerKey;
}
Aggregations