Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Google Cloud Dataflow Java SDK provides a simple, Java-based
interface for processing virtually any size data using Google cloud
resources. This artifact includes entire Dataflow Java SDK.
/*
* Copyright (C) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.cloud.dataflow.sdk.coders;
import com.google.cloud.dataflow.sdk.util.BufferedElementCountingOutputStream;
import com.google.cloud.dataflow.sdk.util.VarInt;
import com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObservableIterable;
import com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver;
import com.google.common.base.Preconditions;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
/**
* An abstract base class with functionality for assembling a
* {@link Coder} for a class that implements {@code Iterable}.
*
*
To complete a subclass, implement the {@link #decodeToIterable} method. This superclass
* will decode the elements in the input stream into a {@link List} and then pass them to that
* method to be converted into the appropriate iterable type. Note that this means the input
* iterables must fit into memory.
*
*
The format of this coder is as follows:
*
*
*
If the input {@link Iterable} has a known and finite size, then the size is written to the
* output stream in big endian format, followed by all of the encoded elements.
*
If the input {@link Iterable} is not known to have a finite size, then each element
* of the input is preceded by {@code true} encoded as a byte (indicating "more data")
* followed by the encoded element, and terminated by {@code false} encoded as a byte.
*
*
* @param the type of the elements of the {@code Iterable}s being transcoded
* @param the type of the Iterables being transcoded
*/
public abstract class IterableLikeCoder>
extends StandardCoder {
public Coder getElemCoder() {
return elementCoder;
}
/**
* Builds an instance of {@code IterableT}, this coder's associated {@link Iterable}-like
* subtype, from a list of decoded elements.
*/
protected abstract IterableT decodeToIterable(List decodedElements);
/////////////////////////////////////////////////////////////////////////////
// Internal operations below here.
private final Coder elementCoder;
private final String iterableName;
/**
* Returns the first element in the iterable-like {@code exampleValue} if it is non-empty,
* otherwise returns {@code null}.
*/
protected static >
List