file

package
v0.3.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: 14 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

Examples

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, waits for in-flight snapshot calls, and is a no-op for a nil or zero-value snapshot.

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. Records iterates the same rows with a for loop and owns the stream.

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. RecordsIndices iterates the same rows with a for loop and owns the 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. RecordsRange iterates the same rows with a for loop and owns the stream.

func (*Reader) Records added in v0.3.0

func (r *Reader) Records(ctx context.Context, opts ReadOptions) iter.Seq2[arrow.RecordBatch, error]

Records iterates over all rows as Arrow batches. It matches ReadAll, but opens the stream when iteration starts and releases it when iteration ends, including an early break or an error, so the caller releases no stream.

Each yielded batch is borrowed until iteration advances; call Retain to keep one. An open or iteration error is yielded as the second value. The Reader stays usable after iteration ends.

Example

This example writes a small raw Lance file and ranges over its batches. Records opens the stream when iteration starts and releases it when iteration ends, so the caller releases no stream. Each yielded batch stays borrowed until iteration advances; call Retain to keep one.

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"path/filepath"

	"github.com/apache/arrow-go/v18/arrow"
	"github.com/apache/arrow-go/v18/arrow/array"
	"github.com/apache/arrow-go/v18/arrow/memory"

	"github.com/lance-format/lance-go/file"
)

func main() {
	ctx := context.Background()
	dir, err := os.MkdirTemp("", "lance-go-example-file-")
	if err != nil {
		log.Fatal(err)
	}
	defer os.RemoveAll(dir)
	path := filepath.Join(dir, "data.lance")

	schema := arrow.NewSchema([]arrow.Field{
		{Name: "id", Type: arrow.PrimitiveTypes.Int64, Nullable: false},
		{Name: "name", Type: arrow.BinaryTypes.String, Nullable: true},
	}, nil)
	builder := array.NewRecordBuilder(memory.DefaultAllocator, schema)
	builder.Field(0).(*array.Int64Builder).AppendValues([]int64{1, 2, 3}, nil)
	builder.Field(1).(*array.StringBuilder).AppendValues([]string{"a", "b", "c"}, nil)
	batch := builder.NewRecordBatch()
	defer batch.Release()
	builder.Release()

	writer, err := file.Create(ctx, path, schema, nil)
	if err != nil {
		log.Fatal(err)
	}
	if err := writer.Write(ctx, batch); err != nil {
		log.Fatal(err)
	}
	if _, err := writer.Finish(ctx); err != nil {
		log.Fatal(err)
	}
	if err := writer.Close(); err != nil {
		log.Fatal(err)
	}

	reader, err := file.Open(ctx, path, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer reader.Close()

	for batch, err := range reader.Records(ctx, file.ReadOptions{BatchSize: 2}) {
		if err != nil {
			log.Fatal(err)
		}
		ids := batch.Column(0).(*array.Int64)
		for i := 0; i < ids.Len(); i++ {
			fmt.Println(ids.Value(i))
		}
	}
}
Output:
1
2
3

func (*Reader) RecordsIndices added in v0.3.0

func (r *Reader) RecordsIndices(ctx context.Context, indices []uint32, opts ReadOptions) iter.Seq2[arrow.RecordBatch, error]

RecordsIndices iterates over rows at strictly increasing, unique row indices. It matches ReadIndices with the stream lifecycle and borrowing rules of Records; an ordering the native reader rejects is yielded as an iteration error.

Each traversal reads indices when it opens its stream, so a change made between traversals affects the next result; changing the slice while a traversal opens its stream races with that read.

func (*Reader) RecordsRange added in v0.3.0

func (r *Reader) RecordsRange(ctx context.Context, offset, numRows uint64, opts ReadOptions) iter.Seq2[arrow.RecordBatch, error]

RecordsRange iterates over numRows rows starting at offset. It matches ReadRange with the stream lifecycle and borrowing rules of Records.

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. A non-nil value may be a root
	// accessor or one returned by NewStorageOptions or
	// NewStorageOptionsWithProvider. 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. A non-nil value may be a root
	// accessor or one returned by NewStorageOptions or
	// NewStorageOptionsWithProvider.
	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, waits for in-flight snapshot calls, and is a no-op for a nil or zero-value snapshot.

func (*Statistics) Columns

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

Columns copies per-column statistics.

type StorageOptions

type StorageOptions = lance.StorageOptionsAccessor

StorageOptions is an alias for the root lance.StorageOptionsAccessor. Raw file APIs accept it directly, so file readers, writers and sessions share the root accessor's single native lifecycle and the caller closes it once.

A nil *StorageOptions selects native defaults. NewStorageOptions and NewStorageOptionsWithProvider create accessors with the same rules as the root constructors, except that NewStorageOptions treats a nil or empty map as an explicitly empty option set rather than native None.

Every reader, writer and session pins the accessor while it opens and then retains its own native reference. Close is idempotent, prevents later opens, and waits only for open calls currently acquiring the accessor; it does not wait for native handles that already opened, and those handles remain usable afterwards. Callers own the provider value passed to NewStorageOptionsWithProvider; the SDK never calls a provider Close method and keeps the provider reachable until native releases the final owner, including after Close.

NewStorageOptionsFromAccessor remains for source compatibility and returns the same accessor it receives. Pass the root accessor to ReaderOptions, WriterOptions or SessionOptions directly instead; closing the accessor stays with its creator.

func NewStorageOptions

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

NewStorageOptions creates static storage options. A nil or empty map produces an explicit empty option set, matching the historical file behavior and differing from a nil *StorageOptions, which selects native defaults.

func NewStorageOptionsFromAccessor deprecated

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

NewStorageOptionsFromAccessor returns owned unchanged. It is retained for source compatibility with the 0.2 adopting wrapper. Closing the returned accessor closes the same native accessor as closing owned; pass owned directly to file APIs instead and leave closing it to its creator. A nil owned value is rejected, while a non-nil zero value behaves as already closed.

Deprecated: pass the accessor directly to ReaderOptions, WriterOptions or SessionOptions.

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 until the provider resolves; a non-nil map, including an empty one, means an explicit initial set.

The provider value remains caller-owned. The SDK does not call a provider Close method and keeps the provider reachable through the accessor's native callback adapter until native releases the final owner, so it may also be reused by another accessor.

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.

Example

This example writes one raw Lance file and reads it back without a dataset manifest.

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"path/filepath"

	"github.com/apache/arrow-go/v18/arrow"
	"github.com/apache/arrow-go/v18/arrow/array"
	"github.com/apache/arrow-go/v18/arrow/memory"

	"github.com/lance-format/lance-go/file"
)

func main() {
	ctx := context.Background()
	dir, err := os.MkdirTemp("", "lance-go-file-")
	if err != nil {
		log.Fatal(err)
	}
	defer os.RemoveAll(dir)
	uri := filepath.Join(dir, "data.lance")

	schema := arrow.NewSchema([]arrow.Field{
		{Name: "id", Type: arrow.PrimitiveTypes.Int64},
		{Name: "name", Type: arrow.BinaryTypes.String},
	}, nil)
	builder := array.NewRecordBuilder(memory.DefaultAllocator, schema)
	builder.Field(0).(*array.Int64Builder).AppendValues([]int64{1, 2}, nil)
	builder.Field(1).(*array.StringBuilder).AppendValues([]string{"a", "b"}, nil)
	batch := builder.NewRecordBatch()
	builder.Release()

	writer, err := file.Create(ctx, uri, schema, nil)
	if err != nil {
		log.Fatal(err)
	}
	if err := writer.Write(ctx, batch); err != nil {
		log.Fatal(err)
	}
	batch.Release()
	summary, err := writer.Finish(ctx)
	if err != nil {
		log.Fatal(err)
	}
	if err := writer.Close(); err != nil {
		log.Fatal(err)
	}
	fmt.Println("rows written:", summary.NumRows)

	reader, err := file.Open(ctx, uri, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer reader.Close()

	rows, err := reader.ReadAll(ctx, file.ReadOptions{})
	if err != nil {
		log.Fatal(err)
	}
	defer rows.Release()
	for rows.Next() {
		record := rows.RecordBatch()
		ids := record.Column(record.Schema().FieldIndices("id")[0]).(*array.Int64)
		names := record.Column(record.Schema().FieldIndices("name")[0]).(*array.String)
		for i := 0; i < ids.Len(); i++ {
			fmt.Printf("%d:%s\n", ids.Value(i), names.Value(i))
		}
	}
	if err := rows.Err(); err != nil {
		log.Fatal(err)
	}
}
Output:
rows written: 2
1:a
2:b

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. A non-nil value may be a root
	// accessor or one returned by NewStorageOptions or
	// NewStorageOptionsWithProvider. 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