當前位置: 首頁>>代碼示例>>Java>>正文


Java Mutation類代碼示例

本文整理匯總了Java中org.apache.accumulo.core.data.Mutation的典型用法代碼示例。如果您正苦於以下問題:Java Mutation類的具體用法?Java Mutation怎麽用?Java Mutation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Mutation類屬於org.apache.accumulo.core.data包,在下文中一共展示了Mutation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的org.apache.accumulo.core.data.Mutation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。