iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
iceberg::StructType Class Reference

A data type representing a struct with nested fields. More...

#include <type.h>

Inheritance diagram for iceberg::StructType:
iceberg::NestedType iceberg::Type iceberg::util::Formattable iceberg::Schema

Public Member Functions

 StructType (std::vector< SchemaField > fields)
 
TypeId type_id () const override
 Get the type ID.
 
std::string ToString () const override
 Get a user-readable string representation.
 
std::span< const SchemaFieldfields () const override
 Get a view of the child fields.
 
Result< std::optional< SchemaFieldConstRef > > GetFieldById (int32_t field_id) const override
 Get a field by field ID.
 
Result< std::optional< SchemaFieldConstRef > > GetFieldByIndex (int32_t index) const override
 Get a field by index.
 
Result< std::optional< SchemaFieldConstRef > > GetFieldByName (std::string_view name, bool case_sensitive) const override
 Get a field by name. Return an error Status if the field name is not unique; prefer GetFieldById or GetFieldByIndex when possible.
 
std::unique_ptr< SchemaToSchema () const
 
virtual Result< std::optional< SchemaFieldConstRef > > GetFieldByName (std::string_view name, bool case_sensitive) const=0
 Get a field by name. Return an error Status if the field name is not unique; prefer GetFieldById or GetFieldByIndex when possible.
 
Result< std::optional< SchemaFieldConstRef > > GetFieldByName (std::string_view name) const
 Get a field by name (case-sensitive).
 
- Public Member Functions inherited from iceberg::NestedType
bool is_primitive () const override
 Is this a primitive type (may not have child fields)?
 
bool is_nested () const override
 Is this a nested type (may have child fields)?
 
Result< std::optional< SchemaFieldConstRef > > GetFieldByName (std::string_view name) const
 Get a field by name (case-sensitive).
 

Static Public Attributes

static constexpr TypeId kTypeId = TypeId::kStruct
 

Protected Member Functions

bool Equals (const Type &other) const override
 Compare two types for equality.
 

Static Protected Member Functions

static Result< std::unordered_map< int32_t, SchemaFieldConstRef > > InitFieldById (const StructType &)
 
static Result< std::unordered_map< std::string_view, SchemaFieldConstRef > > InitFieldByName (const StructType &)
 
static Result< std::unordered_map< std::string, SchemaFieldConstRef > > InitFieldByLowerCaseName (const StructType &)
 

Protected Attributes

std::vector< SchemaFieldfields_
 
Lazy< InitFieldById > field_by_id_
 
Lazy< InitFieldByName > field_by_name_
 
Lazy< InitFieldByLowerCaseName > field_by_lowercase_name_
 

Additional Inherited Members

- Public Types inherited from iceberg::NestedType
using SchemaFieldConstRef = std::reference_wrapper< const SchemaField >
 

Detailed Description

A data type representing a struct with nested fields.

Member Function Documentation

◆ Equals()

bool iceberg::StructType::Equals ( const Type other) const
overrideprotectedvirtual

Compare two types for equality.

Implements iceberg::Type.

◆ fields()

std::span< const SchemaField > iceberg::StructType::fields ( ) const
overridevirtual

Get a view of the child fields.

Implements iceberg::NestedType.

◆ GetFieldById()

Result< std::optional< NestedType::SchemaFieldConstRef > > iceberg::StructType::GetFieldById ( int32_t  field_id) const
overridevirtual

Get a field by field ID.

Note
This is O(1) complexity.

Implements iceberg::NestedType.

◆ GetFieldByIndex()

Result< std::optional< NestedType::SchemaFieldConstRef > > iceberg::StructType::GetFieldByIndex ( int32_t  index) const
overridevirtual

Get a field by index.

Note
This is O(1) complexity.

Implements iceberg::NestedType.

◆ GetFieldByName() [1/2]

Result< std::optional< NestedType::SchemaFieldConstRef > > iceberg::StructType::GetFieldByName ( std::string_view  name,
bool  case_sensitive 
) const
overridevirtual

Get a field by name. Return an error Status if the field name is not unique; prefer GetFieldById or GetFieldByIndex when possible.

Note
This is O(1) complexity.

Implements iceberg::NestedType.

◆ GetFieldByName() [2/2]

virtual Result< std::optional< SchemaFieldConstRef > > iceberg::NestedType::GetFieldByName ( std::string_view  name,
bool  case_sensitive 
) const
virtual

Get a field by name. Return an error Status if the field name is not unique; prefer GetFieldById or GetFieldByIndex when possible.

Note
This is O(1) complexity.

Implements iceberg::NestedType.

◆ ToString()

std::string iceberg::StructType::ToString ( ) const
overridevirtual

Get a user-readable string representation.

Implements iceberg::util::Formattable.

◆ type_id()

TypeId iceberg::StructType::type_id ( ) const
overridevirtual

Get the type ID.

Implements iceberg::Type.


The documentation for this class was generated from the following files: