beads/cmd/bd/export_source.go
Bee 91aeeb0548
perf(storage/db): batch fetchIssuesByIDs, GetBlockingInfo and loadStatusByID at 200 ids; delete tolerates only a missing wisps table (#6444)
* perf(storage/db): batch the bulk IN-list readers at 200 ids; export narrows the wisp-plane reads

bd export on a 19,413-issue rig in proxied-server (UOW) mode took 264-287s.
The cmd layer is bulk, but uowExportSource.LoadExportRelations handed ALL
ids to the domain use cases, and the domain/db readers built ONE IN (...)
list per statement: 19,409 placeholders each for labels, wisp_labels,
wisp_comments rows and counts, dependencies counts and wisp_dependencies
counts, at 24-60s a statement (~240s of the run). Dolt is super-linear in
IN-list size, prepared or literal alike: on the same server the labels rows
took 31s as one statement and 0.80s as 98 batches of 200; a 200-id batch
is 3-7ms. The wisp readers were also handed every durable id (rows=0 back).

- internal/storage/domain/db/batching.go: forEachIDBatch at queryBatchSize
  (200, mirroring issueops). commentSQLRepositoryImpl.CountsByIssueIDs /
  ListByIssueIDs, labelSQLRepositoryImpl.ListByIssueIDs,
  dependencySQLRepositoryImpl.ListByIssueIDs / CountsByIssueIDs and
  issueSQLRepositoryImpl.GetByIDs loop over batches and merge; an id lands in
  exactly one batch, so per-id groups and their ORDER BY survive. Error
  strings are byte-identical; empty input still issues no statement. The
  three hand-rolled loops (getLabelsFromTable, getDependencyRecordsFromTable,
  fetchCountsByIDs) collapse onto the helper.
- cmd/bd/export_source.go: LoadExportRelations reads wisps-table membership
  once (WispPlaneIDs, now batched through GetByIDs) and sends only wisp ids
  to GetLabelsForWisps / GetCommentsForWisps / GetWispCommentCounts;
  CountsByWispIDs keeps every id because its inbound leg counts wisp->durable
  edges under the durable target. Membership that could not be read fails
  OPEN to every id (wispReaderIDs), never to "no wisps".
- WispPlaneIDs now tolerates only a missing WISPS table
  (dberrors.IsMissingTable), not any table-not-exist: its read joins leases,
  and the blanket check reported a broken database as an empty wisp plane
  (the issue_search.go missingOptionalWispTable lesson). Behavior change on
  purpose: a rig missing leases now fails bd export with "failed to classify
  wisp-plane rows" instead of silently exporting without markers.

Measured in the same clone against the same shared server, 19,433 rows:
stock 264s / 266s / 287s -> batched 16.9s / 17.8s. Stock-vs-batched byte
oracle: 19,363 of 19,433 records byte-identical; every differing record is
a live lease/heartbeat field or an updated_at inside the seven minutes
between the two runs.

Tests: internal/storage/domain/db TestBulkReadersBatch (a recording Runner
over the real Dolt suite: ceil(N/200) statements per leg, <=200 id
placeholders each, merge across batch boundaries, the Types filter's extra
placeholder, every reader routed to the wisp tables, GetByIDs, empty input),
cmd/bd TestWispPlaneSubset + TestWispReaderIDs, and the proxied export
integration fixture's wisp now carries a label and a comment that the --all
export must emit.

Follow-up (not here): fetchIssuesByIDs (SearchIssues Limit=0),
GetBlockingInfo and loadStatusByID still build one unbounded IN list, and
issue_delete.go's two GetByIDs(wisps) calls keep the blanket
IsTableNotExist.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RDjKMk7ubzrgpEDj2JRAbu

* perf(storage/db): batch fetchIssuesByIDs, GetBlockingInfo and loadStatusByID at 200 ids; delete tolerates only a missing wisps table (wy-sm01o2)

Follow-up to #6267 (wy-237yfi), whose own body names these three readers as
the residual unbounded IN lists in internal/storage/domain/db. Dolt's cost per
IN-list placeholder is super-linear, so one statement over N ids is far slower
than ceil(N/200) statements over 200 each.

- issue_search.go fetchIssuesByIDs: one SELECT per <=200-id batch, merged into
  the same map. `ordered` is the scan order concatenated across batches and
  hydration runs ONCE over the merged slice (hydrateIssues batches its own
  relation reads since #6267), so callers get the same map and the same
  hydration for one round trip per 200 ids instead of one 19k-placeholder
  statement (export's SearchIssues with Limit=0 reaches it with ~19k ids).
  The signature and the missing-wisp-table classification are unchanged.
- dependency.go GetBlockingInfo: both legs batch through forEachIDBatch and
  their blockingRows are appended across batches; the merge that follows is
  untouched. Each leg keys its result by a column the IN list constrains
  (outbound issue_id, inbound the dependency target), and an id lands in
  exactly one batch, so every row sharing a key comes from the same batch.
  loadStatusByID batches its id list per table; the cross-plane duplicate-id
  error is unchanged, because an id is still recorded under `issues` before
  the `wisps` pass reaches it. GetBlockingInfoAcrossIssuesAndWisps needs no
  change: it only calls GetBlockingInfo twice and merges the maps.
- issue_delete.go: previewDelete's and collectConnectedIssues' two
  GetByIDs(UseWispsTable) calls read `FROM wisps LEFT JOIN leases`, so their
  blanket dberrors.IsTableNotExist reported a rig missing `leases` as a rig
  with no wisp plane (previewDelete listed live wisps under NotFound;
  hydrateNeighbors returned them unhydrated). Both now tolerate only
  dberrors.IsMissingTable(err, "wisps"), the fix #6267 applied to
  WispPlaneIDs. The other IsTableNotExist sites in that file are left alone:
  they guard reads whose FROM is the optional table itself
  (wisp_dependencies via ListByIssueIDs(UseWispsTable)).

Tests: internal/storage/domain/db TestBulkReadersBatch gains FetchIssuesByIDs
(ceil(N/200) statements, <=200 placeholders, rows on both sides of a boundary
merged, and exactly ONE label hydration over the merged slice),
GetBlockingInfoOutbound, GetBlockingInfoInbound, LoadStatusByID (both planes,
one statement per batch each) and LoadStatusByIDDuplicateAcrossTables; the
empty-input subtest now covers all three readers issuing no statement.
internal/storage/domain/issue_delete_missing_table_test.go proves a missing
`leases` (or `wisp_labels`) is no longer swallowed at either GetByIDs(wisps)
site while a missing `wisps` table still is, with an unrelated-error control.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(storage/db): consume the aborted duplicate-plane run's statements inside its own subtest (wy-sm01o2)

Salvaged WIP from the quota-killed executor (session-limit at 00:19Z): the
duplicate-plane loadStatusByID call aborts mid-run, so reset the recorder
before it and assert its statements under the cap in place, rather than
leaving them to pollute the next subtest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rrz4umA2L5QU8s9EmCBPw8

* docs(cmd/bd): correct the LoadExportRelations plane-partition doc block

The header still documented pre-PR full-set wisp reads ("both planes are
queried with the FULL ID set and merged"), which this PR made false for the
wisp side. That block is the load-bearing record of the plane-partition
invariant, so a future editor trusting it could "restore" full-set wisp reads
and silently undo the wy-237yfi fix.

- The first bullet now describes the partitioned reads: membership is read
  from the wisps table itself (WispPlaneIDs) rather than inferred from row
  flags, the durable plane is queried with the full id set, the wisp plane
  only with that membership subset (wispReaderIDs), and unreadable membership
  fails OPEN to the full list. The "row flags are NOT a substitute" rationale
  is kept deliberately: it is *why* membership is read from the table at all.
- The IsTableNotExist sentence is extended, not replaced. It is still true of
  the three single-table wisp-relation readers, which correctly keep the
  blanket check; only the lease-joined membership probe (WispPlaneIDs) is
  pinned to a missing `wisps` table. Replacing the sentence outright would
  have introduced a new inaccuracy.

Maintainer review fixup for adopt-pr #6444. Documentation only: the tree is
AST-identical after stripping comments, so no behavior can change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-09-12 02:19:39 -07:00

407 lines
16 KiB
Go

package main
import (
"context"
"errors"
"fmt"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/dberrors"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
)
// exportSource abstracts the storage reads `bd export` performs, so the one
// export body (runExportFromSource) serves both storage stacks:
//
// - storeExportSource reads through the classic `store` global
// (embedded / direct / server modes), preserving the exact pre-seam
// call pattern.
// - uowExportSource reads through a proxied-server unit of work, whose
// domain use cases are plane-pinned (issues vs wisps tables) where the
// classic bulk loaders partition internally — the impl queries both
// planes with the full ID set and merges, so both modes read the same
// rows regardless of which table an issue lives in.
//
// Everything downstream of these reads is shared code; the acceptance bar for
// the seam is byte-identical JSONL output across modes.
type exportSource interface {
// GetInfraTypes returns the resolved infra-type set (config, YAML, or
// hardcoded defaults). A nil/empty result makes the caller fall back to
// domain.DefaultInfraTypes(), mirroring the pre-seam behavior.
GetInfraTypes(ctx context.Context) map[string]bool
// SearchIssues returns the full, untruncated result set for the export
// filter (Limit=0, MaxRows=0). Implementations MUST fail rather than
// return a truncated page — export is a data-integrity path.
SearchIssues(ctx context.Context, query string, filter types.IssueFilter) ([]*types.Issue, error)
// GetConfig reads one config key from the database (used for the
// export.exclude_owners owner-filter keys).
GetConfig(ctx context.Context, key string) (string, error)
// GetAllConfig reads the whole config table (used to extract kv.memory.*
// rows when memories are exported).
GetAllConfig(ctx context.Context) (map[string]string, error)
// LoadExportRelations bulk-loads labels, dependency records, comments,
// comment counts, and dependency counts for the searched issues.
LoadExportRelations(ctx context.Context, issues []*types.Issue) (exportRelations, error)
// WispPlaneIDs reports which of ids currently live in the WISPS table.
// Export uses it to stamp the explicit "wisp_plane" marker on records
// whose row flags are ambiguous: a no_history=true row is either an
// unpromoted no-history wisp (wisps table) or a promoted one (durable
// issues-table row that may still carry the stray flag), and only table
// membership can tell them apart — import routes by the marker, so
// mis-stamping a durable row would re-plane it and drop its relations
// (bd-r9uce). Implementations must classify by table membership, never
// by flags, and both modes must agree (byte-identity oracle).
WispPlaneIDs(ctx context.Context, ids []string) (map[string]bool, error)
}
// storeWispPartitioner is the optional store capability WispPlaneIDs uses in
// classic mode. Both real stores (DoltStore, EmbeddedDoltStore) implement it;
// a store that does not simply gets no plane markers, which degrades to the
// data-safe side (import then routes bare no_history rows to the durable
// plane, where nothing is ever excluded from export).
type storeWispPartitioner interface {
PartitionWispIDs(ctx context.Context, ids []string) (wispIDs, permIDs []string, err error)
}
// exportRelations carries the bulk-loaded relational data for the export set,
// keyed by issue ID.
type exportRelations struct {
labels map[string][]string
deps map[string][]*types.Dependency
comments map[string][]*types.Comment
commentCounts map[string]int
depCounts map[string]*types.DependencyCounts
}
// errExportNoStore reports a classic-source read attempted with no store
// open. Callers of exportSource.GetConfig treat any error as "key unset",
// which reproduces the pre-seam `if store == nil` early return.
var errExportNoStore = errors.New("no store available")
// storeExportSource is the classic-mode exportSource over the `store` global.
type storeExportSource struct{}
func (storeExportSource) GetInfraTypes(ctx context.Context) map[string]bool {
if store == nil {
return nil
}
return store.GetInfraTypes(ctx)
}
func (storeExportSource) SearchIssues(ctx context.Context, query string, filter types.IssueFilter) ([]*types.Issue, error) {
return store.SearchIssues(ctx, query, filter)
}
func (storeExportSource) GetConfig(ctx context.Context, key string) (string, error) {
if store == nil {
return "", errExportNoStore
}
return store.GetConfig(ctx, key)
}
func (storeExportSource) GetAllConfig(ctx context.Context) (map[string]string, error) {
return store.GetAllConfig(ctx)
}
func (storeExportSource) LoadExportRelations(ctx context.Context, issues []*types.Issue) (exportRelations, error) {
issueIDs := make([]string, len(issues))
for i, issue := range issues {
issueIDs[i] = issue.ID
}
// Individual bulk-load failures deliberately degrade to empty maps rather
// than aborting the export — unchanged from the pre-seam classic behavior.
labelsMap, _ := store.GetLabelsForIssues(ctx, issueIDs)
allDeps, _ := store.GetDependencyRecordsForIssues(ctx, issueIDs)
commentsMap, _ := store.GetCommentsForIssues(ctx, issueIDs)
commentCounts, _ := store.GetCommentCounts(ctx, issueIDs)
depCounts, _ := store.GetDependencyCounts(ctx, issueIDs)
return exportRelations{
labels: labelsMap,
deps: allDeps,
comments: commentsMap,
commentCounts: commentCounts,
depCounts: depCounts,
}, nil
}
func (storeExportSource) WispPlaneIDs(ctx context.Context, ids []string) (map[string]bool, error) {
if len(ids) == 0 || store == nil {
return nil, nil
}
// The store global is decorator-wrapped (telemetry, hook firing); walk
// Unwrap() down to the store that carries the partition capability.
s := store
var p storeWispPartitioner
for {
if partitioner, ok := s.(storeWispPartitioner); ok {
p = partitioner
break
}
u, ok := s.(interface{ Unwrap() storage.DoltStorage })
if !ok {
return nil, nil
}
s = u.Unwrap()
if s == nil {
return nil, nil
}
}
wispIDs, _, err := p.PartitionWispIDs(ctx, ids)
if err != nil {
return nil, err
}
set := make(map[string]bool, len(wispIDs))
for _, id := range wispIDs {
set[id] = true
}
return set, nil
}
// uowExportSource is the proxied-server exportSource over a unit of work. All
// reads run inside the single read transaction runExport opened, so the
// export is one consistent snapshot.
type uowExportSource struct {
uw uow.UnitOfWork
}
func (s *uowExportSource) GetInfraTypes(ctx context.Context) map[string]bool {
infra, err := s.uw.ConfigUseCase().GetInfraTypes(ctx)
if err != nil {
// Match the classic source's error-free signature: an unreadable
// config degrades to the caller's DefaultInfraTypes() fallback.
return nil
}
return infra
}
func (s *uowExportSource) SearchIssues(ctx context.Context, query string, filter types.IssueFilter) ([]*types.Issue, error) {
page, err := s.uw.IssueUseCase().SearchIssues(ctx, query, filter)
if err != nil {
return nil, err
}
// Export builds its filter with Limit=0/MaxRows=0, so the whole result
// arrives as one page and HasMore can only be true if a limit creeps back
// in. Guard anyway: an export must fail loudly, never truncate silently
// (domain.SearchPage carries no continuation cursor to loop with).
if page.HasMore {
return nil, fmt.Errorf("issue search returned a truncated page (limit=%d); export must never truncate", filter.Limit)
}
return page.Items, nil
}
func (s *uowExportSource) GetConfig(ctx context.Context, key string) (string, error) {
return s.uw.ConfigUseCase().GetConfig(ctx, key)
}
func (s *uowExportSource) GetAllConfig(ctx context.Context) (map[string]string, error) {
return s.uw.ConfigUseCase().GetAllConfig(ctx)
}
// LoadExportRelations reproduces the classic bulk loaders over the
// plane-pinned domain use cases:
//
// - Labels, comments, and comment counts: the classic loaders partition IDs
// by wisps-table membership (issueops.PartitionWispIDsInTx). Row flags are
// NOT a substitute for that partition — a promoted no-history wisp is a
// durable issues-table row that (as wild data from the pre-bd-r9uce
// promote) still carries NoHistory=true — so membership is read from the
// wisps table itself (WispPlaneIDs), never inferred. The durable plane is
// then queried with the FULL ID set and the wisp plane only with that
// membership subset (wispReaderIDs), and the two are merged. Unreadable
// membership fails OPEN to the full id list, so a nil set is never
// mistaken for "no wisps" (wy-237yfi). The planes are ID-disjoint
// (GH#4455 cross-table guard), so at most one plane returns rows for any
// id and the merge cannot collide.
// - Dependency records: domain GetIssueDependencyRecords already partitions
// internally (same issueops helper), so one call covers both planes.
// - Dependency counts: classic GetDependencyCountsInTx queries BOTH dep
// tables for EVERY id and sums (a wisp blocking a durable issue
// contributes to the durable issue's dependent_count), so both planes are
// queried for the full ID set and summed here too.
//
// Wisp-plane reads tolerate a rig without the wisp tables (IsTableNotExist),
// mirroring the dependency-counts leg. The three wisp-relation readers below
// keep that blanket check: each is a single-table read, so blanket and
// table-specific are the same test there. The membership probe is the
// exception — WispPlaneIDs renders FROM wisps LEFT JOIN leases, so its
// tolerance is pinned to a missing `wisps` table and a broken database
// surfaces as an error instead of an empty wisp plane.
func (s *uowExportSource) LoadExportRelations(ctx context.Context, issues []*types.Issue) (exportRelations, error) {
rel := exportRelations{
labels: map[string][]string{},
deps: map[string][]*types.Dependency{},
comments: map[string][]*types.Comment{},
commentCounts: map[string]int{},
depCounts: map[string]*types.DependencyCounts{},
}
allIDs := make([]string, 0, len(issues))
for _, issue := range issues {
allIDs = append(allIDs, issue.ID)
}
if len(allIDs) == 0 {
return rel, nil
}
// BATCH READS, and the batch is what keeps them here. Export hydrates every
// relation of N issues at once — labels, comments, dependencies, counts,
// both planes — and no role answers "the labels of these N ids": Reader.Get
// is one detail view per call, so a role-routed export would be N round
// trips over a whole workspace. A bulk relation reader is the follow-up
// (ga-2ltro.12). Every LabelUseCase call in this file is one of these.
labels, err := s.uw.LabelUseCase().GetLabelsForIssues(ctx, allIDs) //nolint:forbidigo // bulk relation load; no role answers labels-for-N-ids
if err != nil {
return exportRelations{}, fmt.Errorf("load labels: %w", err)
}
mergeExportMap(rel.labels, labels)
comments, err := s.uw.CommentUseCase().GetCommentsForIssues(ctx, allIDs)
if err != nil {
return exportRelations{}, fmt.Errorf("load comments: %w", err)
}
mergeExportMap(rel.comments, comments)
counts, err := s.uw.CommentUseCase().GetCommentCounts(ctx, allIDs)
if err != nil {
return exportRelations{}, fmt.Errorf("load comment counts: %w", err)
}
mergeExportMap(rel.commentCounts, counts)
// The wisp_labels / wisp_comments rows of a wisp are keyed by an issue_id
// that lives in the WISPS table (promotion moves them to the durable
// tables, issueops.PromoteFromEphemeralInTx), so the three wisp readers
// below only need the ids that are wisps right now. Handing them the
// whole workspace was pure waste — on a 19k-issue rig with no wisps it
// was three 19k-placeholder statements answering nothing (wy-237yfi).
// CountsByWispIDs is NOT narrowed: its inbound leg counts wisp -> durable
// edges under the durable target's id.
// A nil set means membership could NOT be read (the wisps table is
// absent, the tolerated case) — never "no wisps": fail open to the full
// id list so the readers below keep their own table-not-exist tolerance.
wispSet, err := s.WispPlaneIDs(ctx, allIDs)
if err != nil {
return exportRelations{}, err
}
wispIDs := wispReaderIDs(allIDs, wispSet)
wispLabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, wispIDs) //nolint:forbidigo // bulk relation load; see GetLabelsForIssues above
if err != nil {
if !dberrors.IsTableNotExist(err) {
return exportRelations{}, fmt.Errorf("load wisp labels: %w", err)
}
} else {
mergeExportMap(rel.labels, wispLabels)
}
wispComments, err := s.uw.CommentUseCase().GetCommentsForWisps(ctx, wispIDs)
if err != nil {
if !dberrors.IsTableNotExist(err) {
return exportRelations{}, fmt.Errorf("load wisp comments: %w", err)
}
} else {
mergeExportMap(rel.comments, wispComments)
}
wispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, wispIDs)
if err != nil {
if !dberrors.IsTableNotExist(err) {
return exportRelations{}, fmt.Errorf("load wisp comment counts: %w", err)
}
} else {
mergeExportMap(rel.commentCounts, wispCounts)
}
deps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)
if err != nil {
return exportRelations{}, fmt.Errorf("load dependency records: %w", err)
}
rel.deps = deps
depCounts, err := s.uw.DependencyUseCase().CountsByIssueIDs(ctx, allIDs)
if err != nil {
return exportRelations{}, fmt.Errorf("load dependency counts: %w", err)
}
rel.depCounts = depCounts
wispDepCounts, err := s.uw.DependencyUseCase().CountsByWispIDs(ctx, allIDs)
if err != nil {
// A rig without the wisp tables simply has no wisp-plane edges.
if !dberrors.IsTableNotExist(err) {
return exportRelations{}, fmt.Errorf("load wisp dependency counts: %w", err)
}
} else {
for id, wc := range wispDepCounts {
if wc == nil || (wc.DependencyCount == 0 && wc.DependentCount == 0) {
continue
}
c := rel.depCounts[id]
if c == nil {
c = &types.DependencyCounts{}
rel.depCounts[id] = c
}
c.DependencyCount += wc.DependencyCount
c.DependentCount += wc.DependentCount
}
}
return rel, nil
}
// wispPlaneSubset returns, in input order, the ids that wispSet marks as
// wisp-plane; none marked yields nil, and the bulk readers answer nil with no
// statement at all. The caller decides what a nil SET means (see
// LoadExportRelations: unreadable membership fails open, never empty).
func wispPlaneSubset(ids []string, wispSet map[string]bool) []string {
var out []string
for _, id := range ids {
if wispSet[id] {
out = append(out, id)
}
}
return out
}
// wispReaderIDs is the caller-side policy wispPlaneSubset defers: a nil set
// means membership was UNREADABLE (WispPlaneIDs tolerated a missing wisps
// table), so every id goes to the wisp readers and they keep their own
// table-not-exist tolerance; a non-nil set — even an empty one — is the
// answer, and only the ids in it go.
func wispReaderIDs(ids []string, wispSet map[string]bool) []string {
if wispSet == nil {
return ids
}
return wispPlaneSubset(ids, wispSet)
}
// WispPlaneIDs classifies by wisps-table membership through the plane-pinned
// GetWispsByIDs read (row flags are NOT a substitute — see the exportSource
// interface comment). A rig without the wisps table has no wisp-plane rows
// (nil set), mirroring the tolerance of the wisp-plane legs in
// LoadExportRelations. Only the WISPS table is optional: the read joins
// leases, and a blanket table-not-exist check would report a broken
// database as an empty wisp plane (the issue_search.go missingOptionalWispTable
// lesson), so the tolerance is pinned to that one table name.
func (s *uowExportSource) WispPlaneIDs(ctx context.Context, ids []string) (map[string]bool, error) {
if len(ids) == 0 {
return nil, nil
}
wisps, err := s.uw.IssueUseCase().GetWispsByIDs(ctx, ids)
if err != nil {
if dberrors.IsMissingTable(err, "wisps") {
return nil, nil
}
return nil, fmt.Errorf("wisp plane membership: %w", err)
}
set := make(map[string]bool, len(wisps))
for _, w := range wisps {
set[w.ID] = true
}
return set, nil
}
// mergeExportMap copies src entries into dst. The label/comment planes are
// disjoint by ID (an issue lives in exactly one of issues/wisps), so a plain
// overwrite-merge reassembles the classic partitioned loaders' single map.
func mergeExportMap[V any](dst, src map[string]V) {
for k, v := range src {
dst[k] = v
}
}