Creates StreamDescriptor which is a copy of this one with the value of sequence changed to
the value passed in.  Recursively calls itself on the nested streams.
355662
private static StreamDescriptor copyStreamDescriptorWithSequence(StreamDescriptor streamDescriptor, int sequence)
    {
        List<StreamDescriptor> streamDescriptors = streamDescriptor.getNestedStreams().stream()
                .map(stream -> copyStreamDescriptorWithSequence(stream, sequence))
                .collect(toImmutableList());

        return new StreamDescriptor(
                streamDescriptor.getStreamName(),
                streamDescriptor.getStreamId(),
                streamDescriptor.getFieldName(),
                streamDescriptor.getStreamType(),
                streamDescriptor.getOrcDataSource(),
                streamDescriptors,
                sequence);
    }
960285
public static StreamShardHandle convertToStreamShardHandle(StreamShardMetadata streamShardMetadata) {
		Shard shard = new Shard();
		shard.withShardId(streamShardMetadata.getShardId());
		shard.withParentShardId(streamShardMetadata.getParentShardId());
		shard.withAdjacentParentShardId(streamShardMetadata.getAdjacentParentShardId());

		HashKeyRange hashKeyRange = new HashKeyRange();
		hashKeyRange.withStartingHashKey(streamShardMetadata.getStartingHashKey());
		hashKeyRange.withEndingHashKey(streamShardMetadata.getEndingHashKey());
		shard.withHashKeyRange(hashKeyRange);

		SequenceNumberRange sequenceNumberRange = new SequenceNumberRange();
		sequenceNumberRange.withStartingSequenceNumber(streamShardMetadata.getStartingSequenceNumber());
		sequenceNumberRange.withEndingSequenceNumber(streamShardMetadata.getEndingSequenceNumber());
		shard.withSequenceNumberRange(sequenceNumberRange);

		return new StreamShardHandle(streamShardMetadata.getStreamName(), shard);
	}
885206
private void customizeStream(Number streamId, AbstractClientStream stream) {
        Integer buffer = streamBuffers.get(streamId.doubleValue());
        if (buffer != null) {
            stream.setClientBufferDuration(buffer);
        }
        stream.setName(createStreamName());
        stream.setConnection(this);
        stream.setScope(this.getScope());
        stream.setStreamId(streamId);
    }
1122387
@SafeVarargs
    @SuppressWarnings("unchecked")
    public static <T> Stream<T> stream(Iterable<T>... iterables) {
        List<Iterator<T>> iterators = Arrays.stream(iterables)
            .map(Iterable::iterator)
            .collect(Collectors.toList());

        return stream(iterators.toArray(new Iterator[iterables.length]));
    }
922651
public <T> T read(final InputStream stream, final DataTypeDescriptor<T> descriptor)
			throws Exception {
		if (stream == null) throw new NullPointerException("input");
		if (descriptor == null) throw new NullPointerException("descriptor");

		JsonParser parser = factory.createParser(stream);
		return read(parser, descriptor);
	}
1006148
@Override
    public java.util.concurrent.Future<DescribeStreamResult> describeStreamAsync(String streamName, Integer limit, String exclusiveStartShardId) {

        return describeStreamAsync(new DescribeStreamRequest().withStreamName(streamName).withLimit(limit).withExclusiveStartShardId(exclusiveStartShardId));
    }
717210
function _createStreamPointer(self, stream, serializer) {
  let id = uuid();
  let readable = typeof stream.read === 'function';
  let type = readable ? 'readable' : 'writable';
  let pointer = `boscar:${type}:${id}`;

  self.streams.set(id, stream);

  if (readable) {
    _bindReadable(pointer, stream, serializer);
  }

  return pointer;
}
268487
public static <T> T copy(final T object, final DataTypeDescriptor<T> descriptor) {
		if (descriptor == null) {
			throw new NullPointerException("descriptor");
		}

		return copy(object, descriptor.getType());
	}
