本文整理匯總了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);
}
示例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;
}
示例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));
}
示例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));
}
示例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();
}
示例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()));
}
示例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()));
}
示例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());
}
示例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 */}
}
示例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)));
}
示例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)));
}
示例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));
}
示例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 */}
}
示例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));
}
示例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));
}