TECA
The Toolkit for Extreme Climate Analysis
teca_table Class Reference

A collection of columnar data with row based accessors and communication and I/O support. More...

#include <teca_table.h>

Inheritance diagram for teca_table:
[legend]
Collaboration diagram for teca_table:
[legend]

Public Member Functions

std::shared_ptr< teca_tableshared_from_this ()
 
std::shared_ptr< teca_table const > shared_from_this () const
 
virtual p_teca_dataset new_instance () const override
 virtual constructor. return a new dataset of the same type. More...
 
virtual p_teca_dataset new_copy (allocator alloc=allocator::malloc) const override
 
virtual p_teca_dataset new_shallow_copy () override
 
void clear ()
 remove all column definitions and data More...
 
template<typename nT , typename cT , typename... oT>
void declare_columns (nT &&col_name, cT col_type, oT &&...args)
 
template<typename nT , typename cT >
void declare_column (nT &&col_name, cT col_type)
 Adds a column definition to the table. More...
 
void set_default_allocator (allocator alloc)
 set the allocator to use with ::declare_column More...
 
unsigned int get_number_of_columns () const noexcept
 get the number of columns More...
 
unsigned long get_number_of_rows () const noexcept
 get the number of rows More...
 
p_teca_variant_array get_column (unsigned int i)
 get a specific column. return a nullptr if the column doesn't exist. More...
 
p_teca_variant_array get_column (const std::string &col_name)
 get a specific column. return a nullptr if the column doesn't exist. More...
 
const_p_teca_variant_array get_column (unsigned int i) const
 get a specific column. return a nullptr if the column doesn't exist. More...
 
const_p_teca_variant_array get_column (const std::string &col_name) const
 get a specific column. return a nullptr if the column doesn't exist. More...
 
template<typename array_t >
std::shared_ptr< array_t > get_column_as (unsigned int i)
 get a specific column. return a nullptr if the column doesn't exist. More...
 
template<typename array_t >
std::shared_ptr< array_t > get_column_as (const std::string &col_name)
 get a specific column. return a nullptr if the column doesn't exist. More...
 
template<typename array_t >
std::shared_ptr< const array_t > get_column_as (unsigned int i) const
 get a specific column. return a nullptr if the column doesn't exist. More...
 
template<typename array_t >
std::shared_ptr< const array_t > get_column_as (const std::string &col_name) const
 get a specific column. return a nullptr if the column doesn't exist. More...
 
bool has_column (const std::string &col_name) const
 test for the existence of a specific column More...
 
std::string get_column_name (unsigned int i) const
 get the name of column i, see also get_number_of_columns More...
 
int append_column (p_teca_variant_array array)
 add a column to the table More...
 
int append_column (const std::string &name, p_teca_variant_array array)
 add a column to the table More...
 
int remove_column (unsigned int i)
 remove a column More...
 
int remove_column (const std::string &name)
 remove a column More...
 
p_teca_array_collection get_columns ()
 get the container holding the columns More...
 
const_p_teca_array_collection get_columns () const
 get the container holding the columns More...
 
void resize (unsigned long n)
 resize the table to hold n rows of data, new rows are default initialized More...
 
void reserve (unsigned long n)
 reserve memory for n rows of data without changing the tables size More...
 
template<typename cT , typename... oT>
void append (cT &&val, oT &&... args)
 
std::string get_class_name () const override
 return a unique string identifier More...
 
int get_type_code () const override
 return an integer identifier uniquely naming the dataset type More...
 
 operator bool () const noexcept
 covert to boolean. true if the dataset is not empty, otherwise false. More...
 
bool empty () const noexcept override
 return true if the dataset is empty. More...
 
int to_stream (teca_binary_stream &) const override
 serialize the dataset to the given stream for I/O or communication More...
 
int from_stream (teca_binary_stream &) override
 deserialize the dataset from the given stream for I/O or communication More...
 
int to_stream (std::ostream &) const override
 serialize to the stream in human readable representation More...
 
