Method overriden by subclasses to optimize the MultiStream behavior.
166690
def _MultiStream(cls, fds):
    """"""
    for fd in fds:
      fd.Seek(0)
      while True:
        chunk = fd.Read(cls.MULTI_STREAM_CHUNK_SIZE)
        if not chunk:
          break
        yield fd, chunk, None
476344
@GwtIncompatible("Unnecessary")
  private Writer streamToLegacyOutputWriter(OutputStream stream) throws IOException {
    if (legacyOutputCharset == null) {
      return new BufferedWriter(new OutputStreamWriter(stream, UTF_8));
    } else {
      return new BufferedWriter(
          new OutputStreamWriter(stream, legacyOutputCharset));
    }
  }
1193778
@PublicEvolving
	public SingleOutputStreamOperator<T> forceNonParallel() {
		transformation.setParallelism(1);
		transformation.setMaxParallelism(1);
		nonParallel = true;
		return this;
	}
768016
def modify_class(original_class, modifier_class, override=True):
    
    # get members to add
    modifier_methods = inspect.getmembers(modifier_class, inspect.ismethod)
    
    # set methods
    for method_tuple in modifier_methods:
        name = method_tuple[0]
        method = method_tuple[1]
        if isinstance(method, types.UnboundMethodType):
            if hasattr(original_class, name) and not override:
                return None
            else:
                setattr(original_class, name, method.im_func)
213931
private static Spliterator.OfInt adapt(Spliterator<Integer> s) {
        if (s instanceof Spliterator.OfInt) {
            return (Spliterator.OfInt) s;
        }
        else {
//            if (Tripwire.ENABLED)
//                Tripwire.trip(AbstractPipeline.class,
//                              "using IntStream.adapt(Spliterator<Integer> s)");
            throw new UnsupportedOperationException("IntStream.adapt(Spliterator<Integer> s)");
        }
    }
301446
public void run() throws IOException, ClassNotFoundException, Util.Exit {
        int i = 0;
        if (outFile != null) {
            /* Everything goes to one big file... */
            ByteArrayOutputStream bout = new ByteArrayOutputStream(8192);
            writeFileTop(bout); /* only once */

            for (TypeElement t: classes) {
                write(bout, t);
            }

            writeIfChanged(bout.toByteArray(), outFile);
        } else {
            /* Each class goes to its own file... */
            for (TypeElement t: classes) {
                ByteArrayOutputStream bout = new ByteArrayOutputStream(8192);
                writeFileTop(bout);
                write(bout, t);
                writeIfChanged(bout.toByteArray(), getFileObject(t.getQualifiedName()));
            }
        }
    }
712129
private static void readFully(final DataInput input, final float[] floats) throws IOException {
        if (input instanceof ImageInputStream) {
            // Optimization for ImageInputStreams, read all in one go
            ((ImageInputStream) input).readFully(floats, 0, floats.length);
        }
        else {
            for (int i = 0; i < floats.length; i++) {
                floats[i] = input.readFloat();
            }
        }
    }
1008703
private static List<Method> adaptConstructors(List<Method> methods, TypeDef target) {
        List<Method> adapted = new ArrayList<Method>();
        for (Method m : methods) {
            adapted.add(new MethodBuilder(m)
                    .withName(null)
                    .withReturnType(target.toUnboundedReference())
                    .build());
        }
        return adapted;
    }
491445
def open_multi(cls, sock, chunk_types, isattys, chunk_eof_type=None, buf_size=None,
                 select_timeout=None):
    """"""
    cls._assert_aligned(chunk_types, isattys)

    # N.B. This is purely to permit safe handling of a dynamic number of contextmanagers.
    with ExitStack() as stack:
      read_fds, write_fds = list(zip(
        # Allocate one pipe pair per chunk type provided.
        *(stack.enter_context(_pipe(isatty)) for isatty in isattys)
      ))
      writer = NailgunStreamWriter(
        read_fds,
        sock,
        chunk_types,
        chunk_eof_type,
        buf_size=buf_size,
        select_timeout=select_timeout
      )
      with writer.running():
        yield write_fds, writer
1227887
def make_limited_stream(stream, limit):
    """"""
    if not isinstance(stream, LimitedStream):
        if limit is None:
            raise TypeError('stream not limited and no limit provided.')
        stream = LimitedStream(stream, limit)
    return stream
1036437
void cleanup(Http2Stream stream, EmbeddedChannel compressor) {
        if (compressor.finish()) {
            for (;;) {
                final ByteBuf buf = compressor.readOutbound();
                if (buf == null) {
                    break;
                }

                buf.release();
            }
        }
        stream.removeProperty(propertyKey);
    }
467931
protected void overrideXtextInternalLoggers() {
		final Logger logger = getLogger();
		final org.apache.log4j.spi.LoggerFactory factory = new InternalXtextLoggerFactory(logger);
		final org.apache.log4j.Logger internalLogger = org.apache.log4j.Logger.getLogger(
				MessageFormat.format(Messages.SarlBatchCompiler_40, logger.getName()), factory);
		setStaticField(BatchLinkableResourceStorageWritable.class, "LOG", internalLogger); //$NON-NLS-1$
		setStaticField(BatchLinkableResource.class, "log", internalLogger); //$NON-NLS-1$
		setStaticField(ProcessorInstanceForJvmTypeProvider.class, "logger", internalLogger); //$NON-NLS-1$
	}
201356
protected void writeToSerializedStream(ObjectOutputStream stream) throws IOException {
        stream.writeLong(cas);
        stream.writeInt(expiry);
        stream.writeUTF(id);
        stream.writeObject(content);
        stream.writeObject(mutationToken);
    }
660458
def dispatch(self, receiver):
        ''' 

        '''
        super(ColumnsStreamedEvent, self).dispatch(receiver)
        if hasattr(receiver, '_columns_streamed'):
            receiver._columns_streamed(self)
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));
    }
666120
private Stream<ImmutableSubstitution<ImmutableTerm>> splitSubstitution(
            ImmutableSubstitution<ImmutableTerm> substitution, VariableGenerator variableGenerator) {

        ImmutableMultimap<Variable, Integer> functionSubTermMultimap = substitution.getImmutableMap().entrySet().stream()
                .filter(e -> e.getValue() instanceof ImmutableFunctionalTerm)
                .flatMap(e -> {
                    ImmutableList<? extends ImmutableTerm> subTerms = ((ImmutableFunctionalTerm) e.getValue()).getTerms();
                    return IntStream.range(0, subTerms.size())
                            .filter(i -> subTerms.get(i) instanceof ImmutableFunctionalTerm)
                            .boxed()
                            .map(i -> Maps.immutableEntry(e.getKey(), i));
                })
                .collect(ImmutableCollectors.toMultimap());

        if (functionSubTermMultimap.isEmpty())
            return Stream.of(substitution);

        ImmutableTable<Variable, Integer, Variable> subTermNames = functionSubTermMultimap.entries().stream()
                .map(e -> Tables.immutableCell(e.getKey(), e.getValue(), variableGenerator.generateNewVariable()))
                .collect(ImmutableCollectors.toTable());

        ImmutableMap<Variable, ImmutableTerm> parentSubstitutionMap = substitution.getImmutableMap().entrySet().stream()
                .map(e ->
                        Optional.ofNullable(functionSubTermMultimap.get(e.getKey()))
                                .map(indexes -> {
                                    Variable v = e.getKey();
                                    ImmutableFunctionalTerm def = (ImmutableFunctionalTerm) substitution.get(v);
                                    ImmutableList<ImmutableTerm> newArgs = IntStream.range(0, def.getArity())
                                            .boxed()
                                            .map(i -> Optional.ofNullable((ImmutableTerm) subTermNames.get(v, i))
                                                    .orElseGet(() -> def.getTerm(i)))
                                            .collect(ImmutableCollectors.toList());

                                    ImmutableTerm newDef = termFactory.getImmutableFunctionalTerm(
                                            def.getFunctionSymbol(), newArgs);
                                    return Maps.immutableEntry(v, newDef);
                                })
                                .orElse(e))
                .collect(ImmutableCollectors.toMap());

        ImmutableSubstitution<ImmutableTerm> parentSubstitution = substitutionFactory.getSubstitution(parentSubstitutionMap);


        ImmutableSubstitution<ImmutableTerm> childSubstitution = substitutionFactory.getSubstitution(
                subTermNames.cellSet().stream()
                    .collect(ImmutableCollectors.toMap(
                        Table.Cell::getValue,
                        c -> ((ImmutableFunctionalTerm) substitution.get(c.getRowKey())).getTerm(c.getColumnKey()))));

        return Stream.concat(
                // Recursive
                splitSubstitution(childSubstitution, variableGenerator),
                Stream.of(parentSubstitution));
    }
1127578
protected JSONReader _with(int features,
            ValueReaderLocator td, TreeCodec tc, CollectionBuilder lb, MapBuilder mb)
    {
        if (getClass() != JSONReader.class) { // sanity check
            throw new IllegalStateException("Sub-classes MUST override _with(...)");
        }
        return new JSONReader(features, td, tc, lb, mb);
    }