本文整理汇总了Java中org.apache.accumulo.core.data.Mutation.put方法的典型用法代码示例。如果您正苦于以下问题:Java Mutation.put方法的具体用法?Java Mutation.put怎么用?Java Mutation.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.data.Mutation
的用法示例。
在下文中一共展示了Mutation.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRandomEntries
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
* Write random entries.
* <p>
* Closes the writer after entries are written.
*
* @param writer
* Writer to write entries to.
*/
void writeRandomEntries(BatchWriter writer) throws MutationsRejectedException {
for (int i = 0; i < rowCount; i++) {
byte[] row = getRandomBytes(keyFieldSize, true);
for (int j = 0; j < columnCount; j++) {
byte[] colF = getRandomBytes(keyFieldSize, true);
byte[] colQ = getRandomBytes(keyFieldSize, true);
byte[] value = getRandomBytes(valueFieldSize, false);
Mutation mutation = new Mutation(row);
mutation.put(colF, colQ, VISIBILITY, value);
writer.addMutation(mutation);
}
}
writer.close();
}
示例2: getMutations
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
* Get random mutations to be written.
*
* @return Mutations.
*/
List<Mutation> getMutations() {
List<Mutation> mutations = new ArrayList<>(rowCount);
for (int i = 0; i < rowCount; i++) {
byte[] row = getRandomBytes(keyFieldSize, true);
Mutation mutation = new Mutation(row);
mutations.add(mutation);
for (int j = 0; j < columnCount; j++) {
byte[] colF = getRandomBytes(keyFieldSize, true);
byte[] colQ = getRandomBytes(keyFieldSize, true);
byte[] value = getRandomBytes(valueFieldSize, false);
mutation.put(colF, colQ, VISIBILITY, value);
}
}
return mutations;
}
示例3: writeData
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
/**
* Writes the given data to Accumulo. The full combinatorial of values is written.
*
* @param rows
* Rows to write.
* @param colFs
* Column families to write.
* @param colQs
* Column qualifiers to write.
* @param colVs
* Column visibilities to write.
* @param values
* Values to write.
*/
private static void writeData(BatchWriter writer, Iterable<String> rows, Iterable<String> colFs, Iterable<String> colQs, Iterable<String> colVs,
Iterable<String> values) throws MutationsRejectedException {
List<Mutation> mutations = new ArrayList<>();
for (String row : rows) {
Mutation mutation = new Mutation(row);
mutations.add(mutation);
for (String colF : colFs) {
for (String colQ : colQs) {
for (String colV : colVs) {
for (String value : values) {
mutation.put(colF, colQ, new ColumnVisibility(colV), value);
}
}
}
}
}
writer.addMutations(mutations);
writer.flush();
}
示例4: addMutationsTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationsTest() throws Exception {
when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
BatchWriter writer = new EncryptedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("encrypt-value.ini"), KEYS);
List<Mutation> mutations = new ArrayList<>();
Mutation mutation = new Mutation("row");
mutation.put("colF", "colQ", "val");
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(1)).addMutation(any()); // 1 time
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(3)).addMutation(any()); // 1 + 2 times
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(6)).addMutation(any()); // 1 + 2 + 3 times
}
示例5: addMutationsTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationsTest() 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));
List<Mutation> mutations = new ArrayList<>();
Mutation mutation = new Mutation("row");
mutation.put("colF", "colQ", "val");
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(1)).addMutation(any()); // 1 time
verify(mockSignatureWriter, never()).addMutation(any());
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(3)).addMutation(any()); // 1 + 2 times
verify(mockSignatureWriter, never()).addMutation(any());
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(6)).addMutation(any()); // 1 + 2 + 3 times
verify(mockSignatureWriter, never()).addMutation(any());
}
示例6: addMutationsExternalTest
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void addMutationsExternalTest() 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));
List<Mutation> mutations = new ArrayList<>();
Mutation mutation = new Mutation("row");
mutation.put("colF", "colQ", "val");
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(1)).addMutation(any()); // 1 time
verify(mockSignatureWriter, times(1)).addMutation(any()); // 1 time
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(3)).addMutation(any()); // 1 + 2 times
verify(mockSignatureWriter, times(3)).addMutation(any()); // 1 + 2 times
mutations.add(mutation);
writer.addMutations(mutations);
verify(mockWriter, times(6)).addMutation(any()); // 1 + 2 + 3 times
verify(mockSignatureWriter, times(6)).addMutation(any()); // 1 + 2 + 3 times
}
示例7: testAgeoffFilter
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void testAgeoffFilter() throws Exception {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
is = new IteratorSetting(10, AgeOffFilter.class);
AgeOffFilter.setTTL(is, 1000L);
c.tableOperations().attachIterator(tableName, is);
sleepUninterruptibly(500, TimeUnit.MILLISECONDS); // let zookeeper updates propagate.
bw = c.createBatchWriter(tableName, bwc);
Mutation m = new Mutation("foo");
m.put("a", "b", "c");
bw.addMutation(m);
bw.close();
sleepUninterruptibly(1, TimeUnit.SECONDS);
assertEquals(0, Iterators.size(c.createScanner(tableName, Authorizations.EMPTY).iterator()));
}
示例8: test
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
conn.tableOperations().create(tableName);
BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
for (Entry<Key,Value> e : data) {
Key k = e.getKey();
Mutation m = new Mutation(k.getRow());
m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
bw.addMutation(m);
}
bw.close();
assertEquals(0, CIFTester.main(tableName, CIFTester.TestMapper.class.getName()));
assertEquals(1, assertionErrors.get(tableName).size());
}
示例9: reduce
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public void reduce(Iterable<Tuple3<String, Double, Integer>> values, Collector<Tuple2<Text, Mutation>> out) throws Exception {
for (Tuple3<String,Double,Integer> entry: values) {
if(i == 0){
toReturn = "[" + entry.f0.toString();
}else{
toReturn = toReturn + "," + entry.f0.toString();
}
i++;
if(i == 10){
break;
}
}
toReturn += "]";
Mutation m = new Mutation(rowkey);
m.put(rowkey, "", new Value(toReturn.getBytes()));
out.collect(new Tuple2<>(new Text("HighScore"), m));
}
示例10: invoke
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
/**
* this is called for each token in tweet
*/
public void invoke(Tuple2<TermIndexKey, Integer> value) throws Exception {
// if the writer isnt already instantiated, do it now
if (writerForTerms == null) {
writerForTerms = createBatchWriter(tableTerms);
}
//Write termData once per token/user
Mutation mutationTerms = new Mutation(value._1.getTermBytes());
if(value._2()<=1)
{
//put without value
// column family, column qualifier without value
mutationTerms.put(value._1.getSourceBytes(), value._1.rawTwitterDataKey.keyBytes, EMPTY_BYTES);
}
else
{
//put with number of occurrences
// column family, column qualifier and value to write
mutationTerms.put(value._1.getSourceBytes(), value._1.rawTwitterDataKey.keyBytes, (""+value._2()).getBytes());
}
writerForTerms.addMutation(mutationTerms);
}
示例11: invoke
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
/**
* this is called for each tweet
*/
public void invoke(Tuple2<RawTwitterDataKey, GeoTemporalKey> value) throws Exception {
// if the writer isnt already instantiated, do it now
if (writerForGeoTempIndex == null) {
writerForGeoTempIndex = createBatchWriter(tableTerms);
}
//Write geoTemporalIndex once per tweet
Mutation mutationTerms = new Mutation(value._2.rowBytes);
mutationTerms.put(value._1.keyBytes, value._2.columQualifier, EMPTY_BYTES);
writerForGeoTempIndex.addMutation(mutationTerms);
}
示例12: invoke
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
/**
* this is called for each tweet, writes rawTwitterData into db
*/
public void invoke(Tuple2<RawTwitterDataKey, String> value) throws Exception {
// if the writer isnt already instantiated, do it now
if (writerForRawData == null) {
writerForRawData = createBatchWriter(tableRawData);
}
// bytes of the string containing tweet's json
byte[] tweet = value._2().getBytes();
//Write raw data once per tweet
Mutation mutationRawData = new Mutation(value._1.keyBytes);
// column family, column qualifier and tweet as string
mutationRawData.put(T_BYTES, EMPTY_BYTES, tweet);
writerForRawData.addMutation(mutationRawData);
}
示例13: testErrorOnNextWithoutClose
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Test
public void testErrorOnNextWithoutClose() throws Exception {
conn.tableOperations().create(tableName);
BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
for (Entry<Key,Value> e : data) {
Key k = e.getKey();
Mutation m = new Mutation(k.getRow());
m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
bw.addMutation(m);
}
bw.close();
assertEquals(1, CIFTester.main(tableName, CIFTester.TestNoClose.class.getName()));
assertEquals(1, assertionErrors.get(tableName).size());
// this should actually exist, in addition to the dummy entry
assertEquals(2, assertionErrors.get(tableName + "_map_ioexception").size());
}
示例14: buildMutation
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
public static Mutation buildMutation(ColumnVisibility cv, String path, boolean isDir, boolean isHidden, boolean canExec, long length, long lastmod,
String hash) {
if (path.equals("/"))
path = "";
Mutation m = new Mutation(QueryUtil.getRow(path));
Text colf = null;
if (isDir)
colf = QueryUtil.DIR_COLF;
else
colf = new Text(encoder.encode(Long.MAX_VALUE - lastmod));
m.put(colf, new Text(LENGTH_CQ), cv, new Value(Long.toString(length).getBytes()));
m.put(colf, new Text(HIDDEN_CQ), cv, new Value(Boolean.toString(isHidden).getBytes()));
m.put(colf, new Text(EXEC_CQ), cv, new Value(Boolean.toString(canExec).getBytes()));
m.put(colf, new Text(LASTMOD_CQ), cv, new Value(Long.toString(lastmod).getBytes()));
if (hash != null && hash.length() > 0)
m.put(colf, new Text(HASH_CQ), cv, new Value(hash.getBytes()));
return m;
}
示例15: map
import org.apache.accumulo.core.data.Mutation; //导入方法依赖的package包/类
@Override
public void map(LongWritable key, Text value, Context output) throws IOException {
String[] words = value.toString().split("\\s+");
for (String word : words) {
Mutation mutation = new Mutation(new Text(word));
mutation.put(new Text("count"), new Text("20080906"), new Value("1".getBytes()));
try {
output.write(null, mutation);
} catch (InterruptedException e) {
log.error("Could not write mutation to Context.", e);
}
}
}