Tabnine Logo
ByteString.copyFrom
Code IndexAdd Tabnine to your IDE (free)

How to use
copyFrom
method
in
org.apache.beam.vendor.grpc.v1_13_1.com.google.protobuf.ByteString

Best Java code snippets using org.apache.beam.vendor.grpc.v1_13_1.com.google.protobuf.ByteString.copyFrom (Showing top 20 results out of 315)

origin: org.apache.beam/beam-runners-core-construction-java

private static RunnerApi.Coder toKnownCoder(Coder<?> coder, SdkComponents components)
  throws IOException {
 CoderTranslator translator = KNOWN_TRANSLATORS.get(coder.getClass());
 List<String> componentIds = registerComponents(coder, translator, components);
 return RunnerApi.Coder.newBuilder()
   .addAllComponentCoderIds(componentIds)
   .setSpec(
     SdkFunctionSpec.newBuilder()
       .setSpec(
         FunctionSpec.newBuilder()
           .setUrn(KNOWN_CODER_URNS.get(coder.getClass()))
           .setPayload(ByteString.copyFrom(translator.getPayload(coder)))))
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

private static SdkFunctionSpec toProto(String urn, Serializable serializable) {
 return SdkFunctionSpec.newBuilder()
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(urn)
       .setPayload(
         ByteString.copyFrom(SerializableUtils.serializeToByteArray(serializable)))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-direct-java

@Override
public void getArtifact(
  ArtifactApi.GetArtifactRequest request,
  StreamObserver<ArtifactApi.ArtifactChunk> responseObserver) {
 try {
  ByteBuffer artifact = getArtifact(request.getName());
  do {
   responseObserver.onNext(
     ArtifactChunk.newBuilder()
       .setData(
         ByteString.copyFrom(
           artifact, Math.min(artifact.remaining(), DEFAULT_CHUNK_SIZE)))
       .build());
  } while (artifact.hasRemaining());
  responseObserver.onCompleted();
 } catch (FileNotFoundException e) {
  responseObserver.onError(
    Status.INVALID_ARGUMENT
      .withDescription(String.format("No such artifact %s", request.getName()))
      .withCause(e)
      .asException());
 } catch (Exception e) {
  responseObserver.onError(
    Status.INTERNAL
      .withDescription(
        String.format("Could not retrieve artifact with name %s", request.getName()))
      .withCause(e)
      .asException());
 }
}
origin: org.apache.beam/beam-runners-core-construction-java

 @Override
 public FunctionSpec translate(
   AppliedPTransform<?, ?, View.CreatePCollectionView<?, ?>> transform,
   SdkComponents components) {
  return FunctionSpec.newBuilder()
    .setUrn(getUrn(transform.getTransform()))
    .setPayload(
      ByteString.copyFrom(
        SerializableUtils.serializeToByteArray(transform.getTransform().getView())))
    .build();
 }
}
origin: org.apache.beam/beam-runners-core-construction-java

channel.read(readBuffer);
readBuffer.flip();
ByteString chunk = ByteString.copyFrom(readBuffer);
origin: org.apache.beam/beam-runners-core-construction-java

private static SdkFunctionSpec toProto(BoundedSource<?> source, SdkComponents components) {
 return SdkFunctionSpec.newBuilder()
   .setEnvironmentId(components.getOnlyEnvironmentId())
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(JAVA_SERIALIZED_BOUNDED_SOURCE)
       .setPayload(ByteString.copyFrom(SerializableUtils.serializeToByteArray(source)))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

 public static SdkFunctionSpec toProto(
   GlobalCombineFn<?, ?, ?> combineFn, SdkComponents components) {
  return SdkFunctionSpec.newBuilder()
    .setEnvironmentId(components.getOnlyEnvironmentId())
    .setSpec(
      FunctionSpec.newBuilder()
        .setUrn(JAVA_SERIALIZED_COMBINE_FN_URN)
        .setPayload(ByteString.copyFrom(SerializableUtils.serializeToByteArray(combineFn)))
        .build())
    .build();
 }
}
origin: org.apache.beam/beam-runners-core-construction-java

public static SdkFunctionSpec translateWindowMappingFn(
  WindowMappingFn<?> windowMappingFn, SdkComponents components) {
 return SdkFunctionSpec.newBuilder()
   .setEnvironmentId(components.getOnlyEnvironmentId())
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(CUSTOM_JAVA_WINDOW_MAPPING_FN_URN)
       .setPayload(
         ByteString.copyFrom(SerializableUtils.serializeToByteArray(windowMappingFn)))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

public static SdkFunctionSpec translateViewFn(ViewFn<?, ?> viewFn, SdkComponents components) {
 return SdkFunctionSpec.newBuilder()
   .setEnvironmentId(components.getOnlyEnvironmentId())
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(CUSTOM_JAVA_VIEW_FN_URN)
       .setPayload(ByteString.copyFrom(SerializableUtils.serializeToByteArray(viewFn)))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

private static SdkFunctionSpec toProto(UnboundedSource<?, ?> source, SdkComponents components) {
 return SdkFunctionSpec.newBuilder()
   .setEnvironmentId(components.getOnlyEnvironmentId())
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(JAVA_SERIALIZED_UNBOUNDED_SOURCE)
       .setPayload(ByteString.copyFrom(SerializableUtils.serializeToByteArray(source)))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

private static RunnerApi.Coder toCustomCoder(Coder<?> coder) throws IOException {
 RunnerApi.Coder.Builder coderBuilder = RunnerApi.Coder.newBuilder();
 return coderBuilder
   .setSpec(
     SdkFunctionSpec.newBuilder()
       .setSpec(
         FunctionSpec.newBuilder()
           .setUrn(JAVA_SERIALIZED_CODER_URN)
           .setPayload(
             ByteString.copyFrom(SerializableUtils.serializeToByteArray(coder)))
           .build()))
   .build();
}
origin: org.apache.beam/beam-runners-core-construction-java

public static SdkFunctionSpec translateDoFn(
  DoFn<?, ?> fn, TupleTag<?> tag, SdkComponents components) {
 return SdkFunctionSpec.newBuilder()
   .setEnvironmentId(components.getOnlyEnvironmentId())
   .setSpec(
     FunctionSpec.newBuilder()
       .setUrn(CUSTOM_JAVA_DO_FN_URN)
       .setPayload(
         ByteString.copyFrom(
           SerializableUtils.serializeToByteArray(DoFnAndMainOutput.of(fn, tag))))
       .build())
   .build();
}
origin: org.apache.beam/beam-runners-direct-java

@Test
public void putArtifactBeforeNameFails() {
 byte[] data = "foo-".getBytes(UTF_8);
 RecordingStreamObserver<ArtifactApi.PutArtifactResponse> responseObserver =
   new RecordingStreamObserver<>();
 StreamObserver<ArtifactApi.PutArtifactRequest> requestObserver =
   stub.putArtifact(responseObserver);
 requestObserver.onNext(
   ArtifactApi.PutArtifactRequest.newBuilder()
     .setData(
       ArtifactApi.ArtifactChunk.newBuilder().setData(ByteString.copyFrom(data)).build())
     .build());
 responseObserver.awaitTerminalState();
 assertThat(responseObserver.error, Matchers.not(Matchers.nullValue()));
}
origin: org.apache.beam/beam-runners-core-construction-java

.setTimestamp(element.getTimestamp().getMillis())
.setEncodedElement(
  ByteString.copyFrom(
    CoderUtils.encodeToByteArray(coder, element.getValue()))));
origin: org.apache.beam/beam-runners-direct-java

@Test
public void singleDataPutArtifactSucceeds() throws Exception {
 byte[] data = "foo-bar-baz".getBytes(UTF_8);
 RecordingStreamObserver<ArtifactApi.PutArtifactResponse> responseObserver =
   new RecordingStreamObserver<>();
 StreamObserver<ArtifactApi.PutArtifactRequest> requestObserver =
   stub.putArtifact(responseObserver);
 String name = "my-artifact";
 requestObserver.onNext(
   ArtifactApi.PutArtifactRequest.newBuilder()
     .setMetadata(
       ArtifactApi.PutArtifactMetadata.newBuilder()
         .setMetadata(ArtifactApi.ArtifactMetadata.newBuilder().setName(name).build())
         .setStagingSessionToken("token")
         .build())
     .build());
 requestObserver.onNext(
   ArtifactApi.PutArtifactRequest.newBuilder()
     .setData(
       ArtifactApi.ArtifactChunk.newBuilder().setData(ByteString.copyFrom(data)).build())
     .build());
 requestObserver.onCompleted();
 responseObserver.awaitTerminalState();
 File staged = stager.getLocation().getArtifactFile(name);
 assertThat(staged.exists(), is(true));
 ByteBuffer buf = ByteBuffer.allocate(data.length);
 new FileInputStream(staged).getChannel().read(buf);
 Assert.assertArrayEquals(data, buf.array());
}
origin: org.apache.beam/beam-runners-direct-java

.setData(
  ArtifactApi.ArtifactChunk.newBuilder()
    .setData(ByteString.copyFrom(partOne))
    .build())
.build());
.setData(
  ArtifactApi.ArtifactChunk.newBuilder()
    .setData(ByteString.copyFrom(partTwo))
    .build())
.build());
.setData(
  ArtifactApi.ArtifactChunk.newBuilder()
    .setData(ByteString.copyFrom(partThree))
    .build())
.build());
origin: org.apache.beam/beam-runners-core-construction-java

