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 ¶
- type BufferDescriptor
- type CacheMode
- type ColumnMetadata
- type ColumnStatistics
- type DedicatedBlobWriter
- func (w *DedicatedBlobWriter) BlobID() uint32
- func (w *DedicatedBlobWriter) Close() error
- func (w *DedicatedBlobWriter) FinishArray(ctx context.Context, fieldName string) (arrow.Field, arrow.Array, error)
- func (w *DedicatedBlobWriter) Path() (string, error)
- func (w *DedicatedBlobWriter) Write(ctx context.Context, data []byte) error
- type DelimitedList
- type EncodingDescriptor
- type EncodingKind
- type FormatVersion
- type Metadata
- type MetadataInfo
- type PackedBlobWriter
- func (w *PackedBlobWriter) BlobID() uint32
- func (w *PackedBlobWriter) Close() error
- func (w *PackedBlobWriter) FinishArray(ctx context.Context, fieldName string) (arrow.Field, arrow.Array, error)
- func (w *PackedBlobWriter) Path() (string, error)
- func (w *PackedBlobWriter) Write(ctx context.Context, data []byte) error
- func (w *PackedBlobWriter) WriteBlobs(ctx context.Context, payloads arrow.Array) error
- type PageMetadata
- type ReadOptions
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) IOStats() (ScanStats, error)
- func (r *Reader) Metadata() (*Metadata, error)
- func (r *Reader) NumRows() (uint64, error)
- func (r *Reader) ReadAll(ctx context.Context, opts ReadOptions) (array.RecordReader, error)
- func (r *Reader) ReadGlobalBuffer(ctx context.Context, index uint32) ([]byte, error)
- func (r *Reader) ReadIndices(ctx context.Context, indices []uint32, opts ReadOptions) (array.RecordReader, error)
- func (r *Reader) ReadRange(ctx context.Context, offset, numRows uint64, opts ReadOptions) (array.RecordReader, error)
- func (r *Reader) Schema() (*arrow.Schema, error)
- func (r *Reader) Statistics() (*Statistics, error)
- func (r *Reader) String() string
- type ReaderOptions
- type RegistryStats
- type ScanStats
- type SchedulerConfig
- type SchedulerLiteMode
- type Session
- func (s *Session) BasePath() (string, error)
- func (s *Session) Close() error
- func (s *Session) Contains(ctx context.Context, relativePath string) (bool, error)
- func (s *Session) DeleteFile(ctx context.Context, relativePath string) error
- func (s *Session) DownloadFile(ctx context.Context, relativeRemotePath, localPath string) error
- func (s *Session) List(ctx context.Context, relativePath string) ([]string, error)
- func (s *Session) ListWithDelimiter(ctx context.Context, relativePath string) (DelimitedList, error)
- func (s *Session) OpenDedicatedBlobWriter(ctx context.Context, dataFilePath string, blobID uint32) (*DedicatedBlobWriter, error)
- func (s *Session) OpenPackedBlobWriter(ctx context.Context, dataFilePath string, blobID uint32) (*PackedBlobWriter, error)
- func (s *Session) OpenReader(ctx context.Context, relativePath string, opts *ReaderOptions) (*Reader, error)
- func (s *Session) OpenWriter(ctx context.Context, relativePath string, schema *arrow.Schema, ...) (*Writer, error)
- func (s *Session) ReadRange(ctx context.Context, relativePath string, offset, length uint64) ([]byte, error)
- func (s *Session) RegistryStats() (RegistryStats, error)
- func (s *Session) SchedulerStats() (ScanStats, error)
- func (s *Session) StoreIOStats() (StoreIOStats, error)
- func (s *Session) StoreInfo() (StoreInfo, error)
- func (s *Session) String() string
- func (s *Session) UploadFile(ctx context.Context, localPath, relativeRemotePath string) error
- type SessionOptions
- type Statistics
- type StorageOptions
- type StoreIOStats
- type StoreInfo
- type WriteSummary
- type Writer
- func (w *Writer) Abort(ctx context.Context) error
- func (w *Writer) AddGlobalBuffer(ctx context.Context, data []byte) (uint32, error)
- func (w *Writer) AddSchemaMetadata(ctx context.Context, key, value string) error
- func (w *Writer) Close() error
- func (w *Writer) Finish(ctx context.Context) (WriteSummary, error)
- func (w *Writer) Write(ctx context.Context, batch arrow.RecordBatch) error
- type WriterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferDescriptor ¶
BufferDescriptor locates a byte range in the file.
type ColumnMetadata ¶
type ColumnMetadata struct {
Buffers []BufferDescriptor
Pages []PageMetadata
Encoding EncodingDescriptor
}
ColumnMetadata is an owned column descriptor.
type ColumnStatistics ¶
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.
type DelimitedList ¶
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 ¶
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.
type MetadataInfo ¶
type MetadataInfo struct {
FormatVersion FormatVersion
MajorVersion uint16
MinorVersion uint16
NumRows uint64
NumDataBytes uint64
NumColumnMetadataBytes uint64
NumGlobalBufferBytes 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 ¶
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 ¶
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 (*Reader) Close ¶
Close releases the reader allocation and waits for in-flight calls. Streams already returned by ReadAll, ReadRange, or ReadIndices remain usable.
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 ¶
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) Statistics ¶
func (r *Reader) Statistics() (*Statistics, error)
Statistics returns an independent statistics snapshot.
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 ¶
RegistryStats is a native object-store registry 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 ¶
OpenSession opens a raw file session over baseURI.
func (*Session) DeleteFile ¶
DeleteFile removes relativePath.
func (*Session) DownloadFile ¶
DownloadFile downloads relativeRemotePath to localPath.
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 ¶
SchedulerStats returns native scheduler counters.
func (*Session) StoreIOStats ¶
func (s *Session) StoreIOStats() (StoreIOStats, error)
StoreIOStats returns native object-store IO counters.
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 ¶
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 ¶
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 ¶
Abort forwards the native abort call. The writer allocation stays open until Close.
func (*Writer) AddGlobalBuffer ¶
AddGlobalBuffer appends a global buffer and returns its one-based index.
func (*Writer) AddSchemaMetadata ¶
AddSchemaMetadata adds one schema metadata entry.
func (*Writer) Close ¶
Close drops the writer allocation and waits for in-flight calls. It does not imply a successful finish.
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.