• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Mutation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseLine

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
private Mutation parseLine(FileMapping mapping, String[] line) {
  RowMapping rowMapping = mapping.getRowMapping();
  // Construct the Mutation
  Mutation mutation = rowMapping.getRowId(line);
  int rowOffset = rowMapping.getLogicalOffset();
  assert null != mutation;

  // Build the Mutation - each "column" in the line of data
  for (int logicalOffset = 0; logicalOffset < mapping.numMappings(); logicalOffset++) {
    if (logicalOffset == rowOffset) {
      continue;
    }
    // Avoid calling getColumnMapping for the rowId offset
    ColumnMapping colMapping = mapping.getColumnMapping(logicalOffset);
    String value = line[logicalOffset];
    if (null == value) {
      LOG.debug("Saw null value at column offset {}", logicalOffset);
      continue;
    }
    colMapping.addColumns(mutation, value);
  }

  return mutation;
}
 
开发者ID:joshelser,项目名称:accumulo-delimited-ingest,代码行数:25,代码来源:DelimitedIngest.java


示例2: accept

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
@Override
/**
 * Processes a record by extracting its field map and converting
 * it into a list of Mutations into Accumulo.
 */
public void accept(FieldMappable record)
    throws IOException, ProcessingException {
  Map<String, Object> fields = record.getFieldMap();

  Iterable<Mutation> putList = mutationTransformer.getMutations(fields);
  if (null != putList) {
    for (Mutation m : putList) {
      try {
        this.table.addMutation(m);
      } catch (MutationsRejectedException ex) {
        throw new IOException("Mutation rejected" , ex);
      }
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:21,代码来源:AccumuloMutationProcessor.java


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


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


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


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


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


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


示例9: put

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
@Override
public void put(final String tableName, final String rowId, final Collection<PutMutation> columns) throws IOException {

    BatchWriter writer = batchWriter(10000000L, tableName);

    Mutation mutation = new Mutation(new Text(rowId));
    for (final PutMutation column : columns) {
        mutation.put(new Text(column.getColumnFamily()), new Text(column.getColumnQualifier()),
                new ColumnVisibility(column.getColumnVisibilty()), new Value(column.getBuffer().getBytes()));
    }

    try {
        writer.addMutation(mutation);
        writer.close();
    } catch (MutationsRejectedException e) {
        e.printStackTrace();
    }
}
 
开发者ID:pinkdevelops,项目名称:nifi-accumulo-service,代码行数:19,代码来源:Accumulo_1_7_0_ConnectorService.java


示例10: toMutation

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
public static Mutation toMutation(Metric metric) {
    final Mutation mutation = new Mutation(encodeRowKey(metric));

    List<Tag> tags = metric.getTags();
    Collections.sort(tags);

    for (final Tag entry : tags) {
        if (entry.getKey().equals(VISIBILITY_TAG))
            continue;

        final String cf = entry.join();
        // @formatter:off
        String cq = tags.stream().filter(inner -> !inner.equals(entry))
                .filter(inner -> !inner.getKey().equals(VISIBILITY_TAG))
                .map(Tag::join)
                .collect(Collectors.joining(","));
        // @formatter:on

        mutation.put(cf, cq, extractVisibility(tags), metric.getValue().getTimestamp(), extractValue(metric));
    }
    return mutation;
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:23,代码来源:MetricAdapter.java


示例11: testToMutations

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
@Test
public void testToMutations() {
    Meta one = new Meta("sys.cpu.user", "tag1", "value1");
    Meta two = new Meta("sys.cpu.user", "tag2", "value2");
    Meta three = new Meta("sys.cpu.user", "tag3", "value3");
    MetaKeySet mks = new MetaKeySet();
    mks.addAll(one.toKeys());
    mks.addAll(two.toKeys());
    mks.addAll(three.toKeys());
    List<Mutation> muts = mks.toMutations();
    Mutation e1 = new Mutation("m:sys.cpu.user");
    e1.put("", "", MetaKeySet.NULL_VALUE);
    Mutation e2 = new Mutation("t:sys.cpu.user");
    e2.put("tag1", "", MetaKeySet.NULL_VALUE);
    e2.put("tag2", "", MetaKeySet.NULL_VALUE);
    e2.put("tag3", "", MetaKeySet.NULL_VALUE);
    Mutation e3 = new Mutation("v:sys.cpu.user");
    e3.put("tag1", "value1", MetaKeySet.NULL_VALUE);
    e3.put("tag2", "value2", MetaKeySet.NULL_VALUE);
    e3.put("tag3", "value3", MetaKeySet.NULL_VALUE);
    Assert.assertEquals(3, muts.size());
    Assert.assertTrue(muts.contains(e1));
    Assert.assertTrue(muts.contains(e2));
    Assert.assertTrue(muts.contains(e3));
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:26,代码来源:MetaKeySetTest.java


示例12: putArray

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
private int putArray(Mutation m, int count, Object o, Pair<Text, Text> col, String fieldName) {

    // First of all we delete array field on accumulo store
    Text rowKey = new Text(m.getRow());
    Query<K, T> query = newQuery();
    query.setFields(fieldName);
    query.setStartKey((K)rowKey.toString());
    query.setEndKey((K)rowKey.toString());
    deleteByQuery(query);
    flush();
    if (o == null){
      return 0;
    }

    List<?> array = (List<?>) o;  // both GenericArray and DirtyListWrapper
    int j = 0;
    for (Object item : array) {
      m.put(col.getFirst(), new Text(toBytes(j++)), new Value(toBytes(item)));
      count++;
    }
    return count;
  }
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:23,代码来源:AccumuloStore.java


示例13: getHadoopOF

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
/**
 * creates output format to write data from flink DataSet to accumulo
 * @return
 * @throws AccumuloSecurityException
 */
public HadoopOutputFormat getHadoopOF() throws AccumuloSecurityException, IOException {

    if(job == null){
        job = Job.getInstance(new Configuration(), jobName);
    }
    AccumuloOutputFormat.setConnectorInfo(job, accumuloUser, new PasswordToken(accumuloPassword));
    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.withInstance(accumuloInstanceName);
    clientConfig.withZkHosts(accumuloZookeeper);
    AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig);
    AccumuloOutputFormat.setDefaultTableName(job, outTable);
    AccumuloFileOutputFormat.setOutputPath(job,new Path("/tmp"));

    HadoopOutputFormat<Text, Mutation> hadoopOF =
            new HadoopOutputFormat<>(new AccumuloOutputFormat() , job);
    return hadoopOF;
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:23,代码来源:FlinkEnvManager.java


示例14: testAmc

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
@Test
public void testAmc() throws TableExistsException, AccumuloSecurityException, AccumuloException, TableNotFoundException {
    Connector conn = amc.getConnector();
    System.out.println("I am connected as: " + conn.whoami());

    conn.tableOperations().create("TestTable");
    Mutation m1 = new Mutation("row1");
    String testString = "42";
    m1.put("CF", "CQ", testString);
    BatchWriter bw = conn.createBatchWriter("TestTable", new BatchWriterConfig());
    bw.addMutation(m1);
    bw.close();

    Scanner s = conn.createScanner("TestTable", new Authorizations("standard"));
    for(Map.Entry<Key, Value> entry: s){
        System.out.println(entry.getKey());
        System.out.println(entry.getValue());
        assertEquals(entry.getValue().toString(), testString);
    }

    s.close();
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:23,代码来源:AmcHelperTest.java


示例15: 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));


}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:23,代码来源:TopTenGroupReduce.java


示例16: 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);
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:27,代码来源:TermIndexSink.java


示例17: 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);
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:17,代码来源:GeoTemporalIndexSink.java


示例18: 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);
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:21,代码来源:RawTwitterDataSink.java


示例19: run

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
@Override
public int run(String[] args) throws Exception {
  Job job = Job.getInstance(getConf());
  job.setJobName(this.getClass().getSimpleName());
  job.setJarByClass(this.getClass());

  Opts opts = new Opts();
  opts.parseArgs(CharacterHistogram.class.getName(), args);

  job.setInputFormatClass(ChunkInputFormat.class);
  opts.setAccumuloConfigs(job);
  job.getConfiguration().set(VIS, opts.visibilities.toString());

  job.setMapperClass(HistMapper.class);
  job.setMapOutputKeyClass(Text.class);
  job.setMapOutputValueClass(Mutation.class);

  job.setNumReduceTasks(0);

  job.setOutputFormatClass(AccumuloOutputFormat.class);

  job.waitForCompletion(true);
  return job.isSuccessful() ? 0 : 1;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:25,代码来源:CharacterHistogram.java


示例20: main

import org.apache.accumulo.core.data.Mutation; //导入依赖的package包/类
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, MutationsRejectedException, TableExistsException,
    TableNotFoundException {
  ClientOnRequiredTable opts = new ClientOnRequiredTable();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(InsertWithBatchWriter.class.getName(), args, bwOpts);

  Connector connector = opts.getConnector();
  MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());

  if (!connector.tableOperations().exists(opts.getTableName()))
    connector.tableOperations().create(opts.getTableName());
  BatchWriter bw = mtbw.getBatchWriter(opts.getTableName());

  Text colf = new Text("colfam");
  System.out.println("writing ...");
  for (int i = 0; i < 10000; i++) {
    Mutation m = new Mutation(new Text(String.format("row_%d", i)));
    for (int j = 0; j < 5; j++) {
      m.put(colf, new Text(String.format("colqual_%d", j)), new Value((String.format("value_%d_%d", i, j)).getBytes()));
    }
    bw.addMutation(m);
    if (i % 100 == 0)
      System.out.println(i);
  }
  mtbw.close();
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:27,代码来源:InsertWithBatchWriter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Rectangle类代码示例发布时间:2022-05-21
下一篇:
Java JsType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap