本文整理汇总了Java中org.apache.accumulo.core.data.Mutation.putDelete方法的典型用法代码示例。如果您正苦于以下问题:Java Mutation.putDelete方法的具体用法?Java Mutation.putDelete怎么用?Java Mutation.putDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.data.Mutation
的用法示例。
在下文中一共展示了Mutation.putDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alterElementVisibility
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
public boolean alterElementVisibility(Mutation m, AccumuloElement element, Visibility newVisibility) {
ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(element.getVisibility());
ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility);
if (currentColumnVisibility.equals(newColumnVisibility)) {
return false;
}
if (element instanceof AccumuloEdge) {
AccumuloEdge edge = (AccumuloEdge) element;
m.putDelete(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), currentColumnVisibility, currentTimeMillis());
m.put(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
m.putDelete(AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), currentColumnVisibility, currentTimeMillis());
m.put(AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
m.putDelete(AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), currentColumnVisibility, currentTimeMillis());
m.put(AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
} else if (element instanceof AccumuloVertex) {
m.putDelete(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, currentColumnVisibility, currentTimeMillis());
m.put(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
} else {
throw new IllegalArgumentException("Invalid element type: " + element);
}
return true;
}
示例2: createEntries
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws Exception {
if (opts.createEntries || opts.deleteEntries) {
BatchWriterConfig cfg = new BatchWriterConfig();
cfg.setDurability(opts.durability);
BatchWriter writer = new SignedBatchWriter(conn, opts.getTableName(), cfg, opts.signatureConfig, opts.signatureKeys);
ColumnVisibility cv = new ColumnVisibility(opts.auths.toString().replace(',', '|'));
Text cf = new Text("datatypes");
Text cq = new Text("xml");
byte[] row = {'h', 'e', 'l', 'l', 'o', '\0'};
byte[] value = {'w', 'o', 'r', 'l', 'd', '\0'};
for (int i = 0; i < 10; i++) {
row[row.length - 1] = (byte) i;
Mutation m = new Mutation(new Text(row));
if (opts.deleteEntries) {
m.putDelete(cf, cq, cv);
}
if (opts.createEntries) {
value[value.length - 1] = (byte) i;
m.put(cf, cq, cv, new Value(value));
}
writer.addMutation(m);
}
writer.close();
}
}
示例3: createEntries
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws Exception {
if (opts.createEntries || opts.deleteEntries) {
BatchWriterConfig cfg = new BatchWriterConfig();
cfg.setDurability(opts.durability);
BatchWriter writer = new EncryptedBatchWriter(conn, opts.getTableName(), cfg, opts.encryptionConfig, opts.encryptionKeys);
ColumnVisibility cv = new ColumnVisibility(opts.auths.toString().replace(',', '|'));
Text cf = new Text("datatypes");
Text cq = new Text("xml");
byte[] row = {'h', 'e', 'l', 'l', 'o', '\0'};
byte[] value = {'w', 'o', 'r', 'l', 'd', '\0'};
for (int i = 0; i < 10; i++) {
row[row.length - 1] = (byte) i;
Mutation m = new Mutation(new Text(row));
if (opts.deleteEntries) {
m.putDelete(cf, cq, cv);
}
if (opts.createEntries) {
value[value.length - 1] = (byte) i;
m.put(cf, cq, cv, new Value(value));
}
writer.addMutation(m);
}
writer.close();
}
}
示例4: change
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
public void change(EncryptionConfig config) throws Exception {
Random random = new Random();
List<Entry<Key,Value>> entries = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
byte[] bytes = new byte[32 * 4];
random.nextBytes(bytes);
entries.add(new AbstractMap.SimpleImmutableEntry<>(new Key(Arrays.copyOfRange(bytes, 0, 32), Arrays.copyOfRange(bytes, 32, 64), Arrays.copyOfRange(bytes,
64, 96), "secret".getBytes(VISIBILITY_CHARSET), (long) 0, false), new Value(Arrays.copyOfRange(bytes, 96, 128))));
}
// Write the entries to Accumulo.
BatchWriter writer = AccumuloInstance.getConnector(USER).createBatchWriter(UNENCRYPTED_TEST_TABLE, null);
BatchWriter encryptedWriter = new EncryptedBatchWriter(AccumuloInstance.getConnector(USER), ENCRYPTED_TEST_TABLE, null, config,
AccumuloInstance.getUser(USER).encryptionKeys);
for (Entry<Key,Value> entry : entries) {
Key key = entry.getKey();
Mutation mutation = new Mutation(entry.getKey().getRow());
if (key.isDeleted()) {
mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(), key.getColumnVisibilityParsed(), key.getTimestamp());
} else {
mutation.put(key.getColumnFamily(), key.getColumnQualifier(), key.getColumnVisibilityParsed(), key.getTimestamp(), entry.getValue());
}
writer.addMutation(mutation);
encryptedWriter.addMutation(mutation);
}
writer.close();
encryptedWriter.close();
}
示例5: addMutation
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
* Signs the given mutation and then write it to Accumulo.
*
* @param mutation
* The mutation to sign.
*/
@Override
public void addMutation(Mutation mutation) throws MutationsRejectedException {
Mutation signedMutation = new Mutation(mutation.getRow());
// Sign the entries.
for (ColumnUpdate update : mutation.getUpdates()) {
if (update.isDeleted()) {
if (signatureConfig.destination == Destination.COLUMN_VISIBILITY) {
throw new IllegalArgumentException("cannot delete entries when the signature is stored in the column visibility");
}
if (update.hasTimestamp()) {
signedMutation.putDelete(update.getColumnFamily(), update.getColumnQualifier(), new ColumnVisibility(update.getColumnVisibility()),
update.getTimestamp());
} else {
signedMutation.putDelete(update.getColumnFamily(), update.getColumnQualifier(), new ColumnVisibility(update.getColumnVisibility()));
}
} else {
Entry<Key,Value> signedEntry = signer.sign(new MutableEntry(mutation.getRow(), update).toEntry(), update.hasTimestamp());
Key signedKey = signedEntry.getKey();
if (update.hasTimestamp()) {
signedMutation.put(signedKey.getColumnFamily(), signedKey.getColumnQualifier(), signedKey.getColumnVisibilityParsed(), signedKey.getTimestamp(),
signedEntry.getValue());
} else {
signedMutation.put(signedKey.getColumnFamily(), signedKey.getColumnQualifier(), signedKey.getColumnVisibilityParsed(), signedEntry.getValue());
}
}
}
// Write the signed mutations.
if (signatureTableWriter != null) {
tableWriter.addMutation(mutation);
signatureTableWriter.addMutation(signedMutation);
} else {
tableWriter.addMutation(signedMutation);
}
}
示例6: deleteTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void deleteTest() throws Exception {
when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS));
Mutation mutation = new Mutation("row".getBytes());
mutation.putDelete("colF".getBytes(), "colQ".getBytes());
mutation.putDelete("colF".getBytes(), "colQ".getBytes(), 0L);
writer.addMutation(mutation);
verify(mockWriter).addMutation(captor.capture());
verify(mockSignatureWriter, never()).addMutation(any());
List<Mutation> mutations = captor.getAllValues();
assertThat("only a single mutation", mutations, iterableWithSize(1));
Mutation signed = mutations.get(0);
assertThat("row is unchanged", signed.getRow(), equalTo("row".getBytes()));
List<ColumnUpdate> updates = signed.getUpdates();
assertThat("has 2 updates", updates, hasSize(2));
ColumnUpdate update = updates.get(0);
assertThat("is delete operation", update.isDeleted(), is(true));
assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
assertThat("timestamp is not set", update.hasTimestamp(), is(false));
update = updates.get(1);
assertThat("is delete operation", update.isDeleted(), is(true));
assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
assertThat("timestamp is set", update.hasTimestamp(), is(true));
assertThat("timestamp is correct", update.getTimestamp(), is(0L));
}
示例7: deleteColVisTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void deleteColVisTest() throws Exception {
when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config2.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS));
Mutation mutation = new Mutation("row".getBytes());
mutation.putDelete("colF1".getBytes(), "colQ".getBytes());
mutation.putDelete("colF1".getBytes(), "colQ".getBytes(), 0L);
try {
writer.addMutation(mutation);
fail("signed deletes are not allowed");
} catch (IllegalArgumentException e) { /* expected */}
}
示例8: deleteTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void deleteTest() throws Exception {
when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-entry.ini"), KEYS);
Mutation mutation = new Mutation("row".getBytes());
mutation.putDelete("colF1".getBytes(), "colQ".getBytes());
try {
writer.addMutation(mutation);
fail("encrypted deletes are not allowed on non-deterministically encrypted data");
} catch (IllegalArgumentException e) { /* expected */}
}
示例9: deleteDeterministicTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void deleteDeterministicTest() throws Exception {
when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("deterministic.ini"), KEYS);
Mutation mutation = new Mutation("row".getBytes());
mutation.putDelete("colF1".getBytes(), "colQ".getBytes());
mutation.putDelete("colF2".getBytes(), "colQ".getBytes(), 0);
writer.addMutation(mutation);
verify(mockWriter, times(4)).addMutation(captor.capture());
Iterable<Mutation> mutations = captor.getAllValues();
assertThat("should have 4 mutations", mutations, iterableWithSize(4));
}
示例10: createEntries
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws Exception {
if (opts.createEntries || opts.deleteEntries) {
BatchWriterConfig cfg = new BatchWriterConfig();
cfg.setDurability(opts.durability);
BatchWriter writer = conn.createBatchWriter(opts.getTableName(), cfg);
ColumnVisibility cv = new ColumnVisibility(opts.auths.toString().replace(',', '|'));
Text cf = new Text("datatypes");
Text cq = new Text("xml");
byte[] row = {'h', 'e', 'l', 'l', 'o', '\0'};
byte[] value = {'w', 'o', 'r', 'l', 'd', '\0'};
for (int i = 0; i < 10; i++) {
row[row.length - 1] = (byte) i;
Mutation m = new Mutation(new Text(row));
if (opts.deleteEntries) {
m.putDelete(cf, cq, cv);
}
if (opts.createEntries) {
value[value.length - 1] = (byte) i;
m.put(cf, cq, cv, new Value(value));
}
writer.addMutation(m);
}
writer.close();
}
}
示例11: generateMutations
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
* Generates Accumulo mutations from a Transaction log. Used to Replicate Fluo table to Accumulo.
*
* @param txLog Transaction log
* @param seq Export sequence number
* @param consumer generated mutations will be output to this consumer
*/
public static void generateMutations(long seq, TxLog txLog, Consumer<Mutation> consumer) {
Map<Bytes, Mutation> mutationMap = new HashMap<>();
for (LogEntry le : txLog.getLogEntries()) {
LogEntry.Operation op = le.getOp();
Column col = le.getColumn();
byte[] cf = col.getFamily().toArray();
byte[] cq = col.getQualifier().toArray();
byte[] cv = col.getVisibility().toArray();
if (op.equals(LogEntry.Operation.DELETE) || op.equals(LogEntry.Operation.SET)) {
Mutation m = mutationMap.computeIfAbsent(le.getRow(), k -> new Mutation(k.toArray()));
if (op.equals(LogEntry.Operation.DELETE)) {
if (col.isVisibilitySet()) {
m.putDelete(cf, cq, new ColumnVisibility(cv), seq);
} else {
m.putDelete(cf, cq, seq);
}
} else {
if (col.isVisibilitySet()) {
m.put(cf, cq, new ColumnVisibility(cv), seq, le.getValue().toArray());
} else {
m.put(cf, cq, seq, le.getValue().toArray());
}
}
}
}
mutationMap.values().forEach(consumer);
}
示例12: deleteEdge
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public void deleteEdge(Edge edge, Authorizations authorizations) {
checkNotNull(edge);
Span trace = Trace.start("deleteEdge");
trace.data("edgeId", edge.getId());
try {
getSearchIndex().deleteElement(this, edge, authorizations);
ColumnVisibility visibility = visibilityToAccumuloVisibility(edge.getVisibility());
Mutation outMutation = new Mutation(edge.getVertexId(Direction.OUT));
outMutation.putDelete(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), visibility);
Mutation inMutation = new Mutation(edge.getVertexId(Direction.IN));
inMutation.putDelete(AccumuloVertex.CF_IN_EDGE, new Text(edge.getId()), visibility);
addMutations(VertexiumObjectType.VERTEX, outMutation, inMutation);
deleteAllExtendedDataForElement(edge, authorizations);
// Deletes everything else related to edge.
addMutations(VertexiumObjectType.EDGE, getDeleteRowMutation(edge.getId()));
if (hasEventListeners()) {
queueEvent(new DeleteEdgeEvent(this, edge));
}
} finally {
trace.stop();
}
}
示例13: performDelete
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private void performDelete(Delete delete) throws TableNotFoundException, MutationsRejectedException, TranslatorException {
if (delete.getParameterValues() != null) {
throw new TranslatorException(AccumuloPlugin.Event.TEIID19005, AccumuloPlugin.Util.gs(AccumuloPlugin.Event.TEIID19005));
}
Table table = delete.getTable().getMetadataObject();
AccumuloQueryVisitor visitor = new AccumuloQueryVisitor(this.aef);
visitor.visitNode(delete.getWhere());
if (!visitor.exceptions.isEmpty()) {
throw visitor.exceptions.get(0);
}
/*
// To get the update count I am taking longer route..
Connector connector = this.connection.getInstance();
BatchDeleter deleter = connector.createBatchDeleter(SQLStringVisitor.getRecordName(table), auths, this.aef.getQueryThreadsCount(), new BatchWriterConfig());
deleter.setRanges(visitor.getRanges());
deleter.delete();
deleter.close();
*/
Text prevRow = null;
Connector connector = this.connection.getInstance();
BatchWriter writer = createBatchWriter(table, connector);
Iterator<Entry<Key,Value>> results = AccumuloQueryExecution.runQuery(this.aef, this.connection.getInstance(), this.connection.getAuthorizations(), visitor.getRanges(), table, null);
while (results.hasNext()) {
Key key = results.next().getKey();
Text rowId = key.getRow();
if (prevRow == null || !prevRow.equals(rowId)) {
this.updateCount++;
}
prevRow = rowId;
Mutation mutation = new Mutation(rowId);
mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier());
writer.addMutation(mutation);
}
writer.close();
}
示例14: createMutationForEdgeBuilder
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private Mutation createMutationForEdgeBuilder(AccumuloGraph graph, EdgeBuilderBase edgeBuilder, ColumnVisibility edgeColumnVisibility, long timestamp) {
String edgeRowKey = edgeBuilder.getElementId();
Mutation m = new Mutation(edgeRowKey);
String edgeLabel = edgeBuilder.getLabel();
if (edgeBuilder.getNewEdgeLabel() != null) {
edgeLabel = edgeBuilder.getNewEdgeLabel();
m.putDelete(AccumuloEdge.CF_SIGNAL, new Text(edgeBuilder.getLabel()), edgeColumnVisibility, currentTimeMillis());
}
m.put(AccumuloEdge.CF_SIGNAL, new Text(edgeLabel), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
m.put(AccumuloEdge.CF_OUT_VERTEX, new Text(edgeBuilder.getOutVertexId()), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
m.put(AccumuloEdge.CF_IN_VERTEX, new Text(edgeBuilder.getInVertexId()), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
createMutationForElementBuilder(graph, edgeBuilder, edgeRowKey, m);
return m;
}
示例15: createAlterEdgeLabelMutation
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private Mutation createAlterEdgeLabelMutation(Edge edge, String newEdgeLabel, ColumnVisibility edgeColumnVisibility) {
String edgeRowKey = edge.getId();
Mutation m = new Mutation(edgeRowKey);
m.putDelete(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), edgeColumnVisibility, currentTimeMillis());
m.put(AccumuloEdge.CF_SIGNAL, new Text(newEdgeLabel), edgeColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
return m;
}