int from_stream (std::istream &) override
 deserialize from the stream in human readable representation More...
 
void copy (const const_p_teca_dataset &other, allocator alloc=allocator::malloc) override
 
void copy (const const_p_teca_table &other, unsigned long first_row, unsigned long last_row, allocator alloc=allocator::malloc)
 deep copy a subset of row values. More...
 
void shallow_copy (const p_teca_dataset &other) override
 
void copy_structure (const const_p_teca_table &other)
 copy the column layout and types More...
 
void swap (const p_teca_dataset &other) override
 swap internals of the two objects More...
 
void concatenate_rows (const const_p_teca_table &other)
 append rows from the passed in table which must have identical columns. More...
 
void concatenate_cols (const const_p_teca_table &other, bool deep=false)
 
temporal metadata
void set_calendar (const std::vector< std::string > &vals)
 
int get_calendar (std::vector< std::string > &vals) const
 
void set_calendar (const p_teca_variant_array &vals)
 
int get_calendar (p_teca_variant_array vals) const
 
void set_calendar (const std::initializer_list< std::string > &l)
 
void set_calendar (const std::string *vals)
 
int get_calendar (std::string *vals) const
 
void set_calendar (const std::string &val_1)
 
int get_calendar (std::string &val_1) const
 
void set_time_units (const std::vector< std::string > &vals)
 
int get_time_units (std::vector< std::string > &vals) const
 
void set_time_units (const p_teca_variant_array &vals)
 
int get_time_units (p_teca_variant_array vals) const
 
void set_time_units (const std::initializer_list< std::string > &l)
 
void set_time_units (const std::string *vals)
 
int get_time_units (std::string *vals) const
 
void set_time_units (const std::string &val_1)
 
int get_time_units (std::string &val_1) const
 
attribute metadata
void set_attributes (const std::vector< teca_metadata > &vals)
 
int get_attributes (std::vector< teca_metadata > &vals) const
 
void set_attributes (const p_teca_variant_array &vals)
 
int get_attributes (p_teca_variant_array vals) const
 
void set_attributes (const std::initializer_list< teca_metadata > &l)
 
void set_attributes (const teca_metadata *vals)
 
int get_attributes (teca_metadata *vals) const
 
void set_attributes (const teca_metadata &val_1)
 
int get_attributes (teca_metadata &val_1) const
 
- Public Member Functions inherited from teca_dataset
virtual int set_request_indices (const std::string &request_key, const unsigned long ids[2])
 
virtual int get_request_indices (unsigned long ids[2]) const
 
virtual int get_request_index (unsigned long &index) const
 
virtual int set_request_index (const std::string &request_key, unsigned long index)
 
 operator bool () const noexcept
 
virtual void copy_metadata (const const_p_teca_dataset &other)
 copy metadata. always a deep copy. More...
 
virtual teca_metadataget_metadata () noexcept
 get the dataset metadata More...
 
virtual const teca_metadataget_metadata () const noexcept
 get the dataset metadata More...
 
virtual void set_metadata (const teca_metadata &md)
 set the dataset metadata More...
 
void set_index_request_key (const std::vector< std::string > &vals)
 
int get_index_request_key (std::vector< std::string > &vals) const
 
void set_index_request_key (const p_teca_variant_array &vals)
 
int get_index_request_key (p_teca_variant_array vals) const
 
void set_index_request_key (const std::initializer_list< std::string > &l)
 
void set_index_request_key (const std::string *vals)
 
int get_index_request_key (std::string *vals) const
 
void set_index_request_key (const std::string &val_1)
 
int get_index_request_key (std::string &val_1) const
 

Static Public Member Functions

static p_teca_table New ()
 

Protected Member Functions

 teca_table (const teca_table &other)=delete
 
 teca_table (teca_table &&other)=delete
 
teca_tableoperator= (const teca_table &other)=delete
 
void declare_columns ()
 
void append ()
 
- Protected Member Functions inherited from teca_dataset
 teca_dataset (const teca_dataset &)=delete
 
 teca_dataset (const teca_dataset &&)=delete
 
void operator= (const p_teca_dataset &other)=delete
 
void operator= (p_teca_dataset &&other)=delete
 

Additional Inherited Members

- Public Types inherited from teca_dataset
using allocator = teca_variant_array::allocator
 
- Protected Attributes inherited from teca_dataset
teca_metadatametadata
 

Detailed Description

A collection of columnar data with row based accessors and communication and I/O support.

Member Function Documentation

◆ append()

template<typename cT , typename... oT>
void teca_table::append ( cT &&  val,
oT &&...  args 
)

append the collection of data in succession to each column. see also operator<< for sequential stream insertion like append.

◆ append_column() [1/2]

int teca_table::append_column ( const std::string &  name,
p_teca_variant_array  array 
)
inline

add a column to the table

◆ append_column() [2/2]

int teca_table::append_column ( p_teca_variant_array  array)
inline

add a column to the table

◆ clear()

void teca_table::clear ( )

remove all column definitions and data

◆ concatenate_cols()

void teca_table::concatenate_cols ( const const_p_teca_table &  other,
bool  deep = false 
)

append columns from the passed in table which must have same number of rows. if deep flag is true a full copy of the data is made, else a shallow copy is made.

◆ concatenate_rows()

void teca_table::concatenate_rows ( const const_p_teca_table &  other)

append rows from the passed in table which must have identical columns.

◆ copy() [1/2]

void teca_table::copy ( const const_p_teca_dataset &  other,
allocator  alloc = allocator::malloc 
)
overridevirtual

Deep copy data and metdata.

Parameters
[in]otherThe dataset to copy.
[in]allocThe allocator to use for alloctions of data structures to hold the copy. The default is a CPU based allocator.

Reimplemented from teca_dataset.

◆ copy() [2/2]

void teca_table::copy ( const const_p_teca_table &  other,
unsigned long  first_row,
unsigned long  last_row,
allocator  alloc = allocator::malloc 
)

deep copy a subset of row values.

◆ copy_structure()

void teca_table::copy_structure ( const const_p_teca_table &  other)

copy the column layout and types

◆ declare_column()

template<typename nT , typename cT >
void teca_table::declare_column ( nT &&  col_name,
cT  col_type 
)

Adds a column definition to the table.

◆ declare_columns()

template<typename nT , typename cT , typename... oT>
void teca_table::declare_columns ( nT &&  col_name,
cT  col_type,
oT &&...  args 
)

Define the table columns. requires name,type pairs. For example, declare_columns("c1",int(),"c2",float()) creates a table with 2 columns the first storing int the second storing float.

◆ empty()

bool teca_table::empty ( ) const
overridevirtualnoexcept

return true if the dataset is empty.

Reimplemented from teca_dataset.

◆ from_stream() [1/2]

int teca_table::from_stream ( std::istream &  )
overridevirtual

deserialize from the stream in human readable representation

Reimplemented from teca_dataset.

◆ from_stream() [2/2]

int teca_table::from_stream ( teca_binary_stream )
overridevirtual

deserialize the dataset from the given stream for I/O or communication

Reimplemented from teca_dataset.

◆ get_class_name()

std::string teca_table::get_class_name ( ) const
inlineoverridevirtual

return a unique string identifier

Implements teca_dataset.

◆ get_column() [1/4]

p_teca_variant_array teca_table::get_column ( const std::string &  col_name)

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column() [2/4]

const_p_teca_variant_array teca_table::get_column ( const std::string &  col_name) const

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column() [3/4]

p_teca_variant_array teca_table::get_column ( unsigned int  i)
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column() [4/4]

const_p_teca_variant_array teca_table::get_column ( unsigned int  i) const
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column_as() [1/4]

template<typename array_t >
std::shared_ptr<array_t> teca_table::get_column_as ( const std::string &  col_name)
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column_as() [2/4]

template<typename array_t >
std::shared_ptr<const array_t> teca_table::get_column_as ( const std::string &  col_name) const
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column_as() [3/4]

template<typename array_t >
std::shared_ptr<array_t> teca_table::get_column_as ( unsigned int  i)
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column_as() [4/4]

template<typename array_t >
std::shared_ptr<const array_t> teca_table::get_column_as ( unsigned int  i) const
inline

get a specific column. return a nullptr if the column doesn't exist.

◆ get_column_name()

std::string teca_table::get_column_name ( unsigned int  i) const
inline

get the name of column i, see also get_number_of_columns

◆ get_columns() [1/2]

p_teca_array_collection teca_table::get_columns ( )
inline

get the container holding the columns

◆ get_columns() [2/2]

const_p_teca_array_collection teca_table::get_columns ( ) const
inline

get the container holding the columns

◆ get_number_of_columns()

unsigned int teca_table::get_number_of_columns ( ) const
noexcept

get the number of columns

◆ get_number_of_rows()

unsigned long teca_table::get_number_of_rows ( ) const
noexcept

get the number of rows

◆ get_type_code()

int teca_table::get_type_code ( ) const
overridevirtual

return an integer identifier uniquely naming the dataset type

Implements teca_dataset.

◆ has_column()

bool teca_table::has_column ( const std::string &  col_name) const
inline

test for the existence of a specific column

◆ new_copy()

virtual p_teca_dataset teca_table::new_copy ( allocator  alloc = allocator::malloc) const
inlineoverridevirtual

Implements teca_dataset.

◆ new_instance()

virtual p_teca_dataset teca_table::new_instance ( ) const
inlineoverridevirtual

virtual constructor. return a new dataset of the same type.

Implements teca_dataset.

◆ new_shallow_copy()

virtual p_teca_dataset teca_table::new_shallow_copy ( )
inlineoverridevirtual

Virtual shallow copy constructor. return a shallow copy of this dataset in a new instance. References to source data structures are taken, but metadata is always deep copied.

Implements teca_dataset.

◆ operator bool()

teca_table::operator bool ( ) const
inlineexplicitnoexcept

covert to boolean. true if the dataset is not empty, otherwise false.

◆ remove_column() [1/2]

int teca_table::remove_column ( const std::string &  name)
inline

remove a column

◆ remove_column() [2/2]

int teca_table::remove_column ( unsigned int  i)
inline

remove a column

◆ reserve()

void teca_table::reserve ( unsigned long  n)

reserve memory for n rows of data without changing the tables size

◆ resize()

void teca_table::resize ( unsigned long  n)

resize the table to hold n rows of data, new rows are default initialized

◆ set_attributes()

void teca_table::set_attributes ( const std::vector< teca_metadata > &  vals)
inline

Provides access to the array attributes metadata, which contains information such as dimensions, units, data type, description, etc.

◆ set_calendar()

void teca_table::set_calendar ( const std::vector< std::string > &  vals)
inline

Specifies the temporal extents of the data and the calendaring system used to define the time axis.

◆ set_default_allocator()

void teca_table::set_default_allocator ( allocator  alloc)
inline

set the allocator to use with ::declare_column

◆ shallow_copy()

void teca_table::shallow_copy ( const p_teca_dataset &  other)
overridevirtual

Shallow copy data and metadata. The shallow copy takes references to the source data structures. Metadata is always deep copied.

Parameters
[in]otherThe dataset to copy.

Reimplemented from teca_dataset.

◆ swap()

void teca_table::swap ( const p_teca_dataset &  other)
overridevirtual

swap internals of the two objects

Reimplemented from teca_dataset.

◆ to_stream() [1/2]

int teca_table::to_stream ( std::ostream &  ) const
overridevirtual

serialize to the stream in human readable representation

Reimplemented from teca_dataset.

◆ to_stream() [2/2]

int teca_table::to_stream ( teca_binary_stream ) const
overridevirtual

serialize the dataset to the given stream for I/O or communication

Reimplemented from teca_dataset.


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