@earth-app/collegedb
    Preparing search index...

    Function rebalance

    • Moves stored mappings onto the shard the placement function computes.

      This is the migration for a deployment whose keys were placed before 1.4.0. Once it reports moved: 0 with no failures, the stored mappings agree with the placement function and placement: 'computed' can drop the KV read without changing where any key resolves.

      It is also the measurement that decides whether computed placement is worth enabling: a keyspace that still disagrees after a pass is a keyspace whose exceptions are the mapping.

      Parameters

      • table: string

        Table whose rows move with their mapping

      • options: { concurrency?: number; dryRun?: boolean } = {}

        Concurrency and a dry-run switch

      Returns Promise<RebalanceResult>

      Counts of agreed, moved, and failed keys

      If CollegeDB is not initialized

      1.4.0

      const result = await rebalance('users', { dryRun: true });
      console.log(`${result.agreed}/${result.examined} keys already agree`);