formatters

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatParquet = "parquet"
)

Format type constants

Variables

This section is empty.

Functions

func UsesInternalCompression

func UsesInternalCompression(format string) bool

UsesInternalCompression returns true if the format handles compression internally

Types

type CSVFormatter

type CSVFormatter struct{}

CSVFormatter handles CSV format output

func NewCSVFormatter

func NewCSVFormatter() *CSVFormatter

NewCSVFormatter creates a new CSV formatter

func (*CSVFormatter) Extension

func (f *CSVFormatter) Extension() string

Extension returns the file extension for CSV files

func (*CSVFormatter) Format

func (f *CSVFormatter) Format(rows []map[string]interface{}) ([]byte, error)

Format converts rows to CSV format

func (*CSVFormatter) MIMEType

func (f *CSVFormatter) MIMEType() string

MIMEType returns the MIME type for CSV

type Formatter

type Formatter interface {
	// Format converts database rows to the target format
	Format(rows []map[string]interface{}) ([]byte, error)

	// Extension returns the file extension for this format (e.g., ".jsonl", ".csv", ".parquet")
	Extension() string

	// MIMEType returns the MIME type for this format
	MIMEType() string
}

Formatter defines the interface for output format handlers

func GetFormatter

func GetFormatter(format string) Formatter

GetFormatter returns the appropriate formatter based on the format string

func GetFormatterWithCompression

func GetFormatterWithCompression(format string, compression string) Formatter

GetFormatterWithCompression returns the appropriate formatter with compression settings For Parquet, this enables internal compression. For other formats, compression parameter is ignored.

type JSONLFormatter

type JSONLFormatter struct{}

JSONLFormatter handles JSONL (JSON Lines) format output

func NewJSONLFormatter

func NewJSONLFormatter() *JSONLFormatter

NewJSONLFormatter creates a new JSONL formatter

func (*JSONLFormatter) Extension

func (f *JSONLFormatter) Extension() string

Extension returns the file extension for JSONL files

func (*JSONLFormatter) Format

func (f *JSONLFormatter) Format(rows []map[string]interface{}) ([]byte, error)

Format converts rows to JSONL format (one JSON object per line)

func (*JSONLFormatter) MIMEType

func (f *JSONLFormatter) MIMEType() string

MIMEType returns the MIME type for JSONL

type ParquetFormatter

type ParquetFormatter struct {
	// contains filtered or unexported fields
}

ParquetFormatter handles Parquet format output

func NewParquetFormatter

func NewParquetFormatter() *ParquetFormatter

NewParquetFormatter creates a new Parquet formatter

func NewParquetFormatterWithCompression

func NewParquetFormatterWithCompression(compression string) *ParquetFormatter

NewParquetFormatterWithCompression creates a Parquet formatter with specified compression

func (*ParquetFormatter) Extension

func (f *ParquetFormatter) Extension() string

Extension returns the file extension for Parquet files

func (*ParquetFormatter) Format

func (f *ParquetFormatter) Format(rows []map[string]interface{}) ([]byte, error)

Format converts rows to Parquet format

func (*ParquetFormatter) MIMEType

func (f *ParquetFormatter) MIMEType() string

MIMEType returns the MIME type for Parquet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL