Schema#

public class Schema#

The schema of data to be read in.

Field Summary

Method Summary

asHostDataType()

builder()

getChild(int i)

Get the schema of a child element.

getChildTypes()

Get types of the top level child columns in schema.

getColumnNames()

Get names of the top level child columns in schema.

getFlattenedColumnNames()

Get names of the columns flattened from all levels in schema by depth-first traversal.

getFlattenedDecimalPrecisions()

Get decimal precisions of the columns’ types flattened from all levels in schema by depth-first traversal.

getFlattenedNumChildren()

Get numbers of child columns for each level in schema.

getFlattenedTypeIds()

Get type ids of the columns flattened from all levels in schema by depth-first traversal.

getFlattenedTypes()

Get the types of the columns in schema flattened from all levels by depth-first traversal.

getFlattenedTypeScales()

Get scales of the columns’ types flattened from all levels in schema by depth-first traversal.

getNumChildren()

Get number of top level child columns in schema.

getType()

hasNestedChildren()

This is really for a top level struct schema where it is nested, but for things like CSV we care that it does not have any children that are also nested.

isNested()

Check if the schema is nested (i.e., top level type is LIST or STRUCT).

isStructOrHasStructDescendant()

Check to see if the schema includes a struct at all.

toString()

Static Fields

public static final Schema INFERRED#

Methods

public Schema getChild(int i)#

Get the schema of a child element.

Note that an inferred schema will have no children.

Parameters:

i – the index of the child to read.

Throws:

IndexOutOfBoundsException – if the index is not in the range of children.

Returns:

the new Schema

public String toString()#
public String[] getFlattenedColumnNames()#

Get names of the columns flattened from all levels in schema by depth-first traversal.

Returns:

An array containing names of all columns in schema.

public String[] getColumnNames()#

Get names of the top level child columns in schema.

Returns:

An array containing names of top level child columns.

public boolean isNested()#

Check if the schema is nested (i.e., top level type is LIST or STRUCT).

Returns:

true if the schema is nested, false otherwise.

public boolean hasNestedChildren()#

This is really for a top level struct schema where it is nested, but for things like CSV we care that it does not have any children that are also nested.

public int[] getFlattenedTypeIds()#

Get type ids of the columns flattened from all levels in schema by depth-first traversal.

Returns:

An array containing type ids of all columns in schema.

public int[] getFlattenedTypeScales()#

Get scales of the columns’ types flattened from all levels in schema by depth-first traversal.

Returns:

An array containing type scales of all columns in schema.

public int[] getFlattenedDecimalPrecisions()#

Get decimal precisions of the columns’ types flattened from all levels in schema by depth-first traversal.

This is used to pass down the decimal precisions from Spark to only the JNI layer, where some JNI functions require precision values to perform their operations. Decimal precisions should not be consumed by any libcudf’s APIs since libcudf does not support precisions for fixed point numbers.

Returns:

An array containing decimal precision of all columns in schema.

public DType[] getFlattenedTypes()#

Get the types of the columns in schema flattened from all levels by depth-first traversal.

Returns:

An array containing types of all columns in schema.

public DType[] getChildTypes()#

Get types of the top level child columns in schema.

Returns:

An array containing types of top level child columns.

public int getNumChildren()#

Get number of top level child columns in schema.

Returns:

Number of child columns.

public int[] getFlattenedNumChildren()#

Get numbers of child columns for each level in schema.

Returns:

Numbers of child columns for all levels flattened by depth-first traversal.

public DType getType()#
public boolean isStructOrHasStructDescendant()#

Check to see if the schema includes a struct at all.

Returns:

true if this or any one of its descendants contains a struct, else false.

public HostColumnVector.DataType asHostDataType()#

Static Methods

public static Builder builder()#
public static class Builder#

Method Summary

Methods

public Builder addColumn(DType type, String name, int precision)#

Add a new column.

Parameters:
  • type – the type of column to add

  • name – the name of the column to add (Ignored for list types)

  • precision – the decimal precision, only applicable for decimal types

Returns:

the builder for the new column. This should really only be used when the type passed in is a LIST or a STRUCT.

public Builder addColumn(DType type, String name)#
public Builder column(DType type, String name, int precision)#

Adds a single column to the current schema.

addColumn is preferred as it can be used to support nested types.

Parameters:
  • type – the type of the column.

  • name – the name of the column.

  • precision – the decimal precision, only applicable for decimal types.

Returns:

this for chaining.

public Builder column(DType type, String name)#
public Schema build()#