file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package file provides the raw Lance file API.

The package reads and writes individual .lance files. Dataset operations live in the root lance package. Importing file initializes the default native bundle through that root dependency, including in CGO-free builds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferDescriptor

type BufferDescriptor struct {
	Position uint64
	Size     uint64
}

BufferDescriptor locates a byte range in the file.

type CacheMode

type CacheMode int32

CacheMode selects the reader's page-cache behavior.

const (
	// CacheNone disables the reader cache.
	CacheNone CacheMode = 0
	// CacheSession uses the cache owned by the file session the reader was
	// opened from, or by ReaderOptions.Session for a standalone reader. It is
	// invalid when neither session is set.
	CacheSession CacheMode = 1
)

type ColumnMetadata

type ColumnMetadata struct {
	Buffers  []BufferDescriptor
	Pages    []PageMetadata
	Encoding EncodingDescriptor
}

ColumnMetadata is an owned column descriptor.

type ColumnStatistics

type ColumnStatistics struct {
	NumPages  uint64
	SizeBytes uint64
}

ColumnStatistics is an owned per-column statistics snapshot.

type DedicatedBlobWriter

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

DedicatedBlobWriter writes one dedicated blob sidecar. It is safe for concurrent use. Close waits for in-flight calls and is idempotent.

func (*DedicatedBlobWriter) BlobID

func (w *DedicatedBlobWriter) BlobID() uint32

BlobID returns the native blob id.

func (*DedicatedBlobWriter) Close

func (w *DedicatedBlobWriter) Close() error

Close frees the native allocation and waits for in-flight calls.

func (*DedicatedBlobWriter) FinishArray

func (w *DedicatedBlobWriter) FinishArray(ctx context.Context, fieldName string) (arrow.Field, arrow.Array, error)

FinishArray consumes the native writer and returns its prepared descriptor. The returned array owns its buffers. Call Close to release the allocation.

func (*DedicatedBlobWriter) Path

func (w *DedicatedBlobWriter) Path() (string, error)

Path returns the native sidecar path.

func (*DedicatedBlobWriter) Write

func (w *DedicatedBlobWriter) Write(ctx context.Context, data []byte) error

Write appends bytes to the dedicated sidecar.

type DelimitedList

type DelimitedList struct {
	CommonPrefixes []string
	Objects        []string
}

DelimitedList is a copied native list-with-delimiter result.

type EncodingDescriptor

type EncodingDescriptor struct {
	Kind           EncodingKind
	BufferLocation uint64
	BufferLength   uint64
	DirectBytes    []byte
}

EncodingDescriptor describes one native encoding.

type EncodingKind

type EncodingKind int32

EncodingKind identifies how a page or column is encoded.

const (
	EncodingAbsent   EncodingKind = 0
	EncodingNone     EncodingKind = 1
	EncodingDirect   EncodingKind = 2
	EncodingIndirect EncodingKind = 3
)

type FormatVersion

type FormatVersion int32

FormatVersion identifies the raw file format revision.

const (
	FormatV1   FormatVersion = 0
	FormatV2_0 FormatVersion = 1
	FormatV2_1 FormatVersion = 2
	FormatV2_2 FormatVersion = 3
	FormatV2_3 FormatVersion = 4
)

type Metadata

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

Metadata is an independent native metadata snapshot. It stays usable after the reader and session that produced it are closed.

func (*Metadata) Close

func (m *Metadata) Close() error

Close releases the native snapshot. It is idempotent and waits for in-flight snapshot calls.

func (*Metadata) Columns

func (m *Metadata) Columns() ([]ColumnMetadata, error)

Columns copies per-column and per-page descriptors.

func (*Metadata) GlobalBuffers

func (m *Metadata) GlobalBuffers() ([]BufferDescriptor, error)

GlobalBuffers copies global buffer descriptors. Use Reader.ReadGlobalBuffer to fetch contents.

func (*Metadata) Info

func (m *Metadata) Info() (MetadataInfo, error)

Info copies scalar metadata.

func (*Metadata) Schema

func (m *Metadata) Schema() (*arrow.Schema, error)

Schema returns the complete file schema, including field metadata.

type MetadataInfo

type MetadataInfo struct {
	FormatVersion          FormatVersion
	MajorVersion           uint16
	MinorVersion           uint16
	NumRows                uint64
	NumDataBytes           uint64
	NumColumnMetadataBytes uint64
	NumGlobalBufferBytes   uint64
	NumFooterBytes         uint64
	FileSizeBytes          uint64
	NumColumns             uint64
	NumPhysicalColumns     uint64
	NumGlobalBuffers       uint64
}

MetadataInfo is an owned scalar metadata snapshot.

type PackedBlobWriter

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

PackedBlobWriter writes one packed blob sidecar. It is safe for concurrent use. Close waits for in-flight calls and is idempotent.

func (*PackedBlobWriter) BlobID

func (w *PackedBlobWriter) BlobID() uint32

BlobID returns the native blob id.

func (*PackedBlobWriter) Close

func (w *PackedBlobWriter) Close() error

Close frees the native allocation and waits for in-flight calls.

func (*PackedBlobWriter) FinishArray

func (w *PackedBlobWriter) FinishArray(ctx context.Context, fieldName string) (arrow.Field, arrow.Array, error)

FinishArray consumes the native writer and returns its prepared descriptor. The returned array owns its buffers. Call Close to release the allocation.

func (*PackedBlobWriter) Path

func (w *PackedBlobWriter) Path() (string, error)

Path returns the native sidecar path.

func (*PackedBlobWriter) Write

func (w *PackedBlobWriter) Write(ctx context.Context, data []byte) error

Write appends one payload.

func (*PackedBlobWriter) WriteBlobs

func (w *PackedBlobWriter) WriteBlobs(ctx context.Context, payloads arrow.Array) error

WriteBlobs appends one Arrow array of Binary, LargeBinary, or FixedSizeBinary payloads. Bytes from payloads are copied before it returns, so the array remains owned and usable by the caller. Nulls and non-null empty payloads keep their distinct meanings in the finished descriptors.

type PageMetadata

type PageMetadata struct {
	Buffers             []BufferDescriptor
	NumRows             uint64
	Priority            uint64
	Encoding            EncodingDescriptor
	EncodingDescription string
}

PageMetadata is an owned page descriptor.

type ReadOptions

type ReadOptions struct {
	BatchSize      uint32
	BatchReadahead uint32
}

ReadOptions controls Arrow batch production. Zero values select 1024 rows per batch and 16 batches of readahead, matching the native Python reader.

type Reader

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

Reader reads one raw Lance file. It is safe for concurrent use. Close waits for in-flight calls and is idempotent. Record readers and metadata snapshots already returned remain usable after Close.

func Open

func Open(ctx context.Context, uri string, opts *ReaderOptions) (*Reader, error)

Open opens uri as a raw Lance file.

func (*Reader) Close

func (r *Reader) Close() error

Close releases the reader allocation and waits for in-flight calls. Streams already returned by ReadAll, ReadRange, or ReadIndices remain usable.

func (*Reader) IOStats

func (r *Reader) IOStats() (ScanStats, error)

IOStats returns cumulative native IO counters.

func (*Reader) Metadata

func (r *Reader) Metadata() (*Metadata, error)

Metadata returns an independent metadata snapshot.

func (*Reader) NumRows

func (r *Reader) NumRows() (uint64, error)

NumRows returns the file row count.

func (*Reader) ReadAll

func (r *Reader) ReadAll(ctx context.Context, opts ReadOptions) (array.RecordReader, error)

ReadAll streams all rows. The returned reader is independent of this Reader and remains valid after Close.

func (*Reader) ReadGlobalBuffer

func (r *Reader) ReadGlobalBuffer(ctx context.Context, index uint32) ([]byte, error)

ReadGlobalBuffer reads a global buffer. Index 0 is the serialized schema; writer-added buffers start at 1.

func (*Reader) ReadIndices

func (r *Reader) ReadIndices(ctx context.Context, indices []uint32, opts ReadOptions) (array.RecordReader, error)

ReadIndices streams rows at strictly increasing, unique row indices. An empty slice reads no rows. Invalid ordering is rejected by the native reader, either here or while advancing the returned stream.

func (*Reader) ReadRange

func (r *Reader) ReadRange(ctx context.Context, offset, numRows uint64, opts ReadOptions) (array.RecordReader, error)

ReadRange streams numRows rows starting at offset.

func (*Reader) Schema

func (r *Reader) Schema() (*arrow.Schema, error)

Schema returns the complete file schema.

func (*Reader) Statistics

func (r *Reader) Statistics() (*Statistics, error)

Statistics returns an independent statistics snapshot.

func (*Reader) String

func (r *Reader) String() string

type ReaderOptions

type ReaderOptions struct {
	// Columns projects the file. A nil slice leaves projection unset; a
	// non-nil empty slice requests an explicit empty projection.
	Columns []string
	// CacheMode defaults to CacheNone.
	CacheMode CacheMode

	ReadChunkSize        *uint64
	BatchSizeBytes       *uint64
	CacheRepetitionIndex *bool
	ValidateOnDecode     *bool
	InlineScheduling     *bool

	// Scheduler is nil for native defaults. Session.OpenReader rejects a
	// non-nil value because session readers inherit the session scheduler.
	Scheduler *SchedulerConfig
	// StorageOptions is nil for native defaults. Session.OpenReader rejects a
	// non-nil value because session readers use the session store.
	StorageOptions *StorageOptions
	// Session shares an existing Lance session's caches with a standalone
	// reader. Nil uses no shared cache. Session.OpenReader rejects a non-nil
	// value because session readers use the file session's cache and store.
	Session *lance.Session
}

ReaderOptions configures a raw file reader. Pointer fields distinguish an unset option from an explicit zero value.

type RegistryStats

type RegistryStats struct {
	Hits         uint64
	Misses       uint64
	ActiveStores uint64
}

RegistryStats is a native object-store registry counter snapshot.

type ScanStats

type ScanStats struct {
	IOPS      uint64
	Requests  uint64
	BytesRead uint64
}

ScanStats is a native scan counter snapshot.

type SchedulerConfig

type SchedulerConfig struct {
	IOBufferSizeBytes uint64
	LiteMode          SchedulerLiteMode
}

SchedulerConfig configures the native scan scheduler.

type SchedulerLiteMode

type SchedulerLiteMode int32

SchedulerLiteMode selects the native scheduler implementation.

const (
	SchedulerAuto     SchedulerLiteMode = 0
	SchedulerStandard SchedulerLiteMode = 1
	SchedulerLite     SchedulerLiteMode = 2
)

type Session

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

Session groups raw file operations under one resolved base path and object store. It is safe for concurrent use. Close waits for in-flight calls and is idempotent. Readers, writers, streams, and blob writers already opened remain usable after Close.

func OpenSession

func OpenSession(ctx context.Context, baseURI string, opts *SessionOptions) (*Session, error)

OpenSession opens a raw file session over baseURI.

func (*Session) BasePath

func (s *Session) BasePath() (string, error)

BasePath returns the resolved native base path.

func (*Session) Close

func (s *Session) Close() error

Close releases the session allocation and waits for in-flight calls.

func (*Session) Contains

func (s *Session) Contains(ctx context.Context, relativePath string) (bool, error)

Contains reports whether relativePath exists.

func (*Session) DeleteFile

func (s *Session) DeleteFile(ctx context.Context, relativePath string) error

DeleteFile removes relativePath.

func (*Session) DownloadFile

func (s *Session) DownloadFile(ctx context.Context, relativeRemotePath, localPath string) error

DownloadFile downloads relativeRemotePath to localPath.

func (*Session) List

func (s *Session) List(ctx context.Context, relativePath string) ([]string, error)

List returns paths relative to the session base.

func (*Session) ListWithDelimiter

func (s *Session) ListWithDelimiter(ctx context.Context, relativePath string) (DelimitedList, error)

ListWithDelimiter lists paths and common prefixes relative to the session base.

func (*Session) OpenDedicatedBlobWriter

func (s *Session) OpenDedicatedBlobWriter(ctx context.Context, dataFilePath string, blobID uint32) (*DedicatedBlobWriter, error)

OpenDedicatedBlobWriter opens a dedicated blob writer for dataFilePath and blobID.

func (*Session) OpenPackedBlobWriter

func (s *Session) OpenPackedBlobWriter(ctx context.Context, dataFilePath string, blobID uint32) (*PackedBlobWriter, error)

OpenPackedBlobWriter opens a packed blob writer for dataFilePath and blobID.

func (*Session) OpenReader

func (s *Session) OpenReader(ctx context.Context, relativePath string, opts *ReaderOptions) (*Reader, error)

OpenReader opens relativePath as a raw Reader.

func (*Session) OpenWriter

func (s *Session) OpenWriter(ctx context.Context, relativePath string, schema *arrow.Schema, opts *WriterOptions) (*Writer, error)

OpenWriter opens relativePath as a raw Writer. A nil schema creates a lazy writer that adopts the first batch schema.

func (*Session) ReadRange

func (s *Session) ReadRange(ctx context.Context, relativePath string, offset, length uint64) ([]byte, error)

ReadRange reads length bytes at offset from relativePath.

func (*Session) RegistryStats

func (s *Session) RegistryStats() (RegistryStats, error)

RegistryStats returns native object-store registry counters.

func (*Session) SchedulerStats

func (s *Session) SchedulerStats() (ScanStats, error)

SchedulerStats returns native scheduler counters.

func (*Session) StoreIOStats

func (s *Session) StoreIOStats() (StoreIOStats, error)

StoreIOStats returns native object-store IO counters.

func (*Session) StoreInfo

func (s *Session) StoreInfo() (StoreInfo, error)

StoreInfo returns the resolved native object-store properties.

func (*Session) String

func (s *Session) String() string

func (*Session) UploadFile

func (s *Session) UploadFile(ctx context.Context, localPath, relativeRemotePath string) error

UploadFile uploads localPath to relativeRemotePath.

type SessionOptions

type SessionOptions struct {
	// StorageOptions is nil for native defaults.
	StorageOptions *StorageOptions
	// Scheduler is nil for native defaults.
	Scheduler *SchedulerConfig
	// Session shares an existing Lance session's store registry and caches.
	// Nil creates a session with no shared cache.
	Session *lance.Session
}

SessionOptions configures a raw file session.

type Statistics

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

Statistics is an independent native statistics snapshot.

func (*Statistics) Close

func (s *Statistics) Close() error

Close releases the native snapshot. It is idempotent and waits for in-flight snapshot calls.

func (*Statistics) Columns

func (s *Statistics) Columns() ([]ColumnStatistics, error)

Columns copies per-column statistics.

type StorageOptions

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

StorageOptions holds reusable object-store configuration. It can carry static options, a dynamic root StorageOptionsProvider, or both. A nil *StorageOptions means native defaults; NewStorageOptions always supplies an explicit option map.

StorageOptions may be closed once every session, reader, and writer opened with it has returned from its open call. Native handles clone or retain the resolved accessor, so later use of those handles is unaffected. The provider value passed to NewStorageOptionsWithProvider remains owned by the caller; this type owns only the native accessor and its retained callback context.

func NewStorageOptions

func NewStorageOptions(values map[string]string) (*StorageOptions, error)

NewStorageOptions creates static storage options. An empty map produces an explicit empty option set, which is different from passing nil.

func NewStorageOptionsFromAccessor

func NewStorageOptionsFromAccessor(owned *lance.StorageOptionsAccessor) (*StorageOptions, error)

NewStorageOptionsFromAccessor adopts an already-created root storage-options accessor. Ownership transfers to the returned StorageOptions; closing it closes the accessor. The accessor must not be closed separately while it is in use here. A non-nil zero-value accessor is accepted and behaves as already closed.

func NewStorageOptionsWithProvider

func NewStorageOptionsWithProvider(initial map[string]string, provider lance.StorageOptionsProvider) (*StorageOptions, error)

NewStorageOptionsWithProvider creates storage options with a dynamic provider and optional initial options. A nil initial map means native None; a non-nil map, including an empty one, means an explicit initial set.

The provider is retained by native datasets, readers, writers and sessions for as long as they need it. Callers may close the returned StorageOptions after open calls return without closing the provider themselves.

func (*StorageOptions) Close

func (o *StorageOptions) Close() error

Close releases the native accessor. It is idempotent and waits for open calls currently acquiring this StorageOptions, but not for native handles that retained their own accessor reference.

type StoreIOStats

type StoreIOStats struct {
	ReadIOPS     uint64
	ReadBytes    uint64
	WriteIOPS    uint64
	WrittenBytes uint64
}

StoreIOStats is a native object-store IO counter snapshot.

type StoreInfo

type StoreInfo struct {
	BlockSize            uint64
	MaxIOPSize           uint64
	IOParallelism        uint64
	IsLocal              bool
	IsCloud              bool
	PrefersLiteScheduler bool
}

StoreInfo describes the resolved object store.

type WriteSummary

type WriteSummary struct {
	NumRows   uint64
	SizeBytes uint64
}

WriteSummary is the native result of a successful Finish.

type Writer

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

Writer writes one raw Lance file. It is safe for concurrent use. Close waits for in-flight calls and is idempotent. Close does not imply a successful Finish.

func Create

func Create(ctx context.Context, uri string, schema *arrow.Schema, opts *WriterOptions) (*Writer, error)

Create creates uri as a raw Lance file. A nil schema creates a lazy writer that adopts the first batch schema.

func (*Writer) Abort

func (w *Writer) Abort(ctx context.Context) error

Abort forwards the native abort call. The writer allocation stays open until Close.

func (*Writer) AddGlobalBuffer

func (w *Writer) AddGlobalBuffer(ctx context.Context, data []byte) (uint32, error)

AddGlobalBuffer appends a global buffer and returns its one-based index.

func (*Writer) AddSchemaMetadata

func (w *Writer) AddSchemaMetadata(ctx context.Context, key, value string) error

AddSchemaMetadata adds one schema metadata entry.

func (*Writer) Close

func (w *Writer) Close() error

Close drops the writer allocation and waits for in-flight calls. It does not imply a successful finish.

func (*Writer) Finish

func (w *Writer) Finish(ctx context.Context) (WriteSummary, error)

Finish finalizes the file. The writer allocation stays open until Close.

func (*Writer) Write

func (w *Writer) Write(ctx context.Context, batch arrow.RecordBatch) error

Write writes one borrowed batch. The writer does not retain the batch after Write returns.

type WriterOptions

type WriterOptions struct {
	DataCacheBytes    *uint64
	MaxPageBytes      *uint64
	KeepOriginalArray *bool
	// Version is the native format version selector. Empty uses native default.
	Version string
	// StorageOptions is nil for native defaults. Session.OpenWriter rejects a
	// non-nil value because session writers use the session store.
	StorageOptions *StorageOptions
	// Session shares an existing Lance session's caches with a standalone
	// writer. Nil uses no shared cache. Session.OpenWriter rejects a non-nil
	// value because session writers use the file session's store.
	Session *lance.Session
}

WriterOptions configures a raw file writer. Pointer fields distinguish an unset option from an explicit zero value.

Jump to

Keyboard shortcuts

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