parquet_table_example Module

Table type generated from the test MAML schema: parquet_table_test, with one accessor per predefined column.

It extends parquet_table, so every inherited operation (%nrows, %get, %filter_rows, %clone, %append, %row, ...) applies unchanged. Open it with %init, %init_slice or %init_empty -- a plain parquet_open_table will not compile for this type, deliberately, since it would skip the predefined columns.



Derived Types

type, public, extends(parquet_table) ::  parquet_table_test

Predefined-column table generated from the test schema.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: zeropoint = 0.0_real64

A worked example of a user-added table parameter, and the thing that makes this module's clone_extra/init_extra statements non-trivial: the generator writes out%zeropoint = self%zeropoint and self%zeropoint = 0.0_real64 from this declaration, and test/test_table_codegen.f90 checks that both happen.

Type-Bound Procedures

procedure, public :: nrows => table_nrows

Number of rows every column holds.

procedure, public :: ncols => table_ncols

Number of columns the table has.

procedure, public :: column_names => table_column_names

Copy out every column name, in order.

procedure, public :: column_index => table_column_index

A column's 1-based position, 0 when absent.

procedure, public :: column_name => table_column_name

Copy out the name at a 1-based position.

generic, public :: column => column_by_name, column_by_index

A resolved handle on one column, by name or by 1-based position. Resolves once -- the lookup, the lazy first touch and the kind -- so a per-element loop over that column stops paying for a name lookup on every access. See parquet_table_col.

generic, public :: has_nulls => has_nulls_name, has_nulls_at

Whether a column holds (or may hold) nulls -- named, or by 1-based position.

generic, public :: get_valid_mask => table_get_valid_mask, table_get_valid_mask_elem

Copy out a column's validity as a plain logical array. A rank-1 mask gives one entry per row (on a *_VEC column: "any element of the row is null"); a rank-2 mask gives the true (width, nrows) per-element state.

procedure, public :: generation => table_generation

Counter bumped by every structural change.

procedure, public :: has_column => table_has_column

Whether a column of this name exists.

generic, public :: missing_columns => missing_columns_string, missing_columns_array

Which of these columns the table does NOT have, as a packed array (zero-size when it has them all). The non-aborting half of %require_columns.

generic, public :: require_columns => require_columns_string, require_columns_array

Aborts unless the table has every one of these columns, naming EVERY missing one -- not just the first, which is what a hand-written loop reports.

generic, public :: kind => kind_name, kind_at

A column's PK_* kind discriminator -- named, or by 1-based position.

generic, public :: width => width_name, width_at

A column's values-per-row (1 if scalar) -- named, or by 1-based position.

generic, public :: unit => unit_name, unit_at

Copy out a column's unit string -- named, or by 1-based position.

generic, public :: residency => residency_name, residency_at

A column's RES_* residency state -- named, or by 1-based position.

generic, public :: is_null => is_null_i32, is_null_i64, is_null_e32, is_null_e64, is_null_at_i32, is_null_at_i64, is_null_at_e32, is_null_at_e64

Whether row i of a column is null, or -- given e as well -- element e of it.

Read more…
procedure, public :: is_detached => table_is_detached

Whether the table has left its file behind.

generic, public :: is_supported => is_supported_name, is_supported_at

Whether a column's type can be read -- named, or by 1-based position.

procedure, public :: filename => table_filename

Copy out the file this table came from.

procedure, public :: get_file_metadata => table_get_file_metadata

One key from the file's metadata.

generic, public :: prefetch => prefetch_string, prefetch_array

Reads the named column(s) now, instead of on first touch. Required before a parallel region: a first touch inside one is a hard error, since it would mutate shared state.

generic, public :: materialize => prefetch_string, prefetch_array

The same call as %prefetch, under the name that pairs with %materialize_all. Reaching for the definitive-sounding %materialize_all when only a few columns are wanted reads the whole file, silently; %materialize(names) is the one to find first.

procedure, public :: materialize_all => table_materialize_every

Read every column not yet read.

procedure, public :: reload => table_reload

Re-read one column; force= to discard local edits.

procedure, public :: evict_column => table_evict_column

Drop a column's VALUES; force= if it holds local edits.

procedure, public :: set_user_populated => table_set_user_populated

Claim a column's values as the caller's own, or unclaim.

procedure, public :: is_user_populated => table_is_user_populated

Whether a column is claimed as holding the caller's values.

procedure, public :: validate_qc => table_validate_qc

Check every qc-declaring column, holding none.

procedure, public :: print_stat => table_print_stat

Print what the table holds, to stdout.

procedure, public :: nrows_unfiltered => table_nrows_unfiltered

Rows before filter=/sample_fraction=.

procedure, public :: row_group_extent => table_row_group_extent

Rows in the row groups this table covers.

procedure, public :: row_group_bounds => table_row_group_bounds

Row-group row ranges, this table's rows or the file's.

generic, public :: row => row_at_i32, row_at_i64

A handle on one row, for code that works a row at a time rather than a column at a time. The index is 1-based within THIS table -- in the slice regime, row 1 is the slice's first row, not the file's.

generic, public :: get_slice => get_slice_i32, get_slice_i64, get_slice_f32, get_slice_f64, get_slice_bool, get_slice_date, get_slice_time, get_slice_ts, get_slice_i32v, get_slice_i64v, get_slice_f32v, get_slice_f64v, get_slice_boolv, get_slice_datev, get_slice_timev, get_slice_tsv, get_slice_str, get_slice_chr, get_slice_chrv

Copies the rows a parquet_slice selects into a freshly allocated array of the caller's own kind, widening on the way exactly as %get does.

Read more…
generic, public :: set_slice => set_slice_i32, set_slice_i64, set_slice_f32, set_slice_f64, set_slice_bool, set_slice_date, set_slice_time, set_slice_ts, set_slice_i32v, set_slice_i64v, set_slice_f32v, set_slice_f64v, set_slice_boolv, set_slice_datev, set_slice_timev, set_slice_tsv, set_slice_chr, set_slice_chrv

Writes values into the rows a parquet_slice selects -- %get_slice's counterpart. The kind must match the column's exactly, and the array must have one value per selected row.

Read more…
generic, public :: col => col_ptr_i32, col_ptr_i64, col_ptr_f32, col_ptr_f64, col_ptr_bool, col_ptr_date, col_ptr_time, col_ptr_ts, col_ptr_i32v, col_ptr_i64v, col_ptr_f32v, col_ptr_f64v, col_ptr_boolv, col_ptr_datev, col_ptr_timev, col_ptr_tsv, col_ptr_strcol

Points p at a column's storage: zero copy, writable, and the pointer kind must match the stored kind exactly (ask %kind first if you do not know it). A parquet_string_column pointer aliases a PK_STRING column's packed store: read it and edit its values in place, but do NOT change its length or element count through the pointer -- the column's own row count would no longer describe it.

Read more…
generic, public :: get => get_arr_i32, get_arr_i64, get_arr_f32, get_arr_f64, get_arr_bool, get_arr_date, get_arr_time, get_arr_ts, get_arr_i32v, get_arr_i64v, get_arr_f32v, get_arr_f64v, get_arr_boolv, get_arr_datev, get_arr_timev, get_arr_tsv, get_arr_str, get_arr_chr, get_arr_chrv

Copies a column into a freshly allocated array of the caller's own kind.

generic, public :: set => set_arr_i32, set_arr_i64, set_arr_f32, set_arr_f64, set_arr_bool, set_arr_date, set_arr_time, set_arr_ts, set_arr_i32v, set_arr_i64v, set_arr_f32v, set_arr_f64v, set_arr_boolv, set_arr_datev, set_arr_timev, set_arr_tsv, set_arr_chr, set_arr_chrv, set_arr_strcol
generic, public :: add_column => add_column_i32, add_column_i64, add_column_f32, add_column_f64, add_column_bool, add_column_date, add_column_time, add_column_ts, add_column_i32v, add_column_i64v, add_column_f32v, add_column_f64v, add_column_boolv, add_column_datev, add_column_timev, add_column_tsv, add_column_chr, add_column_chrv, add_column_strcol, add_column_col
generic, public :: get_element => get_element_i32_i32, get_element_i32_i64, get_element_i64_i32, get_element_i64_i64, get_element_f32_i32, get_element_f32_i64, get_element_f64_i32, get_element_f64_i64, get_element_bool_i32, get_element_bool_i64, get_element_date_i32, get_element_date_i64, get_element_time_i32, get_element_time_i64, get_element_ts_i32, get_element_ts_i64, get_element_i32v_i32, get_element_i32v_i64, get_element_i64v_i32, get_element_i64v_i64, get_element_f32v_i32, get_element_f32v_i64, get_element_f64v_i32, get_element_f64v_i64, get_element_boolv_i32, get_element_boolv_i64, get_element_datev_i32, get_element_datev_i64, get_element_timev_i32, get_element_timev_i64, get_element_tsv_i32, get_element_tsv_i64, get_element_chr_i32, get_element_chr_i64, get_element_chrv_i32, get_element_chrv_i64

