Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::FeatureWriter Class Reference

Append-only writer for a single feature group. More...

#include <feature_writer.hpp>

Public Types

using Options = FeatureWriterOptions
 Alias for the options struct.
 

Public Member Functions

 FeatureWriter ()=default
 Default-construct an empty writer (use create() factory instead).
 
 FeatureWriter (FeatureWriter &&) noexcept=default
 
FeatureWriteroperator= (FeatureWriter &&) noexcept=default
 
 FeatureWriter (const FeatureWriter &)=delete
 
FeatureWriteroperator= (const FeatureWriter &)=delete
 
 ~FeatureWriter ()
 
expected< void > write (const FeatureVector &fv)
 Write a single feature vector to the store.
 
expected< void > write_batch (const FeatureVector *fvs, size_t count)
 Write a contiguous array of feature vectors.
 
expected< void > write_batch (const std::vector< FeatureVector > &fvs)
 Write a vector of feature vectors.
 
expected< void > flush ()
 Flush all buffered rows to the current Parquet file as a new row group.
 
expected< void > close ()
 Close the writer: flush remaining data, write Parquet footer, and finalize the file.
 
const FeatureGroupDefgroup_def () const
 Return the feature group definition used by this writer.
 
int64_t rows_written () const
 Total number of rows written (including flushed and pending).
 
std::vector< std::string > output_files () const
 Return a copy of all finalized output file paths (excludes the active file).
 
bool is_open () const
 Check whether the writer currently has an open Parquet file.
 

Static Public Member Functions

static expected< FeatureWritercreate (Options opts)
 Create a new FeatureWriter for the given options.
 

Detailed Description

Append-only writer for a single feature group.

Writes typed, versioned feature vectors keyed by entity_id and timestamp_ns into Parquet files. Schema layout per file: col 0 = entity_id (STRING), col 1 = timestamp_ns (INT64), col 2 = version (INT32), col 3..N = feature columns (DOUBLE).

Files are append-only and automatically rolled when max_file_rows is reached. The writer flushes pending rows to a row group when the buffer reaches row_group_size.

Note
Movable but not copyable. The destructor calls close() if the writer is still open.
See also
FeatureWriterOptions, FeatureGroupDef, FeatureVector, FeatureReader

Definition at line 102 of file feature_writer.hpp.

Member Typedef Documentation

◆ Options

Alias for the options struct.

Definition at line 105 of file feature_writer.hpp.

Constructor & Destructor Documentation

◆ FeatureWriter() [1/3]

signet::forge::FeatureWriter::FeatureWriter ( )
default

Default-construct an empty writer (use create() factory instead).

◆ FeatureWriter() [2/3]

signet::forge::FeatureWriter::FeatureWriter ( FeatureWriter &&  )
defaultnoexcept

◆ FeatureWriter() [3/3]

signet::forge::FeatureWriter::FeatureWriter ( const FeatureWriter )
delete

◆ ~FeatureWriter()

signet::forge::FeatureWriter::~FeatureWriter ( )
inline

Definition at line 177 of file feature_writer.hpp.

Member Function Documentation

◆ close()

expected< void > signet::forge::FeatureWriter::close ( )
inline

Close the writer: flush remaining data, write Parquet footer, and finalize the file.

Returns
Success, or an IO error from the underlying ParquetWriter.

Definition at line 303 of file feature_writer.hpp.

◆ create()

static expected< FeatureWriter > signet::forge::FeatureWriter::create ( Options  opts)
inlinestatic

Create a new FeatureWriter for the given options.

Creates the output directory if it does not exist. Validates that the output_dir does not contain path traversal components.

Parameters
optsWriter configuration (output directory, group schema, etc.).
Returns
A ready-to-write FeatureWriter, or an Error on validation/IO failure.

Definition at line 118 of file feature_writer.hpp.

◆ flush()

expected< void > signet::forge::FeatureWriter::flush ( )
inline

Flush all buffered rows to the current Parquet file as a new row group.

Opens a new file if none is currently open. Automatically rolls to a new file when max_file_rows is exceeded.

Returns
Success, or an IO error from the underlying ParquetWriter.

Definition at line 250 of file feature_writer.hpp.

◆ group_def()

const FeatureGroupDef & signet::forge::FeatureWriter::group_def ( ) const
inline

Return the feature group definition used by this writer.

Definition at line 324 of file feature_writer.hpp.

◆ is_open()

bool signet::forge::FeatureWriter::is_open ( ) const
inline

Check whether the writer currently has an open Parquet file.

Definition at line 330 of file feature_writer.hpp.

◆ operator=() [1/2]

FeatureWriter & signet::forge::FeatureWriter::operator= ( const FeatureWriter )
delete

◆ operator=() [2/2]

FeatureWriter & signet::forge::FeatureWriter::operator= ( FeatureWriter &&  )
defaultnoexcept

◆ output_files()

std::vector< std::string > signet::forge::FeatureWriter::output_files ( ) const
inline

Return a copy of all finalized output file paths (excludes the active file).

Definition at line 328 of file feature_writer.hpp.

◆ rows_written()

int64_t signet::forge::FeatureWriter::rows_written ( ) const
inline

Total number of rows written (including flushed and pending).

Definition at line 326 of file feature_writer.hpp.

◆ write()

expected< void > signet::forge::FeatureWriter::write ( const FeatureVector fv)
inline

Write a single feature vector to the store.

Buffers internally; flushes a row group when the buffer reaches row_group_size.

Parameters
fvThe feature vector to write. Its values.size() must match the number of feature names in the group definition.
Returns
Success, or SCHEMA_MISMATCH if the value count is wrong.

Definition at line 193 of file feature_writer.hpp.

◆ write_batch() [1/2]

expected< void > signet::forge::FeatureWriter::write_batch ( const FeatureVector fvs,
size_t  count 
)
inline

Write a contiguous array of feature vectors.

Parameters
fvsPointer to the first FeatureVector.
countNumber of vectors to write.
Returns
Success, or an error from an individual write.

Definition at line 225 of file feature_writer.hpp.

◆ write_batch() [2/2]

expected< void > signet::forge::FeatureWriter::write_batch ( const std::vector< FeatureVector > &  fvs)
inline

Write a vector of feature vectors.

Parameters
fvsThe feature vectors to write.
Returns
Success, or an error from an individual write.

Definition at line 236 of file feature_writer.hpp.


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