UNPKG

@dobesv/parquets

Version:

TypeScript implementation of the Parquet file format, based on parquet.js

55 lines (54 loc) 1.67 kB
/// <reference types="node" /> /// <reference types="node" /> import { ParquetSchema } from './schema'; /** * Options for creating a ParquetBufferWriter */ export interface ParquetBufferWriterOptions { rowGroupSize?: number; pageSize?: number; useDataPageV2?: boolean; } /** * Synchronous in-memory Parquet writer that accumulates rows and returns a Buffer. */ export declare class ParquetBufferWriter<T = unknown> { private schema; private opts; private rowGroupSize; private pageSize; private rowCount; private rowBuffer; private rowGroups; private chunks; private offset; private headerWritten; private closed; constructor(schema: ParquetSchema, opts?: ParquetBufferWriterOptions); /** * Create a new ParquetBufferWriter and return it. */ static openBuffer<T = unknown>(schema: ParquetSchema, opts?: ParquetBufferWriterOptions): ParquetBufferWriter<T>; /** * Append a row to the buffer. */ appendRow(row: T): void; /** * Finalize and return the complete Parquet file as a Buffer. * Terminal operation: sets closed=true, throws if called twice. */ toBuffer(): Buffer; /** * Write a buffer section and update offset */ private writeSection; /** * Flush the current row group to chunks */ private flushRowGroup; } /** * Convenience function: write an array of rows to a Parquet buffer. * Equivalent to creating a ParquetBufferWriter, appending all rows, and calling toBuffer(). */ export declare function generateParquetBuffer<T>(schema: ParquetSchema, rows: T[], opts?: ParquetBufferWriterOptions): Buffer;