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


Java StringUtf8Coder.of方法代码示例

本文整理汇总了Java中org.apache.beam.sdk.coders.StringUtf8Coder.of方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtf8Coder.of方法的具体用法?Java StringUtf8Coder.of怎么用?Java StringUtf8Coder.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.beam.sdk.coders.StringUtf8Coder的用法示例。


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

示例1: testClear

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
public void testClear() throws Exception {
  FakeBeamFnStateClient fakeClient = new FakeBeamFnStateClient(ImmutableMap.of(
      key("A"), encode("A1", "A2", "A3")));
  BagUserState<String> userState =
      new BagUserState<>(fakeClient, "A", StringUtf8Coder.of(), () -> requestForId("A"));

  userState.clear();
  userState.append("A1");
  userState.clear();
  userState.asyncClose();

  assertNull(fakeClient.getData().get(key("A")));
  thrown.expect(IllegalStateException.class);
  userState.clear();
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:BagUserStateTest.java

示例2: getSortedTestData

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Override
protected byte[][] getSortedTestData() {
  StringUtf8Coder coder = StringUtf8Coder.of();

  try {
    return new byte[][]{
        CoderUtils.encodeToByteArray(coder, ""),
        CoderUtils.encodeToByteArray(coder, "Lorem Ipsum Dolor Omit Longer"),
        CoderUtils.encodeToByteArray(coder, "aaaa"),
        CoderUtils.encodeToByteArray(coder, "abcd"),
        CoderUtils.encodeToByteArray(coder, "abce"),
        CoderUtils.encodeToByteArray(coder, "abdd"),
        CoderUtils.encodeToByteArray(coder, "accd"),
        CoderUtils.encodeToByteArray(coder, "bbcd")
    };
  } catch (CoderException e) {
    throw new RuntimeException("Could not encode values.", e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:EncodedValueComparatorTest.java

示例3: encode

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Override
public void encode(InvoiceGroupingKey value, OutputStream outStream) throws IOException {
  Coder<String> stringCoder = StringUtf8Coder.of();
  stringCoder.encode(value.startDate(), outStream);
  stringCoder.encode(value.endDate(), outStream);
  stringCoder.encode(value.productAccountKey(), outStream);
  stringCoder.encode(value.usageGroupingKey(), outStream);
  stringCoder.encode(value.description(), outStream);
  stringCoder.encode(String.valueOf(value.unitPrice()), outStream);
  stringCoder.encode(value.unitPriceCurrency(), outStream);
  stringCoder.encode(value.poNumber(), outStream);
}
 
开发者ID:google,项目名称:nomulus,代码行数:13,代码来源:BillingEvent.java

示例4: testAppend

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
public void testAppend() throws Exception {
  FakeBeamFnStateClient fakeClient = new FakeBeamFnStateClient(ImmutableMap.of(
      key("A"), encode("A1")));
  BagUserState<String> userState =
      new BagUserState<>(fakeClient, "A", StringUtf8Coder.of(), () -> requestForId("A"));
  userState.append("A2");
  userState.append("A3");
  userState.asyncClose();

  assertEquals(encode("A1", "A2", "A3"), fakeClient.getData().get(key("A")));
  thrown.expect(IllegalStateException.class);
  userState.append("A4");
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:BagUserStateTest.java

示例5: test

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
  ApexPipelineOptions options = PipelineOptionsFactory.create()
      .as(ApexPipelineOptions.class);
  EmbeddedCollector.RESULTS.clear();
  options.setApplicationName("ReadUnbound");
  options.setRunner(ApexRunner.class);
  Pipeline p = Pipeline.create(options);

  List<String> collection = Lists.newArrayList("1", "2", "3", "4", "5");
  CollectionSource<String> source = new CollectionSource<>(collection, StringUtf8Coder.of());
  p.apply(Read.from(source))
      .apply(ParDo.of(new EmbeddedCollector()));

  ApexRunnerResult result = (ApexRunnerResult) p.run();
  DAG dag = result.getApexDAG();
  DAG.OperatorMeta om = dag.getOperatorMeta("Read(CollectionSource)");
  Assert.assertNotNull(om);
  Assert.assertEquals(om.getOperator().getClass(), ApexReadUnboundedInputOperator.class);

  long timeout = System.currentTimeMillis() + 30000;
  while (System.currentTimeMillis() < timeout) {
    if (EmbeddedCollector.RESULTS.containsAll(collection)) {
      break;
    }
    LOG.info("Waiting for expected results.");
    Thread.sleep(1000);
  }
  Assert.assertEquals(Sets.newHashSet(collection), EmbeddedCollector.RESULTS);
}
 
开发者ID:apache,项目名称:beam,代码行数:31,代码来源:ReadUnboundTranslatorTest.java

示例6: testCheckpointCoderNulls

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
public void testCheckpointCoderNulls() throws Exception {
  CheckpointCoder<String> coder = new CheckpointCoder<>(StringUtf8Coder.of());
  Checkpoint<String> emptyCheckpoint = new Checkpoint<>(null, null);
  Checkpoint<String> decodedEmptyCheckpoint = CoderUtils.decodeFromByteArray(
      coder,
      CoderUtils.encodeToByteArray(coder, emptyCheckpoint));
  assertNull(decodedEmptyCheckpoint.getResidualElements());
  assertNull(decodedEmptyCheckpoint.getResidualSource());
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:UnboundedReadFromBoundedSourceTest.java

示例7: translate

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Override
public void translate(Flatten.PCollections<T> transform, TranslationContext context) {
  JavaStream<T> merged = null;
  Set<PCollection<T>> unique = new HashSet<>();
  for (PValue input: context.getInputs().values()) {
    PCollection<T> collection = (PCollection<T>) input;
    JavaStream<T> inputStream = context.getInputStream(collection);
    if (null == merged) {
      merged = inputStream;
    } else {
      // duplicate edges are not allowed in Gearpump graph
      // so we route through a dummy node
      if (unique.contains(collection)) {
        inputStream = inputStream.map(new DummyFunction<T>(), "dummy");
      }

      merged = merged.merge(inputStream, 1, transform.getName());
    }
    unique.add(collection);
  }

  if (null == merged) {
    UnboundedSourceWrapper<String, ?> unboundedSourceWrapper = new UnboundedSourceWrapper<>(
        new ValuesSource<>(Lists.newArrayList("dummy"),
            StringUtf8Coder.of()), context.getPipelineOptions());
    merged = context.getSourceStream(unboundedSourceWrapper);
  }
  context.setOutputStream(context.getOutput(), merged);
}
 
开发者ID:apache,项目名称:beam,代码行数:30,代码来源:FlattenPCollectionsTranslator.java

示例8: getOutputCoder

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Override
public Coder<String> getOutputCoder() {
  return StringUtf8Coder.of();
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:TextSource.java

示例9: newTracker

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
private static GrowthTracker<String, String, Integer> newTracker(
    GrowthState<String, String, Integer> state) {
  return new GrowthTracker<>(
      SerializableFunctions.<String>identity(), StringUtf8Coder.of(), state, never());
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:WatchTest.java

示例10: getDestinationCoder

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Nullable
@Override
public Coder<String> getDestinationCoder() {
  return StringUtf8Coder.of();
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:TextIOWriteTest.java

示例11: testWriteWithWritableByteChannelFactory

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
@Category(NeedsRunner.class)
public void testWriteWithWritableByteChannelFactory() throws Exception {
  Coder<String> coder = StringUtf8Coder.of();
  String outputName = "file.txt";
  ResourceId baseDir =
      FileSystems.matchNewResource(
          Files.createTempDirectory(tempFolder.getRoot().toPath(), "testwrite").toString(), true);

  PCollection<String> input = p.apply(Create.of(Arrays.asList(LINES2_ARRAY)).withCoder(coder));

  final WritableByteChannelFactory writableByteChannelFactory =
      new DrunkWritableByteChannelFactory();
  TextIO.Write write =
      TextIO.write()
          .to(
              baseDir
                  .resolve(outputName, ResolveOptions.StandardResolveOptions.RESOLVE_FILE)
                  .toString())
          .withoutSharding()
          .withWritableByteChannelFactory(writableByteChannelFactory);
  DisplayData displayData = DisplayData.from(write);
  assertThat(displayData, hasDisplayItem("writableByteChannelFactory", "DRUNK"));

  input.apply(write);

  p.run();

  final List<String> drunkElems = new ArrayList<>(LINES2_ARRAY.length * 2 + 2);
  for (String elem : LINES2_ARRAY) {
    drunkElems.add(elem);
    drunkElems.add(elem);
  }
  assertOutputFiles(
      drunkElems.toArray(new String[0]),
      null,
      null,
      1,
      baseDir.resolve(
          outputName + writableByteChannelFactory.getSuggestedFilenameSuffix(),
          ResolveOptions.StandardResolveOptions.RESOLVE_FILE),
      write.inner.getShardTemplate());
}
 
开发者ID:apache,项目名称:beam,代码行数:44,代码来源:TextIOWriteTest.java

示例12: SerializedMutationCoder

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
private SerializedMutationCoder() {
  byteArrayCoder = ByteArrayCoder.of();
  stringCoder = StringUtf8Coder.of();
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:SerializedMutationCoder.java

示例13: createStateInternals

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Override
protected StateInternals createStateInternals() {
  KeyedStateBackend keyedStateBackend =
      getKeyedStateBackend(2, new KeyGroupRange(0, 1));
  return new FlinkKeyGroupStateInternals<>(StringUtf8Coder.of(), keyedStateBackend);
}
 
开发者ID:apache,项目名称:beam,代码行数:7,代码来源:FlinkKeyGroupStateInternalsTest.java

示例14: shouldWriteAndReadSnapshotForConcreteClassCoder

import org.apache.beam.sdk.coders.StringUtf8Coder; //导入方法依赖的package包/类
@Test
public void shouldWriteAndReadSnapshotForConcreteClassCoder() throws Exception {
  Coder<String> concreteClassCoder = StringUtf8Coder.of();
  testWriteAndReadConfigSnapshot(concreteClassCoder);
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:CoderTypeSerializerTest.java


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