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


Java Value类代码示例

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


Value类属于org.apache.accumulo.core.data包,在下文中一共展示了Value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasData

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
/**
 * Matches the set of entries against the given set of values. The full combinatorial of values passed in is expected in the output set.
 *
 * @param rows
 *          Rows to check for.
 * @param colFs
 *          Column families to check for.
 * @param colQs
 *          Column qualifiers to check for.
 * @param colVs
 *          Column visibilities to check for.
 * @param values
 *          Values to check for.
 * @return Hamcrest matcher.
 */
@Factory
@SuppressWarnings("unchecked")
public static Matcher<Iterable<Entry<Key,Value>>> hasData(Collection<String> rows, Collection<String> colFs, Collection<String> colQs,
    Collection<String> colVs, Collection<String> values) {
  int size = rows.size() * colFs.size() * colQs.size() * colVs.size() * values.size();
  ArrayList<Matcher<? super Iterable<Entry<Key,Value>>>> matchers = new ArrayList<>(size + 1);

  matchers.add(IsIterableWithSize.iterableWithSize(size));

  for (String row : rows) {
    for (String colF : colFs) {
      for (String colQ : colQs) {
        for (String colV : colVs) {
          for (String value : values) {
            matchers.add(hasItems(equalToRow(row, colF, colQ, colV, value)));
          }
        }
      }
    }
  }

  return allOf(matchers);
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:39,代码来源:Matchers.java

示例2: getRandomData

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
/**
 * Get random data.
 *
 * @param count
 *          Number of entries to create.
 * @param rowSize
 *          Size (in bytes) of the row.
 * @param colFSize
 *          Size (in bytes) of the column family.
 * @param colQSize
 *          Size (in bytes) of the column qualifier.
 * @param colVisValue
 *          Value to use for colVis.
 * @param valueSize
 *          Size (in bytes) of the value.
 * @return Random data.
 */
static SortedMap<Key,Value> getRandomData(int count, int rowSize, int colFSize, int colQSize, byte[] colVisValue, int valueSize) {
  SortedMap<Key,Value> data = new TreeMap<>();

  for (int i = 0; i < count; i++) {
    byte[] row = new byte[rowSize];
    byte[] colF = new byte[colFSize];
    byte[] colQ = new byte[colQSize];
    byte[] colVis = colVisValue.clone();
    byte[] value = new byte[valueSize];

    random.nextBytes(row);
    random.nextBytes(colF);
    random.nextBytes(colQ);
    random.nextBytes(value);
    long timestamp = random.nextLong();

    data.put(new Key(row, colF, colQ, colVis, timestamp, false, false), new Value(value));
  }

  return data;
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:39,代码来源:GenerateRandomEntries.java

示例3: runTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
/**
 * Run a specific test for a given version and configuration.
 *
 * @param dataScanner
 *          Scanner for the unsigned data.
 * @param signedScanner
 *          Scanner for the signed data.
 * @param verifier
 *          Verifier for the signed data.
 * @param signatureConfig
 *          Configuration for the verifier.
 */
private void runTest(Scanner dataScanner, Scanner signedScanner, EntrySigner verifier, SignatureConfig signatureConfig) {
  Iterator<Entry<Key,Value>> iterator = signedScanner.iterator();
  for (Entry<Key,Value> entry : dataScanner) {
    assertThat("should have more entries", iterator.hasNext(), is(true));
    Entry<Key,Value> signedEntry = iterator.next();

    Entry<Key,Value> verifiedEntry;
    if (signatureConfig.isSignatureInSeparateTable()) {
      assertThat("keys should match", signedEntry.getKey(), equalTo(entry.getKey()));
      assertThat("values should not match", signedEntry.getValue().get(), not(equalTo(entry.getValue().get())));
      verifiedEntry = verifier.verify(entry, signedEntry);
    } else {
      verifiedEntry = verifier.verify(signedEntry);
    }

    assertThat("entries should match", verifiedEntry, Matchers.equalTo(entry));
  }

  assertThat("should have no more entries", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:33,代码来源:VersioningIT.java

示例4: check

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
public void check(SignatureConfig config) throws Exception {
  Scanner scanner = AccumuloInstance.getConnector(USER).createScanner(UNSIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations);
  Scanner signedScanner;

  if (!config.isSignatureInSeparateTable()) {
    signedScanner = new SignedScanner(AccumuloInstance.getConnector(USER), SIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations, config,
        AccumuloInstance.getUser(USER).signatureKeys.get(config.getAlgorithm()));
  } else {
    signedScanner = new SignedScanner(AccumuloInstance.getConnector(USER), UNSIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations, config,
        AccumuloInstance.getUser(USER).signatureKeys.get(config.getAlgorithm()));
  }

  Iterator<Entry<Key,Value>> iterator = signedScanner.iterator();
  for (Entry<Key,Value> entry : scanner) {
    assertThat("should have an entry that matches", iterator.hasNext(), is(true));
    assertThat("entries match", iterator.next(), equalTo(entry));
  }

  assertThat("should have no more entries", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:21,代码来源:BatchWriteReadIT.java

示例5: decrypt

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
/**
 * Decrypt the given entry.
 *
 * @param entry
 *          entry to decrypt.
 * @return Decrypted entry.
 */
public Entry<Key,Value> decrypt(Entry<Key,Value> entry) {
  checkArgument(entry != null, "entry is null");

  MutableEntry wrapped = new MutableEntry(entry);
  MutableEntry result = new MutableEntry(entry);
  ColumnVisibility visibility = entry.getKey().getColumnVisibilityParsed();

  // Decrypt the various fields.
  try {
    for (FieldEncryptor fieldEncryptor : encryptors) {
      fieldEncryptor.decrypt(wrapped, result, visibility);
    }
  } catch (IOException e) { // IO exceptions won't be thrown in practice as we are operating on in-memory streams.
    throw new EncryptionException(e);
  }

  return result.toEntry();
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:26,代码来源:EntryEncryptor.java

示例6: signVerifyInValueTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void signVerifyInValueTest() throws Exception {
  MutableEntry entry = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(VISIBILITY_CHARSET), (long) 5, false), new Value(new byte[] {6})));

  MutableEntry signed;
  Entry<Key,Value> verified;

  EntrySigner signer = getSigner("config1.ini", aliceKeyContainers.get(ValueSigner.RSA_PSS));
  EntrySigner verifier = getSigner("config1.ini", bobKeyContainers.get(ValueSigner.RSA_PSS));

  signed = new MutableEntry(signer.sign(entry.toEntry(), true));
  assertThat("row should not have changed", signed.row, is(entry.row));
  assertThat("colFamily should not have changed", signed.colF, is(entry.colF));
  assertThat("colQualifier should not have changed", signed.colQ, is(entry.colQ));
  assertThat("colVisibility should not have changed", signed.colVis, is(entry.colVis));
  assertThat("timestamp should not have changed", signed.timestamp, is(entry.timestamp));
  assertThat("delete should not have changed", signed.delete, is(entry.delete));
  assertThat("value should have changed", signed.value, is(not(entry.value)));

  verified = verifier.verify(signed.toEntry());
  assertThat("original and verified records are the same.", verified, Matchers.equalTo(entry.toEntry()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:24,代码来源:EntrySignerTest.java

示例7: signVerifyInSeparateTableTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void signVerifyInSeparateTableTest() throws Exception {
  MutableEntry entry = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(VISIBILITY_CHARSET), (long) 5, false), new Value(new byte[] {6})));

  MutableEntry signed;
  Entry<Key,Value> verified;

  EntrySigner signer = getSigner("config3.ini", aliceKeyContainers.get(ValueSigner.ECDSA));
  EntrySigner verifier = getSigner("config3.ini", bobKeyContainers.get(ValueSigner.ECDSA));

  signed = new MutableEntry(signer.sign(entry.toEntry(), true));
  assertThat("row should not have changed", signed.row, is(entry.row));
  assertThat("colFamily should not have changed", signed.colF, is(entry.colF));
  assertThat("colQualifier should not have changed", signed.colQ, is(entry.colQ));
  assertThat("colVisibility should not have changed", signed.colVis, is(entry.colVis));
  assertThat("timestamp should not have changed", signed.timestamp, is(entry.timestamp));
  assertThat("delete should not have changed", signed.delete, is(entry.delete));
  assertThat("value should have changed", signed.value, is(not(entry.value)));

  verified = verifier.verify(entry.toEntry(), signed.toEntry());
  assertThat("original and verified records are the same.", verified, Matchers.equalTo(entry.toEntry()));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:24,代码来源:EntrySignerTest.java

示例8: hasNoTimestampTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void hasNoTimestampTest() throws Exception {
  MutableEntry entry = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(VISIBILITY_CHARSET), (long) 0, false), new Value(new byte[] {6})));
  MutableEntry signed;

  EntrySigner signer = getSigner("config1.ini", aliceKeyContainers.get(ValueSigner.RSA_PSS));
  EntrySigner verifier = getSigner("config1.ini", bobKeyContainers.get(ValueSigner.RSA_PSS));

  try {
    signed = new MutableEntry(signer.sign(entry.toEntry(), true));
    signed.timestamp = 1000L;
    verifier.verify(signed.toEntry());
    fail("changing the timestamp should cause the signature to fail");
  } catch (SignatureException e) { /* expected */}

  signed = new MutableEntry(signer.sign(entry.toEntry(), false));
  signed.timestamp = 1000L;
  verifier.verify(signed.toEntry());
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:21,代码来源:EntrySignerTest.java

示例9: badSignatureTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void badSignatureTest() throws Exception {
  MutableEntry entry = new MutableEntry(new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(VISIBILITY_CHARSET), (long) 0, false), new Value(new byte[] {6})));
  Entry<Key,Value> signed;

  // Sign to value;
  EntrySigner signer = getSigner("config3.ini", aliceKeyContainers.get(ValueSigner.ECDSA));
  EntrySigner verifier = getSigner("config3.ini", bobKeyContainers.get(ValueSigner.ECDSA));

  signed = signer.sign(entry.toEntry(), true);
  entry.value = new byte[] {7};

  try {
    verifier.verify(entry.toEntry(), signed);
    fail("bad signature should thrown an exception");
  } catch (SignatureException e) { /* expected */}
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:19,代码来源:EntrySignerTest.java

示例10: internalUnprocessedTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void internalUnprocessedTest() throws Exception {
  EntrySigner signer = getSigner("config1.ini", aliceKeyContainers.get(ValueSigner.RSA_PSS));
  EntrySigner verifier = getSigner("config1.ini", bobKeyContainers.get(ValueSigner.RSA_PSS));

  List<Entry<Key,Value>> entries = new ArrayList<>();
  byte[] row = new byte[] {1};
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(row, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false,
      false), new Value(new byte[] {4}));

  entries.add(signer.sign(entry, true));
  SignedInlineScannerIterator iterator = new SignedInlineScannerIterator(entries.iterator(), verifier);

  iterator.next();
  assertThat("unprocessed item is correct", iterator.unprocessed(), Matchers.equalTo(entries.get(0)));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:17,代码来源:SignedIteratorTest.java

示例11: externalUnprocessedTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void externalUnprocessedTest() throws Exception {
  EntrySigner signer = getSigner("config3.ini", aliceKeyContainers.get(ValueSigner.ECDSA));
  EntrySigner verifier = getSigner("config3.ini", bobKeyContainers.get(ValueSigner.ECDSA));

  List<Entry<Key,Value>> entries = new ArrayList<>();
  List<Entry<Key,Value>> signedEntries = new ArrayList<>();

  byte[] row = new byte[] {1};
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(row, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false,
      false), new Value(new byte[] {4}));

  entries.add(entry);
  signedEntries.add(signer.sign(entry, true));

  SignedExternalScannerIterator iterator = new SignedExternalScannerIterator(entries.iterator(), signedEntries.iterator(), verifier, true);

  iterator.next();
  assertThat("unprocessed item is correct", iterator.unprocessed(), Matchers.equalTo(entries.get(0)));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:21,代码来源:SignedIteratorTest.java

示例12: hasNextTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void hasNextTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  entries.add(encryptor.encrypt(entry));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), encryptor, Collections.singletonList(new Range()),
      new TreeSet<Column>());

  assertThat("has next item", iterator.hasNext(), is(true));
  assertThat("has next item", iterator.hasNext(), is(true));
  iterator.next();
  assertThat("does not have a next item", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:EncryptedScannerIteratorTest.java

示例13: nextTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void nextTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  entries.add(encryptor.encrypt(entry));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), encryptor, Collections.singletonList(new Range()),
      new TreeSet<Column>());
  assertThat("next item is correct", iterator.next(), Matchers.equalTo(entry));

  try {
    iterator.next();
    fail("no items should be left");
  } catch (NoSuchElementException e) { /* expected */}
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:19,代码来源:EncryptedScannerIteratorTest.java

示例14: matchRangeTest

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void matchRangeTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0,
      false, false), new Value(new byte[] {4}));
  Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {6}, new byte[] {7}, "secret".getBytes(Utils.VISIBILITY_CHARSET),
      0, false, false), new Value(new byte[] {8}));
  entries.add(encryptor.encrypt(entry));
  entries.add(encryptor.encrypt(entry2));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS),
      Collections.singletonList(new Range()), new TreeSet<>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS), new ArrayList<Range>(),
      new TreeSet<Column>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForRange(entries, (byte) 1);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(1));

  iterator = getIteratorForRange(entries, (byte) 3);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(0));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:27,代码来源:EncryptedScannerIteratorTest.java

示例15: matchColumnFilters

import org.apache.accumulo.core.data.Value; //导入依赖的package包/类
@Test
public void matchColumnFilters() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0,
      false, false), new Value(new byte[] {4}));
  Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {2}, new byte[] {7}, "secret".getBytes(Utils.VISIBILITY_CHARSET),
      0, false, false), new Value(new byte[] {8}));
  entries.add(encryptor.encrypt(entry));
  entries.add(encryptor.encrypt(entry2));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS),
      Collections.singletonList(new Range()), new TreeSet<>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForColumn(entries, new byte[] {2}, null);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForColumn(entries, new byte[] {3}, null);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(0));

  iterator = getIteratorForColumn(entries, new byte[] {2}, new byte[] {7});
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(1));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:26,代码来源:EncryptedScannerIteratorTest.java


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