@lancedb/lancedb • Docs
@lancedb/lancedb / PermutationBuilder
Class: PermutationBuilder¶
A PermutationBuilder for creating data permutations with splits, shuffling, and filtering.
This class provides a TypeScript wrapper around the native Rust PermutationBuilder, offering methods to configure data splits, shuffling, and filtering before executing the permutation to create a new table.
Methods¶
execute()¶
Execute the permutation and create the destination table.
Returns¶
Promise<Table>
A Promise that resolves to the new Table instance
Example¶
const permutationTable = await builder.execute();
console.log(`Created table: ${permutationTable.name}`);
filter()¶
Configure filtering for the permutation.
Parameters¶
- filter:
stringSQL filter expression
Returns¶
A new PermutationBuilder instance
Example¶
persist()¶
Configure the permutation to be persisted.
Parameters¶
-
connection:
ConnectionThe connection to persist the permutation to -
tableName:
stringThe name of the table to create
Returns¶
A new PermutationBuilder instance
Example¶
shuffle()¶
Configure shuffling for the permutation.
Parameters¶
- options:
ShuffleOptionsConfiguration for shuffling
Returns¶
A new PermutationBuilder instance
Example¶
// Basic shuffle
builder.shuffle({ seed: 42 });
// Shuffle with clump size
builder.shuffle({ seed: 42, clumpSize: 10 });
splitCalculated()¶
Configure calculated splits for the permutation.
Parameters¶
- options:
SplitCalculatedOptionsConfiguration for calculated splitting
Returns¶
A new PermutationBuilder instance
Example¶
splitHash()¶
Configure hash-based splits for the permutation.
Parameters¶
- options:
SplitHashOptionsConfiguration for hash-based splitting
Returns¶
A new PermutationBuilder instance
Example¶
splitRandom()¶
Configure random splits for the permutation.
Parameters¶
- options:
SplitRandomOptionsConfiguration for random splitting
Returns¶
A new PermutationBuilder instance
Example¶
// Split by ratios
builder.splitRandom({ ratios: [0.7, 0.3], seed: 42 });
// Split by counts
builder.splitRandom({ counts: [1000, 500], seed: 42 });
// Split with fixed size
builder.splitRandom({ fixed: 100, seed: 42 });
splitSequential()¶
Configure sequential splits for the permutation.
Parameters¶
- options:
SplitSequentialOptionsConfiguration for sequential splitting
Returns¶
A new PermutationBuilder instance