Reads one row's value out of a column, widening into the caller's variable exactly as %get does -- the one-call form of r = t%row(i) then r%get(name, v). On a *_VEC column the value is that row's whole vector.

generic, public :: set_element => set_element_i32_i32, set_element_i32_i64, set_element_i64_i32, set_element_i64_i64, set_element_f32_i32, set_element_f32_i64, set_element_f64_i32, set_element_f64_i64, set_element_bool_i32, set_element_bool_i64, set_element_date_i32, set_element_date_i64, set_element_time_i32, set_element_time_i64, set_element_ts_i32, set_element_ts_i64, set_element_i32v_i32, set_element_i32v_i64, set_element_i64v_i32, set_element_i64v_i64, set_element_f32v_i32, set_element_f32v_i64, set_element_f64v_i32, set_element_f64v_i64, set_element_boolv_i32, set_element_boolv_i64, set_element_datev_i32, set_element_datev_i64, set_element_timev_i32, set_element_timev_i64, set_element_tsv_i32, set_element_tsv_i64, set_element_chr_i32, set_element_chr_i64, set_element_chrv_i32, set_element_chrv_i64

Writes one row's value in place. The kind must match the column's exactly (as %set does), and writing a value CLEARS that row's null -- use %set_null to put one back. On a *_VEC column the value is that row's whole vector.

generic, public :: set_null => set_null_i32, set_null_i64, set_null_e32, set_null_e64, set_null_mask, set_null_mask_elem

Marks null: row i of a column, element e of row i, or every entry a logical mask marks .false..

Read more…
generic, public :: clear_null => clear_null_i32, clear_null_i64, clear_null_e32, clear_null_e64

Marks row i -- or, given e, element e of it -- valid without saying what its value is. Only useful when a value is already there or is about to be written; %set_element clears the null itself.

procedure, public :: compact_validity => table_compact_validity

Drop a null bitmap that no longer has nulls.

procedure, public :: ensure_validity => table_ensure_validity

Allocate validity storage up front, for concurrent nulling.

procedure, public :: drop_column => table_drop_column

Remove a column; force= for a predefined one.

procedure, public :: rename_column => table_rename_column

Change the name a column is looked up by.

procedure, public :: copy_column => table_copy_column

Add a copy of a column, optionally of another kind.

procedure, public :: cast => table_cast

Convert a column to another kind, in place.

procedure, public :: filter_rows => table_filter_rows

Keep only the rows a mask selects.

generic, public :: sort_by => table_sort_by, table_sort_by_string

Reorders rows by one or more key columns. Detaching.

generic, public :: top_n => table_top_n, table_top_n_string

Keeps only the n best rows, in key order. Detaching.

generic, public :: argsort_by => table_argsort_by_i32, table_argsort_by_i64, table_argsort_by_string_i32, table_argsort_by_string_i64

The row order the keys imply, without reordering anything. Unlike %sort_by the table stays attached, so this is how to read rows in an order while keeping the file.

generic, public :: argsort_partial => table_argsort_partial_i32, table_argsort_partial_i64, table_argsort_partial_string_i32, table_argsort_partial_string_i64

The n best rows in order, by selection rather than a full sort. Also non-mutating.

generic, public :: is_sorted_by => table_is_sorted_by, table_is_sorted_by_string

Whether the rows are already in that order.

generic, public :: delete_rows => table_delete_rows_i32, table_delete_rows_i64

Removes the listed rows. A thin convenience over %filter_rows, and like it, detaching.

generic, public :: truncate => table_truncate_i32, table_truncate_i64

Keeps only the first n rows. Detaching, like every row-structural change.

generic, public :: append => table_append_table, table_append_row

Appends rows: a whole table's worth, or one row. Detaching, like every row-structural change. The bulk idiom is %clone_structure -> fill -> %append(batch).

generic, public :: append_null_rows => table_append_null_rows_i32, table_append_null_rows_i64

Appends n all-null rows, to be filled in afterwards. Detaching.

procedure, public :: compact => table_compact

Release capacity appends left behind.

generic, public :: reserve => table_reserve_i32, table_reserve_i64

Makes room for n rows in every resident column, so the appends that follow do not reallocate. %compact's counterpart; neither changes the row set, so neither detaches.

procedure, public :: reserve_columns => table_reserve_columns

Makes room for n COLUMNS, so that the %add_column calls that follow relocate nothing and leave an outstanding %col pointer valid. See its own doc-comment for the guarantee.

procedure, public :: column_capacity => table_column_capacity

Column slots allocated, or spare.

procedure, public :: clone => table_clone

Independent deep copy of this table.

procedure, public :: clone_structure => table_clone_structure

Empty table with the same columns.

procedure, public :: bind_predefined => table_bind_predefined

Binds a generated type's predefined columns.

generic, public :: assignment(=) => assign_guard

Blocks intrinsic assignment: the store lives behind a pointer, so a default b = a would leave two tables sharing one store and double-freeing it.

Read more…
procedure, public :: init => parquet_table_test_init

Opens a file and binds every predefined column.

generic, public :: init_slice => parquet_table_test_init_slice_i32, parquet_table_test_init_slice_i64

Opens one contiguous row range of a file, binding the same columns %init does. There is no sort argument: a sort reorders rows across the whole file, so a slice could not be cut along it.

generic, public :: init_empty => parquet_table_test_init_empty_none, parquet_table_test_init_empty_i32, parquet_table_test_init_empty_i64

Builds this table in memory, with no file behind it: every predefined column is created empty, or with nrows all-null rows. The output-catalogue shape.

procedure, public :: init_extra => parquet_table_test_init_extra

Resets/initializes YOUR components.

procedure, public :: clone_extra => parquet_table_test_clone_extra

Copies this type's own components on %clone/%clone_structure. Mostly written for you.

generic, public :: uberid => parquet_table_test_uberid_all, parquet_table_test_uberid_at_i32, parquet_table_test_uberid_at_i64, parquet_table_test_uberid_rng_i32, parquet_table_test_uberid_rng_i64
generic, public :: idx => parquet_table_test_idx_all, parquet_table_test_idx_at_i32, parquet_table_test_idx_at_i64, parquet_table_test_idx_rng_i32, parquet_table_test_idx_rng_i64
generic, public :: flag => parquet_table_test_flag_all, parquet_table_test_flag_at_i32, parquet_table_test_flag_at_i64, parquet_table_test_flag_rng_i32, parquet_table_test_flag_rng_i64
generic, public :: name => parquet_table_test_name_all, parquet_table_test_name_at_i32, parquet_table_test_name_at_i64, parquet_table_test_name_rng_i32, parquet_table_test_name_rng_i64
procedure, public :: name_chr => parquet_table_test_name_chr

Name of the object. (string) Copied out as a character array sized to the longest value present.

generic, public :: ra => parquet_table_test_ra_all, parquet_table_test_ra_at_i32, parquet_table_test_ra_at_i64, parquet_table_test_ra_rng_i32, parquet_table_test_ra_rng_i64
generic, public :: dec => parquet_table_test_dec_all, parquet_table_test_dec_at_i32, parquet_table_test_dec_at_i64, parquet_table_test_dec_rng_i32, parquet_table_test_dec_rng_i64
generic, public :: crd => parquet_table_test_crd_all, parquet_table_test_crd_at_i32, parquet_table_test_crd_at_i64, parquet_table_test_crd_rng_i32, parquet_table_test_crd_rng_i64
generic, public :: counts => parquet_table_test_counts_all, parquet_table_test_counts_at_i32, parquet_table_test_counts_at_i64, parquet_table_test_counts_rng_i32, parquet_table_test_counts_rng_i64
generic, public :: passed => parquet_table_test_passed_all, parquet_table_test_passed_at_i32, parquet_table_test_passed_at_i64, parquet_table_test_passed_rng_i32, parquet_table_test_passed_rng_i64
generic, public :: obsdate => parquet_table_test_obsdate_all, parquet_table_test_obsdate_at_i32, parquet_table_test_obsdate_at_i64, parquet_table_test_obsdate_rng_i32, parquet_table_test_obsdate_rng_i64
generic, public :: obstime => parquet_table_test_obstime_all, parquet_table_test_obstime_at_i32, parquet_table_test_obstime_at_i64, parquet_table_test_obstime_rng_i32, parquet_table_test_obstime_rng_i64
generic, public :: obsstamp => parquet_table_test_obsstamp_all, parquet_table_test_obsstamp_at_i32, parquet_table_test_obsstamp_at_i64, parquet_table_test_obsstamp_rng_i32, parquet_table_test_obsstamp_rng_i64
procedure, public :: tags_chr => parquet_table_test_tags_chr

A string vector column, which has only the character copy-out form. (string, width 2) Copied out as a character array sized to the longest value present.

generic, public :: flux => parquet_table_test_flux_all, parquet_table_test_flux_at_i32, parquet_table_test_flux_at_i64, parquet_table_test_flux_rng_i32, parquet_table_test_flux_rng_i64