Documentation
¶
Overview ¶
Package compaction contains the option, metric, and transport values used by dataset compaction.
The types in this package are independent of a Dataset and of the native bindings. Dataset methods in the root package perform the actual native calls. Plan, task, and rewrite-result values are immutable snapshots: the native serialized JSON is authoritative, so a plan can be sent to another process and executed there without carrying a native handle across the boundary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CandidateFile ¶
CandidateFile is one file observed by CleanupExplain.
type CleanupExplanation ¶
type CleanupExplanation struct {
ReadVersion uint64
Stats RemovalStats
Candidates []CandidateFile
CandidateFilesTruncated bool
CandidateFileLimit uint64
ReferencedBranches []ReferencedBranch
Warnings []string
}
CleanupExplanation is an immutable snapshot of the cleanup candidates that existed when the explanation was requested.
It is not a deletion plan or a reservation. Running cleanup re-evaluates the current dataset state, so files listed here may no longer be removable, and files not listed here may have become removable.
type CleanupOldVersionsOptions ¶
type CleanupOldVersionsOptions struct {
// OlderThan is the relative age cutoff. Native Lance owns the exact
// cutoff calculation.
OlderThan time.Duration
// DeleteUnverified allows deleting files that are not referenced by a
// manifest.
DeleteUnverified *bool
// ErrorIfTaggedOldVersions fails instead of deleting a version that has
// tags.
ErrorIfTaggedOldVersions *bool
}
CleanupOldVersionsOptions configures the older-than cleanup helper.
type CleanupOperationOptions ¶
type CleanupOperationOptions struct {
// DeleteConcurrency limits concurrent deletions.
DeleteConcurrency *uint64
// DeleteRateLimit overrides CleanupPolicy.DeleteRateLimit.
DeleteRateLimit *uint64
// MaxCandidateFiles limits how many candidate files are included in an
// explanation. Zero is valid and includes no candidates while still
// reporting aggregate statistics and truncation.
MaxCandidateFiles *uint64
}
CleanupOperationOptions controls one cleanup execution.
A nil *CleanupOperationOptions uses native operation defaults.
type CleanupPolicy ¶
type CleanupPolicy struct {
// BeforeTimestamp selects versions created before this time.
BeforeTimestamp *time.Time
// BeforeVersion selects versions older than this version.
BeforeVersion *uint64
// Versions selects specific versions.
Versions []uint64
// RetainVersions keeps this many latest versions. It is mutually
// exclusive with BeforeVersion in the native selector.
RetainVersions *uint64
// DeleteUnverified allows deleting files that are not referenced by a
// manifest.
DeleteUnverified *bool
// ErrorIfTaggedOldVersions fails instead of deleting a version that has
// tags. Native defaults to true.
ErrorIfTaggedOldVersions *bool
// CleanReferencedBranches also cleans versions referenced by branches.
CleanReferencedBranches *bool
// DeleteRateLimit limits deletions per second.
DeleteRateLimit *uint64
}
CleanupPolicy selects old versions and files for native cleanup.
The selectors are independent and combine with logical AND. Nil pointers leave the corresponding native default unchanged. A nil Versions slice leaves the native versions selector absent; a non-nil empty slice is passed through as an explicit empty selector and is rejected by native validation.
type FileKind ¶
type FileKind int32
FileKind identifies a cleanup candidate file.
const ( // FileKindManifest is a manifest file. FileKindManifest FileKind = 0 // FileKindData is a data file. FileKindData FileKind = 1 // FileKindTransaction is a transaction file. FileKindTransaction FileKind = 2 // FileKindIndex is an index file. FileKindIndex FileKind = 3 // FileKindDeletion is a deletion file. FileKindDeletion FileKind = 4 // FileKindTemporaryManifest is a temporary manifest file. FileKindTemporaryManifest FileKind = 5 )
type IndexRemapMode ¶
type IndexRemapMode int32
IndexRemapMode selects how compaction remaps indexes.
const ( // IndexRemapCompact remaps indexes through the compaction path. IndexRemapCompact IndexRemapMode = 0 // IndexRemapDirect remaps indexes directly. IndexRemapDirect IndexRemapMode = 1 )
func (IndexRemapMode) String ¶
func (m IndexRemapMode) String() string
String returns the native option name.
type Metrics ¶
type Metrics struct {
FragmentsRemoved uint64
FragmentsAdded uint64
FilesRemoved uint64
FilesAdded uint64
}
Metrics reports the fragments and files changed by a compaction.
type Mode ¶
type Mode int32
Mode selects how compaction rewrites fragments.
const ( // ModeReencode rewrites data through the normal encoding path. ModeReencode Mode = 0 // ModeTryBinaryCopy uses binary copy when it is safe, and re-encodes // fragments that cannot be copied. ModeTryBinaryCopy Mode = 1 // ModeForceBinaryCopy requires binary copy and fails when a fragment // cannot be copied. ModeForceBinaryCopy Mode = 2 )
type OptimizeOptions ¶
type OptimizeOptions struct {
// NumIndicesToMerge limits how many existing index segments one merge
// absorbs. Unset leaves the native default (None): a split build appends a
// delta, while the single-process optimizer may instead merge all delta
// segments when a vector index's partitions need rebalancing. Some(n)
// merges the latest n segments plus the new updates, and Some(0) disables
// merging and appends a delta.
NumIndicesToMerge Optional[uint64]
// EnablePartitionRebalancing lets native optimization rebalance index
// partitions. Native validation rejects it together with Some(0) or with
// MaxRowsPerTask or MaxRowsPerSegment.
EnablePartitionRebalancing bool
// IndexNames limits optimization to the named indices. Unset and None
// leave the native default of every index; Some(nil) or Some with an
// empty slice explicitly selects no index.
IndexNames Optional[[]string]
// Retrain merges every segment of a selected vector index into one and
// retrains it. Native optimization only supports this for v3 vector
// indices.
Retrain bool
// TransactionProperties adds properties to the commit transaction. Nil
// leaves the native option unset; a non-nil map, including an empty one,
// sets it. The map is copied before the call returns.
TransactionProperties map[string]string
// MaxRowsPerTask bounds the rows one build task covers. Unset and None both
// leave the native bound unset (unbounded); Some sets it, including zero.
MaxRowsPerTask Optional[uint64]
// MaxRowsPerSegment bounds the rows in one output segment. Unset and None
// both leave the native bound unset (unbounded); Some sets it, including
// zero.
MaxRowsPerSegment Optional[uint64]
}
OptimizeOptions configures native index optimization.
A nil *OptimizeOptions passed to a Dataset method selects the native defaults (the C API's NULL options). A non-nil value starts from native defaults and applies only the fields that are set.
Unset optional fields leave the native default unchanged; None sets the native option to None explicitly; Some sets it, including an explicit zero or an empty slice. IndexNames and TransactionProperties are copied before the call returns.
Native plan, task, merge and result JSON do not serialize OptimizeOptions. Task JSON carries the merge options that execution re-applies (NumIndicesToMerge, EnablePartitionRebalancing and Retrain). IndexNames and the row bounds only select and split the plan. TransactionProperties apply only to a commit, so pass them again to CommitOptimizeIndices when the results crossed a JSON transport boundary.
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional represents a native optional option. Its zero value is unset, which leaves the corresponding native default unchanged.
Some and None map to the native setter's has_value flag. The distinction matters for options whose native default is Some(...), such as MaxOverlaysPerFragment and BinaryCopyReadBatchBytes.
type Options ¶
type Options struct {
// TargetRowsPerFragment is the target number of rows per output
// fragment. Nil leaves the native default (1048576) unchanged.
TargetRowsPerFragment *uint64
// MaxRowsPerGroup is the maximum number of rows per output group. Nil
// leaves the native default (1024) unchanged.
MaxRowsPerGroup *uint64
// MaxBytesPerFile limits output file size. Nil leaves the native
// default (none) unchanged; Some(0) is an explicit native value.
MaxBytesPerFile Optional[uint64]
// MaterializeDeletions controls whether deletions are materialized.
MaterializeDeletions *bool
// MaterializeDeletionsThreshold is the deletion density above which
// deletions are materialized. It is converted to a native float.
MaterializeDeletionsThreshold *float64
// NumThreads limits native compaction parallelism.
NumThreads Optional[uint64]
// BatchSize sets the native read batch size.
BatchSize Optional[uint64]
// IOBufferSize sets the native I/O buffer size.
IOBufferSize Optional[uint64]
// DeferIndexRemap defers index remapping to the commit path.
DeferIndexRemap *bool
// IndexRemapMode selects the index remap strategy.
IndexRemapMode *IndexRemapMode
// CompactionMode selects re-encode or binary copy.
CompactionMode Optional[Mode]
// BinaryCopyReadBatchBytes sets the binary-copy read batch size.
BinaryCopyReadBatchBytes Optional[uint64]
// MaxSourceFragments limits how many source fragments one task reads.
MaxSourceFragments Optional[uint64]
// MaxSourceRows limits how many source rows one task reads.
MaxSourceRows Optional[uint64]
// MaxSourceBytes limits how many source bytes one task reads.
MaxSourceBytes Optional[uint64]
// ExcludedFragmentIDs lists fragments that must not be compacted.
ExcludedFragmentIDs []uint32
// MaxOverlaysPerFragment limits the number of deletion overlays
// considered per fragment.
MaxOverlaysPerFragment Optional[uint64]
// DataStorageVersion selects the output storage version, for example
// "2.1" or "stable". None explicitly clears the native option.
DataStorageVersion Optional[string]
// TransactionProperties adds properties to the commit transaction. Nil
// leaves the native option unset; a non-nil map, including an empty one,
// sets it. The map is copied before the call returns.
//
// Native plan and task JSON does not serialize transaction properties.
// Pass them again to CommitCompaction when a plan or result crossed a
// JSON transport boundary.
TransactionProperties map[string]string
}
Options configures native CompactionOptionsV2.
A nil *Options passed to a Dataset method selects the native from-dataset-config options (the C API's NULL options). A non-nil Options starts from native defaults and applies only the fields that are set.
Pointer fields distinguish an absent value from an explicit zero or false. Optional fields additionally distinguish an explicit native None from an unset value. ExcludedFragmentIDs and TransactionProperties are copied before the call returns.
type ReferencedBranch ¶
ReferencedBranch is a branch observed by CleanupExplain.