956485
private static CopyStreamListener createListener() {
        return new CopyStreamListener() {
            private long megsTotal = 0;

            // @Override
            @Override
            public void bytesTransferred(CopyStreamEvent event) {
                bytesTransferred(event.getTotalBytesTransferred(), event.getBytesTransferred(), event.getStreamSize());
            }

            // @Override
            @Override
            public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) {
                long megs = totalBytesTransferred / 1000000;
                for (long l = megsTotal; l < megs; l++) {
                    System.err.print("#");
                }
                megsTotal = megs;
            }
        };
    }
815700
public U duplicateStream(boolean lastStream) {
        if (!processor.isDuplicable()) {
            throw new IllegalStateException("duplicator is closed or last downstream is added.");
        }
        return doDuplicateStream(new ChildStreamMessage<>(this, processor, lastStream));
    }
172731
public static <T> Stream<T> create(final Iteration<? extends T, ?> iteration) {
        return new IterationStream<T>(iteration);
    }
24025
@SafeVarargs
    public static <U> SimpleReactStream<U> firstOf(final SimpleReactStream<U>... futureStreams) {
        final List<Tuple2<SimpleReactStream<U>, QueueReader>> racers = Stream.of(futureStreams)
                                                                             .map(s -> Tuple.tuple(s, new Queue.QueueReader(
                                                                                                                            s.toQueue(), null)))
                                                                             .collect(Collectors.toList());
        while (true) {
            for (final Tuple2<SimpleReactStream<U>, Queue.QueueReader> q : racers) {
                if (q._2().notEmpty()) {
                    EagerFutureStreamFunctions.closeOthers(q._2().getQueue(), racers.stream()
                                                                                  .map(t -> t._2().getQueue())
                                                                                  .collect(Collectors.toList()));
                    closeOthers(q._1(), racers.stream()
                                                                       .map(t -> t._1())
                                                                       .collect(Collectors.toList()));
                    return q._1().fromStream(q._2().getQueue()
                                               .stream(q._1().getSubscription()));
                }

            }
            LockSupport.parkNanos(1l);
        }

    }
238776
@Override
    public T fromStream(final InputStream in, final boolean close) throws IllegalArgumentException,
        DescriptorImportException {
        // Precondition check
        if (in == null) {
            throw new IllegalArgumentException("InputStream must be specified");
        }

        final Node rootNode = this.getNodeImporter().importAsNode(in, close);

        // Create the end-user view
        final Constructor<T> constructor;
        try {
            constructor = endUserViewImplType.getConstructor(String.class, Node.class);
        } catch (final NoSuchMethodException e) {
            throw new DescriptorImportException("Descriptor impl " + endUserViewImplType.getName()
                + " does not have a constructor accepting " + String.class.getName() + " and " + Node.class.getName(),
                e);
        }
        final T descriptor;
        try {
            descriptor = constructor.newInstance(descriptorName, rootNode);
        } catch (final Exception e) {
            throw new DescriptorImportException("Could not create new instance using " + constructor + " with arg: "
                + rootNode);
        }

        // Return
        return descriptor;
    }
819800
@Override
    public Object mapSequence(Object sequence) {
        List<List<Integer>> seq = (List<List<Integer>>) sequence;
        List<Integer> ret = new ArrayList<>();
        for (List<Integer> step : seq)
            ret.add((Integer) map(step));
        return ret;
    }
1222061
public <T> void write(final OutputStream stream, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) throws IOException {
		if (stream == null) throw new NullPointerException("out");
		if (descriptor == null) throw new NullPointerException("descriptor");

		JsonGenerator generator = factory.createGenerator(stream);
		if (indent) {
			generator.useDefaultPrettyPrinter();
		}

		write(object, descriptor, generator);
		generator.flush();
	}
126247
public List<List<Writable>> transformRawStringsToInputSequence(List<List<String>> sequence) {
        List<List<Writable>> ret = new ArrayList<>();
        for(List<String> input : sequence)
            ret.add(transformRawStringsToInputList(input));
        return ret;
    }
1024699
@Override
    public T fromStream(final InputStream in) throws IllegalArgumentException, DescriptorImportException {
        return fromStream(in, true);
    }