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

io.substrait.relation.Rel Maven / Gradle / Ivy

Go to download

Create a well-defined, cross-language specification for data compute operations

There is a newer version: 0.46.1
Show newest version
package io.substrait.relation;

import io.substrait.extension.AdvancedExtension;
import io.substrait.hint.Hint;
import io.substrait.type.Type;
import io.substrait.type.TypeCreator;
import java.util.List;
import java.util.Optional;
import java.util.stream.IntStream;
import org.immutables.value.Value;

public interface Rel {
  Optional getRemap();

  /**
   * @return the {@link AdvancedExtension} associated with a {@link io.substrait.proto.RelCommon}
   *     message, if present
   */
  Optional getCommonExtension();

  Type.Struct getRecordType();

  List getInputs();

  Optional getHint();

  @Value.Immutable
  public abstract static class Remap {
    public abstract List indices();

    public Type.Struct remap(Type.Struct initial) {
      List types = initial.fields();
      return TypeCreator.of(initial.nullable()).struct(indices().stream().map(i -> types.get(i)));
    }

    public static Remap of(Iterable fields) {
      return ImmutableRemap.builder().addAllIndices(fields).build();
    }

    public static Remap offset(int start, int length) {
      return of(
          IntStream.range(start, start + length)
              .mapToObj(i -> i)
              .collect(java.util.stream.Collectors.toList()));
    }
  }

   O accept(RelVisitor visitor) throws E;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy