当前位置: 首页>>代码示例>>Java>>正文


Java Mutation.getUpdates方法代码示例

本文整理汇总了Java中org.apache.accumulo.core.data.Mutation.getUpdates方法的典型用法代码示例。如果您正苦于以下问题:Java Mutation.getUpdates方法的具体用法?Java Mutation.getUpdates怎么用?Java Mutation.getUpdates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.accumulo.core.data.Mutation的用法示例。


在下文中一共展示了Mutation.getUpdates方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public List<Short> check(Environment env, Mutation mutation) {
  Set<Short> violations = null;

  if (!isAlphaNum(mutation.getRow()))
    violations = addViolation(violations, NON_ALPHA_NUM_ROW);

  Collection<ColumnUpdate> updates = mutation.getUpdates();
  for (ColumnUpdate columnUpdate : updates) {
    if (!isAlphaNum(columnUpdate.getColumnFamily()))
      violations = addViolation(violations, NON_ALPHA_NUM_COLF);

    if (!isAlphaNum(columnUpdate.getColumnQualifier()))
      violations = addViolation(violations, NON_ALPHA_NUM_COLQ);
  }

  return null == violations ? null : new ArrayList<>(violations);
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:19,代码来源:AlphaNumKeyConstraint.java

示例2: write

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public void write(Text table, Mutation mutation) throws IOException, InterruptedException {
  TreeMap<Key,Value> buffer = getBuffer(table);
  int mutationSize = 0;
  for (ColumnUpdate update : mutation.getUpdates()) {
    Key k = new Key(mutation.getRow(), update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(), update.getTimestamp(),
        update.isDeleted());
    Value v = new Value(update.getValue());
    // TODO account for object overhead
    mutationSize += k.getSize();
    mutationSize += v.getSize();
    buffer.put(k, v);
  }
  size += mutationSize;
  long bufferSize = bufferSizes.get(table);
  
  // TODO use a MutableLong instead
  bufferSize += mutationSize;
  bufferSizes.put(table, bufferSize);
  
  while (size >= maxSize) {
    flushLargestTable();
  }
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:25,代码来源:BufferingRFileRecordWriter.java

示例3: 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);
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:45,代码来源:SignedBatchWriter.java

示例4: 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));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:36,代码来源:SignedBatchWriterTest.java

