@PublicEvolving public abstract class Projection extends Object
Projection
represents a list of (possibly nested) indexes that can be used to project
data types. A row projection includes both reducing the accessible fields and reordering them.Modifier and Type | Method and Description |
---|---|
static Projection |
all(DataType dataType)
Create a
Projection of all the fields in the provided dataType . |
Projection |
complement(DataType dataType)
Like
complement(int) , using the dataType fields count. |
abstract Projection |
complement(int fieldsNumber)
Complement this projection.
|
abstract Projection |
difference(Projection other)
Perform a difference of this
Projection with another Projection . |
static Projection |
empty()
Create an empty
Projection , that is a projection that projects no fields, returning
an empty DataType . |
boolean |
equals(Object o) |
static Projection |
fromFieldNames(DataType dataType,
List<String> projectedFields)
|
int |
hashCode() |
abstract boolean |
isNested() |
static Projection |
of(int[] indexes)
Create a
Projection of the provided indexes . |
static Projection |
of(int[][] indexes)
Create a
Projection of the provided indexes . |
abstract DataType |
project(DataType dataType)
Projects a (possibly nested) row data type by returning a new data type that only includes
fields of the given index paths.
|
LogicalType |
project(LogicalType logicalType)
Same as
project(DataType) , but accepting and returning LogicalType . |
static Projection |
range(int startInclusive,
int endExclusive)
Create a
Projection of a field range. |
abstract int[][] |
toNestedIndexes()
Convert this instance to a nested projection index paths.
|
String |
toString() |
abstract int[] |
toTopLevelIndexes()
Convert this instance to a projection of top level indexes.
|
public abstract DataType project(DataType dataType)
When extracting nested fields, the name of the resulting fields is the full path of the
field separated by _
. For example, the field b
inside the row field a
of the root DataType
is named a_b
in the result DataType
. In case of
naming conflicts the postfix notation '_$%d' is used, where %d
is an arbitrary
number, in order to generate a unique field name. For example if the root DataType
includes both a field a_b
and a nested row a
with field b
, the result
DataType
will contain one field named a_b
and the other named a_b_1
.
public LogicalType project(LogicalType logicalType)
project(DataType)
, but accepting and returning LogicalType
.public abstract boolean isNested()
true
whether this projection is nested or not.public abstract Projection difference(Projection other)
Projection
with another Projection
. The result
of this operation is a new Projection
retaining the same ordering of this instance
but with the indexes from other
removed. For example:
[4, 1, 0, 3, 2] - [4, 2] = [1, 0, 2]
Note how the index 3
in the minuend becomes 2
because it's rescaled to
project correctly a RowData
or arity 3.
other
- the subtrahendIllegalArgumentException
- when other
is nested.public abstract Projection complement(int fieldsNumber)
fieldsNumber
except the indexes in this Projection
. For example:
[4, 2].complement(5) = [0, 1, 3]
fieldsNumber
- the size of the universeIllegalStateException
- if this projection is nested.public Projection complement(DataType dataType)
complement(int)
, using the dataType
fields count.public abstract int[] toTopLevelIndexes()
DataType
. For example, [0, 2, 1]
specifies to
include in the following order the 1st field, the 3rd field and the 2nd field of the row.IllegalStateException
- if this projection is nested.public abstract int[][] toNestedIndexes()
DataType
, including nested rows. For example, [[0,
2, 1], ...]
specifies to include the 2nd field of the 3rd field of the 1st field in the
top-level row.public static Projection empty()
Projection
, that is a projection that projects no fields, returning
an empty DataType
.public static Projection of(int[] indexes)
Projection
of the provided indexes
.toTopLevelIndexes()
public static Projection of(int[][] indexes)
Projection
of the provided indexes
.toNestedIndexes()
public static Projection fromFieldNames(DataType dataType, List<String> projectedFields)
public static Projection all(DataType dataType)
Projection
of all the fields in the provided dataType
.public static Projection range(int startInclusive, int endExclusive)
Projection
of a field range.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.