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

A sort order for a table. More...

#include <sort_order.h>

Inheritance diagram for iceberg::SortOrder:
iceberg::util::Formattable

Public Member Functions

int32_t order_id () const
 Get the sort order id.
 
std::span< const SortFieldfields () const
 Get the list of sort fields.
 
bool is_sorted () const
 Returns true if the sort order is sorted.
 
bool is_unsorted () const
 Returns true if the sort order is unsorted A SortOrder is unsorted if it has no sort fields.
 
bool Satisfies (const SortOrder &other) const
 Checks whether this order satisfies another order.
 
bool SameOrder (const SortOrder &other) const
 Checks whether this order is equivalent to another order while ignoring the order id.
 
std::string ToString () const override
 Get a user-readable string representation.
 
Status Validate (const Schema &schema) const
 Validates the sort order against a schema.
 

Static Public Member Functions

static const std::shared_ptr< SortOrder > & Unsorted ()
 Get an unsorted sort order singleton.
 
static Result< std::unique_ptr< SortOrder > > Make (const Schema &schema, int32_t sort_id, std::vector< SortField > fields)
 Create a SortOrder.
 
static Result< std::unique_ptr< SortOrder > > Make (int32_t sort_id, std::vector< SortField > fields)
 Create a SortOrder without binding to a schema.
 
static std::unordered_set< std::string_view > OrderPreservingSortedColumns (const Schema &schema, const SortOrder &order)
 

Static Public Attributes

static constexpr int32_t kUnsortedOrderId = 0
 
static constexpr int32_t kInitialSortOrderId = 1
 

Friends

bool operator== (const SortOrder &lhs, const SortOrder &rhs)
 

Detailed Description

A sort order for a table.

A sort order is defined by a sort order id and a list of sort fields. The order of the sort fields within the list defines the order in which the sort is applied to the data.

Member Function Documentation

◆ Make() [1/2]

Result< std::unique_ptr< SortOrder > > iceberg::SortOrder::Make ( const Schema schema,
int32_t  sort_id,
std::vector< SortField fields 
)
static

Create a SortOrder.

Parameters
schemaThe schema to bind the sort order to.
sort_idThe sort order id.
fieldsThe sort fields.
Returns
A Result containing the SortOrder or an error.

◆ Make() [2/2]

Result< std::unique_ptr< SortOrder > > iceberg::SortOrder::Make ( int32_t  sort_id,
std::vector< SortField fields 
)
static

Create a SortOrder without binding to a schema.

Parameters
sort_idThe sort order id.
fieldsThe sort fields.
Returns
A Result containing the SortOrder or an error.
Note
This method does not check whether the sort fields are valid for any schema.

◆ ToString()

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

Get a user-readable string representation.

Implements iceberg::util::Formattable.

◆ Validate()

Status iceberg::SortOrder::Validate ( const Schema schema) const

Validates the sort order against a schema.

Parameters
schemaThe schema to validate against.
Returns
Error status if the sort order has any invalid transform.

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