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


Java Mutation类代码示例

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


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

示例1: processElement

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) {
	InputContent i = c.element();
	String jobName = c.getPipelineOptions().getJobName();
	ByteString rowkey = ByteString.copyFromUtf8(jobName + "#" + i.expectedDocumentHash); 
	ByteString value = ByteString.copyFromUtf8(i.text);
	
	Iterable<Mutation> mutations =
		ImmutableList.of(Mutation.newBuilder()
			.setSetCell(
				Mutation.SetCell.newBuilder()
					.setFamilyName(IndexerPipelineUtils.DEAD_LETTER_TABLE_ERR_CF)
					.setColumnQualifier(ByteString.copyFromUtf8("text"))
					.setValue(value)
			)
               .build());
	
	c.output(KV.of(rowkey, mutations));			
}
 
开发者ID:GoogleCloudPlatform,项目名称:dataflow-opinion-analysis,代码行数:20,代码来源:FileIndexerPipeline.java

示例2: testDeleteRow

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testDeleteRow() throws Exception {
  final BigtableMutationImpl bigtableMutationImpl = (BigtableMutationImpl) this.bigtableMutation.deleteRow();
  verifyGetMutateRowRequest();

  bigtableMutationImpl.execute();
  bigtableMutationImpl.executeAsync();

  assertEquals(1, bigtableMutationImpl.getMutateRowRequest().getMutationsCount());
  final Mutation mutation = bigtableMutationImpl.getMutateRowRequest().getMutations(0);
  assertEquals(Mutation.MutationCase.DELETE_FROM_ROW, mutation.getMutationCase());
  assertEquals(Mutation.DeleteFromRow.getDefaultInstance(), mutation.getDeleteFromRow());
  assertEquals(Mutation.DeleteFromFamily.getDefaultInstance(), mutation.getDeleteFromFamily());
  assertEquals(Mutation.DeleteFromColumn.getDefaultInstance(), mutation.getDeleteFromColumn());
  assertEquals(Mutation.SetCell.getDefaultInstance(), mutation.getSetCell());

  verify(bigtableMock.getMockedDataClient()).mutateRow(bigtableMutation.getMutateRowRequest().build());
  verify(bigtableMock.getMockedDataClient()).mutateRowAsync(bigtableMutation.getMutateRowRequest().build());
  verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:21,代码来源:BigtableMutationImplTest.java

示例3: testWritingFailsTableDoesNotExist

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
/** Tests that when writing to a non-existent table, the write fails. */
@Test
public void testWritingFailsTableDoesNotExist() throws Exception {
  final String table = "TEST-TABLE";

  PCollection<KV<ByteString, Iterable<Mutation>>> emptyInput =
      p.apply(
          Create.empty(
              KvCoder.of(ByteStringCoder.of(), IterableCoder.of(ProtoCoder.of(Mutation.class)))));

  // Exception will be thrown by write.validate() when writeToDynamic is applied.
  thrown.expect(IllegalArgumentException.class);
  thrown.expectMessage(String.format("Table %s does not exist", table));

  emptyInput.apply("write", defaultWrite.withTableId(table));
  p.run();
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:BigtableIOTest.java

示例4: deleteCellsFromColumn

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Override
public BigtableMutation deleteCellsFromColumn(final String columnFamily,
                                              final String columnQualifier,
                                              final Optional<Long> startTimestampMicros,
                                              final Optional<Long> endTimestampMicros) {
  final TimestampRange.Builder timestampRange = TimestampRange.newBuilder();
  startTimestampMicros.ifPresent(timestampRange::setStartTimestampMicros);
  endTimestampMicros.ifPresent(timestampRange::setEndTimestampMicros);

  final Mutation.DeleteFromColumn.Builder deleteFromColumn =
      Mutation.DeleteFromColumn.newBuilder()
          .setFamilyName(columnFamily)
          .setColumnQualifier(ByteString.copyFromUtf8(columnQualifier))
          .setTimeRange(timestampRange);

  mutateRowRequest.addMutations(Mutation.newBuilder().setDeleteFromColumn(deleteFromColumn));
  return this;
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:19,代码来源:BigtableMutationImpl.java

示例5: testDeleteColumnFamily

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testDeleteColumnFamily() throws Exception {
  final BigtableMutationImpl bigtableMutationImpl =
          (BigtableMutationImpl) this.bigtableMutation.deleteColumnFamily("family");
  verifyGetMutateRowRequest();

  bigtableMutationImpl.execute();
  bigtableMutationImpl.executeAsync();

  assertEquals(1, bigtableMutationImpl.getMutateRowRequest().getMutationsCount());
  final Mutation mutation = bigtableMutationImpl.getMutateRowRequest().getMutations(0);
  assertEquals(Mutation.MutationCase.DELETE_FROM_FAMILY, mutation.getMutationCase());
  assertEquals("family", mutation.getDeleteFromFamily().getFamilyName());
  assertEquals(Mutation.DeleteFromRow.getDefaultInstance(), mutation.getDeleteFromRow());
  assertEquals(Mutation.DeleteFromColumn.getDefaultInstance(), mutation.getDeleteFromColumn());
  assertEquals(Mutation.SetCell.getDefaultInstance(), mutation.getSetCell());

  verify(bigtableMock.getMockedDataClient()).mutateRow(bigtableMutation.getMutateRowRequest().build());
  verify(bigtableMock.getMockedDataClient()).mutateRowAsync(bigtableMutation.getMutateRowRequest().build());
  verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:22,代码来源:BigtableMutationImplTest.java

示例6: testDeleteColumn

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testDeleteColumn() throws Exception {
  final BigtableMutationImpl bigtableMutationImpl =
          (BigtableMutationImpl) this.bigtableMutation.deleteColumn("family:qualifier");
  verifyGetMutateRowRequest();

  bigtableMutationImpl.execute();
  bigtableMutationImpl.executeAsync();

  assertEquals(1, bigtableMutationImpl.getMutateRowRequest().getMutationsCount());
  final Mutation mutation = bigtableMutationImpl.getMutateRowRequest().getMutations(0);
  assertEquals(Mutation.MutationCase.DELETE_FROM_COLUMN, mutation.getMutationCase());
  assertEquals("family", mutation.getDeleteFromColumn().getFamilyName());
  assertEquals("qualifier", mutation.getDeleteFromColumn().getColumnQualifier().toStringUtf8());
  assertEquals(Mutation.DeleteFromRow.getDefaultInstance(), mutation.getDeleteFromRow());
  assertEquals(Mutation.DeleteFromFamily.getDefaultInstance(), mutation.getDeleteFromFamily());
  assertEquals(Mutation.SetCell.getDefaultInstance(), mutation.getSetCell());

  verify(bigtableMock.getMockedDataClient()).mutateRow(bigtableMutation.getMutateRowRequest().build());
  verify(bigtableMock.getMockedDataClient()).mutateRowAsync(bigtableMutation.getMutateRowRequest().build());
  verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:23,代码来源:BigtableMutationImplTest.java

示例7: testDeleteColumnFamilyAndQualifier

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testDeleteColumnFamilyAndQualifier() throws Exception {
  final BigtableMutationImpl bigtableMutationImpl =
          (BigtableMutationImpl) this.bigtableMutation.deleteColumn("family", "qualifier");
  verifyGetMutateRowRequest();

  bigtableMutationImpl.execute();
  bigtableMutationImpl.executeAsync();

  assertEquals(1, bigtableMutationImpl.getMutateRowRequest().getMutationsCount());
  final Mutation mutation = bigtableMutationImpl.getMutateRowRequest().getMutations(0);
  assertEquals(Mutation.MutationCase.DELETE_FROM_COLUMN, mutation.getMutationCase());
  assertEquals("family", mutation.getDeleteFromColumn().getFamilyName());
  assertEquals("qualifier", mutation.getDeleteFromColumn().getColumnQualifier().toStringUtf8());
  assertEquals(Mutation.DeleteFromRow.getDefaultInstance(), mutation.getDeleteFromRow());
  assertEquals(Mutation.DeleteFromFamily.getDefaultInstance(), mutation.getDeleteFromFamily());
  assertEquals(Mutation.SetCell.getDefaultInstance(), mutation.getSetCell());

  verify(bigtableMock.getMockedDataClient()).mutateRow(bigtableMutation.getMutateRowRequest().build());
  verify(bigtableMock.getMockedDataClient()).mutateRowAsync(bigtableMutation.getMutateRowRequest().build());
  verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:23,代码来源:BigtableMutationImplTest.java

示例8: writeRecord

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Override
public ListenableFuture<MutateRowResponse> writeRecord(
    KV<ByteString, Iterable<Mutation>> record)
    throws IOException {
  MutateRowRequest r =
      MutateRowRequest.newBuilder()
          .setTableName(tableName)
          .setRowKey(record.getKey())
          .addAllMutations(record.getValue())
          .build();
  return bulkMutation.add(r);
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:BigtableServiceImpl.java

示例9: expand

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Override
public PDone expand(PCollection<KV<ByteString, Iterable<Mutation>>> input) {
  getBigtableConfig().validate();

  input.apply(ParDo.of(new BigtableWriterFn(getBigtableConfig().getTableId(),
      new SerializableFunction<PipelineOptions, BigtableService>() {
        @Override
        public BigtableService apply(PipelineOptions options) {
          return getBigtableConfig().getBigtableService(options);
        }
      })));
  return PDone.in(input.getPipeline());
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:BigtableIO.java

示例10: BigtableWriteException

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
public BigtableWriteException(KV<ByteString, Iterable<Mutation>> record, Throwable cause) {
  super(
      String.format(
          "Error mutating row %s with mutations %s",
          record.getKey().toStringUtf8(),
          record.getValue()),
      cause);
}
 
开发者ID:apache,项目名称:beam,代码行数:9,代码来源:BigtableIO.java

示例11: testCoderInference

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testCoderInference() {
  SerializableFunction<SchemaAndRecord, KV<ByteString, Mutation>> parseFn =
      new SerializableFunction<SchemaAndRecord, KV<ByteString, Mutation>>() {
        @Override
        public KV<ByteString, Mutation> apply(SchemaAndRecord input) {
          return null;
        }
      };

  assertEquals(
      KvCoder.of(ByteStringCoder.of(), ProtoCoder.of(Mutation.class)),
      BigQueryIO.read(parseFn).inferCoder(CoderRegistry.createDefault()));
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:BigQueryIOReadTest.java

示例12: testE2EBigtableWrite

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Test
public void testE2EBigtableWrite() throws Exception {
  final String tableName = bigtableOptions.getInstanceName().toTableNameStr(tableId);
  final String instanceName = bigtableOptions.getInstanceName().toString();
  final int numRows = 1000;
  final List<KV<ByteString, ByteString>> testData = generateTableData(numRows);

  createEmptyTable(instanceName, tableId);

  Pipeline p = Pipeline.create(options);
  p.apply(GenerateSequence.from(0).to(numRows))
      .apply(ParDo.of(new DoFn<Long, KV<ByteString, Iterable<Mutation>>>() {
        @ProcessElement
        public void processElement(ProcessContext c) {
          int index = c.element().intValue();

          Iterable<Mutation> mutations =
              ImmutableList.of(Mutation.newBuilder()
                  .setSetCell(
                      Mutation.SetCell.newBuilder()
                          .setValue(testData.get(index).getValue())
                          .setFamilyName(COLUMN_FAMILY_NAME))
                  .build());
          c.output(KV.of(testData.get(index).getKey(), mutations));
        }
      }))
      .apply(BigtableIO.write()
        .withBigtableOptions(bigtableOptions)
        .withTableId(tableId));
  p.run();

  // Test number of column families and column family name equality
  Table table = getTable(tableName);
  assertThat(table.getColumnFamiliesMap().keySet(), Matchers.hasSize(1));
  assertThat(table.getColumnFamiliesMap(), Matchers.hasKey(COLUMN_FAMILY_NAME));

  // Test table data equality
  List<KV<ByteString, ByteString>> tableData = getTableData(tableName);
  assertThat(tableData, Matchers.containsInAnyOrder(testData.toArray()));
}
 
开发者ID:apache,项目名称:beam,代码行数:41,代码来源:BigtableWriteIT.java

示例13: makeWrite

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
/** Helper function to make a single row mutation to be written. */
private static KV<ByteString, Iterable<Mutation>> makeWrite(String key, String value) {
  ByteString rowKey = ByteString.copyFromUtf8(key);
  Iterable<Mutation> mutations =
      ImmutableList.of(
          Mutation.newBuilder()
              .setSetCell(SetCell.newBuilder().setValue(ByteString.copyFromUtf8(value)))
              .build());
  return KV.of(rowKey, mutations);
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BigtableIOTest.java

示例14: writeRecord

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Override
public ListenableFuture<MutateRowResponse> writeRecord(
    KV<ByteString, Iterable<Mutation>> record) {
  service.verifyTableExists(tableId);
  Map<ByteString, ByteString> table = service.getTable(tableId);
  ByteString key = record.getKey();
  for (Mutation m : record.getValue()) {
    SetCell cell = m.getSetCell();
    if (cell.getValue().isEmpty()) {
      return Futures.immediateFailedCheckedFuture(new IOException("cell value missing"));
    }
    table.put(key, cell.getValue());
  }
  return Futures.immediateFuture(MutateRowResponse.getDefaultInstance());
}
 
开发者ID:apache,项目名称:beam,代码行数:16,代码来源:BigtableIOTest.java

示例15: deleteColumnFamily

import com.google.bigtable.v2.Mutation; //导入依赖的package包/类
@Override
public BigtableMutation deleteColumnFamily(String columnFamily) {
  final Mutation.DeleteFromFamily.Builder deleteFromFamily =
      Mutation.DeleteFromFamily.newBuilder().setFamilyName(columnFamily);
  mutateRowRequest.addMutations(Mutation.newBuilder().setDeleteFromFamily(deleteFromFamily));
  return this;
}
 
开发者ID:spotify,项目名称:simple-bigtable,代码行数:8,代码来源:BigtableMutationImpl.java


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