.setUrn(JAVA_SERIALIZED_COMBINE_FN_URN)
.setPayload(
  ByteString.copyFrom(
    SerializableUtils.serializeToByteArray(
      combine.getTransform().getFn())))
origin: org.apache.beam/beam-runners-core-construction-java

ByteString serializedFn = ByteString.copyFrom(SerializableUtils.serializeToByteArray(windowFn));
if (windowFn instanceof GlobalWindows) {
 return SdkFunctionSpec.newBuilder()
origin: org.apache.beam/beam-runners-core-construction-java

    .build();
ByteString newPayload = ByteString.copyFrom("foo-bar-baz".getBytes(StandardCharsets.UTF_8));
Pipeline updated =
  ProtoOverrides.updateTransform(
origin: org.apache.beam/beam-runners-direct-java

private ArtifactApi.ArtifactMetadata stageBytes(String name, byte[] bytes) {
 StreamObserver<ArtifactApi.PutArtifactRequest> requests =
   stub.putArtifact(new RecordingStreamObserver<>());
 requests.onNext(
   ArtifactApi.PutArtifactRequest.newBuilder()
     .setMetadata(
       ArtifactApi.PutArtifactMetadata.newBuilder()
         .setMetadata(ArtifactApi.ArtifactMetadata.newBuilder().setName(name).build())
         .setStagingSessionToken("token")
         .build())
     .build());
 requests.onNext(
   ArtifactApi.PutArtifactRequest.newBuilder()
     .setData(
       ArtifactApi.ArtifactChunk.newBuilder().setData(ByteString.copyFrom(bytes)).build())
     .build());
 requests.onCompleted();
 return ArtifactApi.ArtifactMetadata.newBuilder().setName(name).build();
}
org.apache.beam.vendor.grpc.v1_13_1.com.google.protobufByteStringcopyFrom

Popular methods of ByteString

  • toByteArray
  • copyFromUtf8
  • writeTo

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • runOnUiThread (Activity)
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • ImageIO (javax.imageio)
  • JFileChooser (javax.swing)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now