示例5: createTestData1

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
private void createTestData1() {
    List<Tag> tags = Collections.singletonList(new Tag("host", "host1"));

    for (long i = 0; i < 1000; i += 100) {
        Metric m = new Metric("sys.loadAvg", i, .2, tags);
        Mutation mutation = MetricAdapter.toMutation(m);
        for (ColumnUpdate cu : mutation.getUpdates()) {
            Key key = new Key(mutation.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(),
                    cu.getColumnVisibility(), cu.getTimestamp());
            testData1.put(key, new Value(cu.getValue()));
        }
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:14,代码来源:DownsampleIteratorTest.java

示例6: put

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
void put(Map<Key, Value> testData, Metric m) {
    Mutation mutation = MetricAdapter.toMutation(m);
    for (ColumnUpdate cu : mutation.getUpdates()) {
        Key key = new Key(mutation.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(),
                cu.getColumnVisibility(), cu.getTimestamp());
        testData.put(key, new Value(cu.getValue()));
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:9,代码来源:DownsampleIteratorTest.java

示例7: check

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public List<Short> check(Environment env, Mutation mutation) {
  Collection<ColumnUpdate> updates = mutation.getUpdates();

  for (ColumnUpdate columnUpdate : updates) {
    if (!isNumeric(columnUpdate.getValue()))
      return VIOLATION_LIST;
  }

  return null;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:12,代码来源:NumericValueConstraint.java

示例8: writeMutation

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
 * Writes a mutation to the specified table.  If the mutation is meant to delete then the mutation will
 * be transformed to a delete mutation.
 * @param table the table to write to.
 * @param mutation the {@link mutation}.
 * @param context the {@link Context}.
 * @param isDelete {@code true} if the mutation should be a delete mutation.  {@code false} otherwise.
 * @throws IOException
 * @throws InterruptedException
 */
private static void writeMutation(final Text table, final Mutation mutation, final Context context, final boolean isDelete) throws IOException, InterruptedException {
    if (isDelete) {
        final List<ColumnUpdate> updates = mutation.getUpdates();
        final ColumnUpdate columnUpdate = updates.get(0);
        final ColumnVisibility cv = columnUpdate.getColumnVisibility() != null ? new ColumnVisibility(columnUpdate.getColumnVisibility()) : null;
        final Mutation deleteMutation = new Mutation(new Text(mutation.getRow()));
        deleteMutation.putDelete(columnUpdate.getColumnFamily(), columnUpdate.getColumnQualifier(), cv, columnUpdate.getTimestamp());
        context.write(table, deleteMutation);
    } else {
        context.write(table, mutation);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:MergeToolMapper.java

示例9: addMutationValueTest

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationValueTest() 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));
  EntrySigner signer = new EntrySigner(getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS));

  Mutation mutation = new Mutation("row".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), "val1".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), 0, "val2".getBytes());
  writer.addMutation(mutation);

  verify(mockWriter).addMutation(captor.capture());
  verify(mockSignatureWriter, never()).addMutation(any());

  List<Mutation> mutations = captor.getAllValues();
  assertThat("only a single mutation", mutations, hasSize(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("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp not set", update.hasTimestamp(), is(false));
  assertThat("signature in value", update.getColumnFamily(), not(equalTo("val1".getBytes())));

  MutableEntry verified = new MutableEntry(signer.verify(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was correctly unwrapped", verified.value, equalTo("val1".getBytes()));

  update = updates.get(1);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
  assertThat("signature in value", update.getColumnFamily(), not(equalTo("val2".getBytes())));

  verified = new MutableEntry(signer.verify(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was correctly unwrapped", verified.value, equalTo("val2".getBytes()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:43,代码来源:SignedBatchWriterTest.java

示例10: addMutationColVisTest

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationColVisTest() 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));
  EntrySigner signer = new EntrySigner(getConfig("config2.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS));

  Mutation mutation = new Mutation("row".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), "val1".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), 0, "val2".getBytes());
  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("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
  assertThat("colQualifier has the default visibility", new String(update.getColumnVisibility(), Utils.VISIBILITY_CHARSET), startsWith("(default)"));
  assertThat("timestamp not set", update.hasTimestamp(), is(false));
  assertThat("value is unchanged", update.getValue(), equalTo("val1".getBytes()));

  MutableEntry verified = new MutableEntry(signer.verify(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was correctly unwrapped", verified.value, equalTo("val1".getBytes()));

  update = updates.get(1);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
  assertThat("colQualifier has the default visibility", new String(update.getColumnVisibility(), Utils.VISIBILITY_CHARSET), startsWith("(default)"));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
  assertThat("value is unchanged", update.getValue(), equalTo("val2".getBytes()));

  verified = new MutableEntry(signer.verify(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was correctly unwrapped", verified.value, equalTo("val2".getBytes()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:45,代码来源:SignedBatchWriterTest.java

示例11: addMutationSeparateTableTest

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationSeparateTableTest() throws Exception {
  when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
  when(mockConnector.createBatchWriter(SIG_TABLE, null)).thenReturn(mockSignatureWriter);

  BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config3.ini"), aliceKeyContainers.get(ValueSigner.ECDSA));
  EntrySigner signer = new EntrySigner(getConfig("config3.ini"), aliceKeyContainers.get(ValueSigner.ECDSA));

  Mutation mutation = new Mutation("row".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), "val1".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), 0, "val2".getBytes());
  writer.addMutation(mutation);

  verify(mockWriter).addMutation(captor.capture());
  verify(mockSignatureWriter).addMutation(signatureCaptor.capture());

  // Check entry
  List<Mutation> mutations = captor.getAllValues();
  assertThat("only a single mutation", mutations, hasSize(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("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp not set", update.hasTimestamp(), is(false));
  assertThat("value is unchanged", update.getValue(), equalTo("val1".getBytes()));

  update = updates.get(1);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
  assertThat("value is unchanged", update.getValue(), equalTo("val2".getBytes()));

  // Check signature.
  mutations = signatureCaptor.getAllValues();
  assertThat("only a single mutation", mutations, hasSize(1));

  signed = mutations.get(0);
  assertThat("row is unchanged", signed.getRow(), equalTo("row".getBytes()));

  updates = signed.getUpdates();
  assertThat("has 2 updates", updates, hasSize(2));

  update = updates.get(0);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp not set", update.hasTimestamp(), is(false));
  assertThat("signature in value", update.getColumnFamily(), not(equalTo("val1".getBytes())));

  update = updates.get(1);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
  assertThat("signature in value", update.getColumnFamily(), not(equalTo("val2".getBytes())));

  // Verify unwrapping of entry.
  MutableEntry verified = new MutableEntry(signer.verify(new MutableEntry("row".getBytes(), captor.getAllValues().get(0).getUpdates().get(0)).toEntry(),
      new MutableEntry("row".getBytes(), signatureCaptor.getAllValues().get(0).getUpdates().get(0)).toEntry()));
  assertThat("value was correctly unwrapped", verified.value, equalTo("val1".getBytes()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:68,代码来源:SignedBatchWriterTest.java

示例12: deleteExternalTest

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void deleteExternalTest() throws Exception {
  when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
  when(mockConnector.createBatchWriter(SIG_TABLE, null)).thenReturn(mockSignatureWriter);

  BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config3.ini"), aliceKeyContainers.get(ValueSigner.ECDSA));

  Mutation mutation = new Mutation("row".getBytes());
  mutation.putDelete("colF".getBytes(), "colQ".getBytes());
  mutation.putDelete("colF".getBytes(), "colQ".getBytes(), 0);
  writer.addMutation(mutation);

  verify(mockWriter).addMutation(captor.capture());
  verify(mockSignatureWriter).addMutation(signatureCaptor.capture());

  // Check entry
  List<Mutation> mutations = captor.getAllValues();
  assertThat("only a single mutation", mutations, hasSize(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.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp 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.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));

  // Check signature.
  mutations = signatureCaptor.getAllValues();
  assertThat("only a single mutation", mutations, hasSize(1));

  signed = mutations.get(0);
  assertThat("row is unchanged", signed.getRow(), equalTo("row".getBytes()));

  updates = signed.getUpdates();
  assertThat("has 2 updates", updates, hasSize(2));

  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.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp 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.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:62,代码来源:SignedBatchWriterTest.java

示例13: addMutationTest

import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationTest() throws Exception {
  when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
  BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS);

  EntryEncryptor encryptor = new EntryEncryptor(getConfig("encrypt-value.ini"), KEYS);

  Mutation mutation = new Mutation("row".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), "val1".getBytes());
  mutation.put("colF".getBytes(), "colQ".getBytes(), 0, "val2".getBytes());
  writer.addMutation(mutation);

  verify(mockWriter, times(2)).addMutation(captor.capture());
  List<Mutation> mutations = captor.getAllValues();
  assertThat("two mutations", mutations, iterableWithSize(2));

  Mutation encrypted = mutations.get(0);
  assertThat("row is unchanged", encrypted.getRow(), equalTo("row".getBytes()));

  List<ColumnUpdate> updates = encrypted.getUpdates();
  assertThat("has 1 update", updates, hasSize(1));

  ColumnUpdate update = updates.get(0);
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
  assertThat("timestamp not set", update.hasTimestamp(), is(false));
  assertThat("value is encrypted", update.getColumnFamily(), not(equalTo("val1".getBytes())));

  MutableEntry decrypted = new MutableEntry(encryptor.decrypt(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was encrypted correctly", decrypted.value, equalTo("val1".getBytes()));

  encrypted = mutations.get(1);
  assertThat("row is unchanged", encrypted.getRow(), equalTo("row".getBytes()));

  updates = encrypted.getUpdates();
  assertThat("has 1 update", updates, hasSize(1));

  update = updates.get(0);
  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));
  assertThat("value is encrypted", update.getColumnFamily(), not(equalTo("val2".getBytes())));

  decrypted = new MutableEntry(encryptor.decrypt(new MutableEntry("row".getBytes(), update).toEntry()));
  assertThat("value was encrypted correctly", decrypted.value, equalTo("val2".getBytes()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:48,代码来源:EncryptedBatchWriterTest.java


注:本文中的org.apache.accumulo.core.data.Mutation.getUpdates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。