All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linkedin.dagli.objectio.WrappedObjectReader Maven / Gradle / Ivy

Go to download

DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages

There is a newer version: 15.0.0-beta9
Show newest version
package com.linkedin.dagli.objectio;

import it.unimi.dsi.fastutil.BigList;
import java.util.Collection;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;


/**
 * Base class for an {@link ObjectReader} that redirects all operations to its wrapped instance.
 */
public abstract class WrappedObjectReader implements ObjectReader {
  protected final ObjectReader _wrapped;

  /**
   * Creates a new instance that will wrap the provided reader.
   *
   * @param wrapped the reader wrapped by this instance
   */
  public WrappedObjectReader(ObjectReader wrapped) {
    _wrapped = ObjectReader.cast(wrapped);
  }

  @Override
  public long size64() {
    return _wrapped.size64();
  }

  @Override
  public ObjectIterator iterator() {
    return _wrapped.iterator();
  }

  @Override
  public void forEach(Consumer action) {
    _wrapped.forEach(action);
  }

  @Override
  public void forEachBatch(int batchSize, Consumer> action) {
    _wrapped.forEachBatch(batchSize, action);
  }

  @Override
  public void close() {
    _wrapped.close();
  }

  @Override
  public Stream> batchStream(int batchSize) {
    return _wrapped.batchStream(batchSize);
  }

  @Override
  public Stream stream() {
    return _wrapped.stream();
  }

  @Override
  public Collection toCollection() {
    return _wrapped.toCollection();
  }

  @Override
  public ObjectReader sample(SampleSegment segment) {
    return _wrapped.sample(segment);
  }

  @Override
  public ObjectReader sample(double segmentRangeStartInclusive, double segmentRangeEndExclusive, long seed) {
    return _wrapped.sample(segmentRangeStartInclusive, segmentRangeEndExclusive, seed);
  }

  @Override
  public ObjectReader sample(double segmentRangeStartInclusive, double segmentRangeEndExclusive) {
    return _wrapped.sample(segmentRangeStartInclusive, segmentRangeEndExclusive);
  }

  @Override
  public  ObjectReader lazyMap(Function mapper) {
    return _wrapped.lazyMap(mapper);
  }

  @Override
  public  ObjectReader lazyFlatMap(Function> mapper) {
    return _wrapped.lazyFlatMap(mapper);
  }

  @Override
  public ObjectReader lazyFilter(Predicate inclusionTest) {
    return _wrapped.lazyFilter(inclusionTest);
  }

  @Override
  public ObjectReader lazyShuffle(long seed, int bufferSize) {
    return _wrapped.lazyShuffle(seed, bufferSize);
  }

  @Override
  public ObjectReader lazyShuffle(int bufferSize) {
    return _wrapped.lazyShuffle(bufferSize);
  }

  @Override
  public Spliterator spliterator() {
    return _wrapped.spliterator();
  }

  @Override
  public int hashCode() {
    return _wrapped.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    return obj instanceof WrappedObjectReader && ((WrappedObjectReader) obj)._wrapped.equals(this._wrapped);
  }

  @Override
  public String toString() {
    return _wrapped.toString();
  }

  @Override
  public List toList() {
    return _wrapped.toList();
  }

  @Override
  public BigList toBigList() {
    return _wrapped.toBigList();
  }
}