@ref0/git 0.20.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +30 -18
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +13 -12
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +145 -98
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +114 -58
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +24 -18
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
|
@@ -2,15 +2,16 @@ import { fail } from "../contracts/result.mjs";
|
|
|
2
2
|
import { streamOf } from "../protocol/bytes/streams.mjs";
|
|
3
3
|
import { emptyTree, objectId, objectTypes } from "../protocol/objects/object.mjs";
|
|
4
4
|
import { decodeRow } from "../store/errors.mjs";
|
|
5
|
+
import { RequestSnapshot } from "../store/request-snapshot.mjs";
|
|
5
6
|
import { repoScope } from "../store/scopes.mjs";
|
|
6
|
-
import { SizeMarker, batchesOf, batchesRead, isBatchId, stagedKey, stagedOid, stagedPrefix,
|
|
7
|
-
import { ChunkReader, chunkedOf } from "./chunks.mjs";
|
|
7
|
+
import { SizeMarker, batchesOf, batchesRead, isBatchId, stagedKey, stagedOid, stagedPrefix, stagedSizeKey } from "./batches.mjs";
|
|
8
|
+
import { ChunkReader, chunkCount, chunkedOf } from "./chunks.mjs";
|
|
8
9
|
import { objectCollections } from "./layout.mjs";
|
|
10
|
+
import { limits } from "@ref0/infra";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
9
12
|
import * as Effect from "effect/Effect";
|
|
10
13
|
import * as Option from "effect/Option";
|
|
11
|
-
import * as Schema from "effect/Schema";
|
|
12
14
|
import * as Result from "effect/Result";
|
|
13
|
-
import { limits } from "@ref0/infra";
|
|
14
15
|
import * as Base64 from "effect/encoding/Base64";
|
|
15
16
|
// src/storage/object-rows.ts
|
|
16
17
|
/** One object as a row, by its ID: its type and its body as base64, the header left out. */
|
|
@@ -97,6 +98,22 @@ const headerOfRow = /* @__PURE__ */ Effect.fnUntraced(function* (row) {
|
|
|
97
98
|
size: data.length / 4 * 3 - padding
|
|
98
99
|
};
|
|
99
100
|
});
|
|
101
|
+
/**
|
|
102
|
+
* A stored object row's inflated body bytes from its base64 length or chunked manifest, without
|
|
103
|
+
* decoding or allocating the body. Returns 0 for an unreadable row.
|
|
104
|
+
*/
|
|
105
|
+
const rowInflatedBytes = (row) => {
|
|
106
|
+
const chunked = chunkedOf(row.value);
|
|
107
|
+
if (chunked !== void 0) return chunked.size;
|
|
108
|
+
const stored = decodeObjectRow(row.value);
|
|
109
|
+
if (Option.isNone(stored)) return 0;
|
|
110
|
+
const { data } = stored.value;
|
|
111
|
+
if (data.length === 0 || data.length % 4 !== 0) return 0;
|
|
112
|
+
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
113
|
+
return data.length / 4 * 3 - padding;
|
|
114
|
+
};
|
|
115
|
+
/** Total inflated body bytes of `rows`, as `rowInflatedBytes` counts each. */
|
|
116
|
+
const rowsInflatedBytes = (rows) => rows.reduce((sum, row) => sum + rowInflatedBytes(row), 0);
|
|
100
117
|
/** A whole object as the contract's, its bytes one piece of a stream. */
|
|
101
118
|
const gitObjectOf = (object) => ({
|
|
102
119
|
oid: object.oid,
|
|
@@ -105,11 +122,10 @@ const gitObjectOf = (object) => ({
|
|
|
105
122
|
bytes: streamOf(object.bytes.slice())
|
|
106
123
|
});
|
|
107
124
|
/**
|
|
108
|
-
* The object rows a receive's change puts, by ID, readable before the commit that writes
|
|
109
|
-
*
|
|
110
|
-
* carries.
|
|
125
|
+
* The inline object rows a receive's change puts, by ID, readable before the commit that writes
|
|
126
|
+
* them; staged receives expose their pre-commit rows through `stagedOwnOf`.
|
|
111
127
|
*/
|
|
112
|
-
const receivedRows = (change) =>
|
|
128
|
+
const receivedRows = (change) => new Map((change?.put ?? []).flatMap((row) => row.collection === objectCollections.objects ? [[row.id, row]] : []));
|
|
113
129
|
/**
|
|
114
130
|
* How a staged push's own chunked rows are read before its commit, by the change it answered:
|
|
115
131
|
* its batch isn't published, so no reader of the repo finds them.
|
|
@@ -124,6 +140,13 @@ const receivedObject = (change, row) => {
|
|
|
124
140
|
return chunked === void 0 || reader === void 0 ? objectOfRow(row) : reader(row.id, chunked).whole();
|
|
125
141
|
};
|
|
126
142
|
/**
|
|
143
|
+
* Object rows one `wholePlan` clone page asks for: matches `wholeRowsMost` (1,000) so a rows-only
|
|
144
|
+
* whole clone reads its remaining rows past the preloaded first page in one store read instead of
|
|
145
|
+
* paging `rowReadBatch` (100) at a time. Past one answer's 16 MiB (`limits.answerBytes`),
|
|
146
|
+
* `eachPageAt` falls back to `rowReadBatch` and then `largeBatch`.
|
|
147
|
+
*/
|
|
148
|
+
const wholePageRows = 1e3;
|
|
149
|
+
/**
|
|
127
150
|
* Object rows a store read refused as too large is cut into: as many of the largest as one answer
|
|
128
151
|
* holds, each row's key and version aside, so no read of them passes its 16 MiB.
|
|
129
152
|
*/
|
|
@@ -168,6 +191,18 @@ const asObjectRow = (row) => ({
|
|
|
168
191
|
value: row.value
|
|
169
192
|
});
|
|
170
193
|
/**
|
|
194
|
+
* Reads already-flushed rows from `stagedObjects` or `stagedDeltas` in key order, normalizing
|
|
195
|
+
* `stagedObjects/<batch>/<oid>` through `asObjectRow` so callers decode object rows with bare OIDs.
|
|
196
|
+
*/
|
|
197
|
+
const readStagedRows = (store, repo) => (keys) => keys.length === 0 ? Effect.succeed([]) : Effect.map(store.read({
|
|
198
|
+
scope: repoScope(repo),
|
|
199
|
+
reads: [...keys]
|
|
200
|
+
}), (snapshot) => keys.map((key, index) => {
|
|
201
|
+
const row = snapshot.results[index]?.[0];
|
|
202
|
+
if (row === void 0) return void 0;
|
|
203
|
+
return key.collection === objectCollections.stagedObjects ? asObjectRow(row) : row;
|
|
204
|
+
}));
|
|
205
|
+
/**
|
|
171
206
|
* The value bytes packed into one staged body read at most (#2521): each row is at most 1 MiB, so
|
|
172
207
|
* every closed read holds > 13 MiB of values and stays under 16 MiB with its keys and envelope.
|
|
173
208
|
*/
|
|
@@ -361,37 +396,70 @@ const heldIdsAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, vers
|
|
|
361
396
|
}));
|
|
362
397
|
return moved ? void 0 : held;
|
|
363
398
|
});
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
* answer's 16 MiB. `true` once every row is read; `false` once a page answers at another version,
|
|
368
|
-
* since the repo moved after the read it joins, once `each` answers `false`, or once a page lists a
|
|
369
|
-
* published staged batch, whose rows `objects` doesn't hold yet: a whole-repo pass waits for
|
|
370
|
-
* upkeep to promote them, and a clone builds through the readers that read batches.
|
|
371
|
-
*/
|
|
372
|
-
const eachPageAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, version, each) {
|
|
373
|
-
const page = (after, limit) => {
|
|
399
|
+
const eachPageAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, version, each, also, pageSize = 100) {
|
|
400
|
+
const scope = repoScope(repo);
|
|
401
|
+
const page = (after, limit, withAlso) => {
|
|
374
402
|
const read = {
|
|
375
403
|
collection: objectCollections.objects,
|
|
376
404
|
limit
|
|
377
405
|
};
|
|
378
406
|
if (after !== void 0) read.after = after;
|
|
407
|
+
const reads = withAlso && also !== void 0 ? [
|
|
408
|
+
read,
|
|
409
|
+
batchesRead,
|
|
410
|
+
...also.reads
|
|
411
|
+
] : [read, batchesRead];
|
|
379
412
|
return Effect.map(store.read({
|
|
380
|
-
scope
|
|
381
|
-
reads
|
|
413
|
+
scope,
|
|
414
|
+
reads
|
|
382
415
|
}), ({ version: at, results }) => ({
|
|
383
416
|
at,
|
|
384
417
|
rows: results[0] ?? [],
|
|
385
418
|
limit,
|
|
386
|
-
batched: (results[1] ?? []).length > 0
|
|
419
|
+
batched: (results[1] ?? []).length > 0,
|
|
420
|
+
extra: withAlso && also !== void 0 ? results.slice(2) : void 0
|
|
387
421
|
}));
|
|
388
422
|
};
|
|
389
423
|
let after;
|
|
424
|
+
let needAlso = also !== void 0 && also.reads.length > 0;
|
|
425
|
+
const snapshot = yield* RequestSnapshot;
|
|
426
|
+
if (snapshot !== void 0) {
|
|
427
|
+
const preloadReads = needAlso && also !== void 0 ? [
|
|
428
|
+
{
|
|
429
|
+
collection: objectCollections.objects,
|
|
430
|
+
limit: 100
|
|
431
|
+
},
|
|
432
|
+
batchesRead,
|
|
433
|
+
...also.reads
|
|
434
|
+
] : [{
|
|
435
|
+
collection: objectCollections.objects,
|
|
436
|
+
limit: 100
|
|
437
|
+
}, batchesRead];
|
|
438
|
+
const preloaded = snapshot.answer(scope, preloadReads);
|
|
439
|
+
if (preloaded !== void 0 && preloaded.version === version) {
|
|
440
|
+
if ((preloaded.results[1] ?? []).length > 0) return "batched";
|
|
441
|
+
const rows = preloaded.results[0] ?? [];
|
|
442
|
+
if (!(yield* each(rows))) return "moved";
|
|
443
|
+
if (needAlso && also !== void 0) {
|
|
444
|
+
also.take(preloaded.results.slice(2));
|
|
445
|
+
needAlso = false;
|
|
446
|
+
}
|
|
447
|
+
const last = rows.at(-1);
|
|
448
|
+
if (last === void 0 || rows.length < 100) return "done";
|
|
449
|
+
after = last.id;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
390
452
|
for (;;) {
|
|
391
|
-
const
|
|
392
|
-
|
|
453
|
+
const first = needAlso;
|
|
454
|
+
const { at, rows, limit, batched, extra } = yield* page(after, pageSize, first).pipe(Effect.catchIf(tooLargeRead, () => pageSize > 100 ? page(after, 100, first).pipe(Effect.catchIf(tooLargeRead, () => page(after, largeBatch, first))) : page(after, largeBatch, first)));
|
|
455
|
+
if (batched) return "batched";
|
|
456
|
+
if (at !== version || !(yield* each(rows))) return "moved";
|
|
457
|
+
if (first && extra !== void 0 && also !== void 0) {
|
|
458
|
+
also.take(extra);
|
|
459
|
+
needAlso = false;
|
|
460
|
+
}
|
|
393
461
|
const last = rows.at(-1);
|
|
394
|
-
if (last === void 0 || rows.length < limit) return
|
|
462
|
+
if (last === void 0 || rows.length < limit) return "done";
|
|
395
463
|
after = last.id;
|
|
396
464
|
}
|
|
397
465
|
});
|
|
@@ -486,14 +554,68 @@ const chunkedAgain = (store, listed) => Effect.fnUntraced(function* (oid) {
|
|
|
486
554
|
/** A reader of `oid`'s chunks, the repo's row naming them `chunked`. */
|
|
487
555
|
const chunkReaderOf = (store, listed, oid, chunked) => new ChunkReader(store, listed.repo, oid, chunked, chunkedAgain(store, listed));
|
|
488
556
|
/**
|
|
557
|
+
* One object's row, `emptyTree` included: an inline row decoded and hashed whole, or a chunked
|
|
558
|
+
* row's `ChunkReader` with no chunks read yet, validated against its size and chunk count (#2522).
|
|
559
|
+
*/
|
|
560
|
+
const rowAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, oid) {
|
|
561
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") return {
|
|
562
|
+
kind: "whole",
|
|
563
|
+
object: emptyTreeObject
|
|
564
|
+
};
|
|
565
|
+
let found;
|
|
566
|
+
yield* eachRow(store, listed, [oid], Effect.fnUntraced(function* (row) {
|
|
567
|
+
const chunked = chunkedOf(row.value);
|
|
568
|
+
if (chunked === void 0) {
|
|
569
|
+
found = {
|
|
570
|
+
kind: "whole",
|
|
571
|
+
object: yield* objectOfRow(row)
|
|
572
|
+
};
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (chunked.size < 1 || chunked.chunks !== chunkCount(chunked.size)) return yield* fail("DATA_LOSS", `Object ${row.id}'s chunked row has invalid size or chunk count`);
|
|
576
|
+
found = {
|
|
577
|
+
kind: "chunked",
|
|
578
|
+
reader: chunkReaderOf(store, listed, row.id, chunked)
|
|
579
|
+
};
|
|
580
|
+
}));
|
|
581
|
+
return found;
|
|
582
|
+
});
|
|
583
|
+
/**
|
|
489
584
|
* A repo's object rows `oids` names, each handed on as it's read: the empty tree among them. One
|
|
490
|
-
* kept as chunks is read whole, `chunkReadMost` chunks a read, once `before` lets it.
|
|
585
|
+
* kept as chunks is read whole, `chunkReadMost` chunks a read, once `before` lets it. When `cache`
|
|
586
|
+
* is provided for a fetch request, inline rows already cached are served (and verified on first
|
|
587
|
+
* decode from raw) without re-reading the store, and newly read inline rows are stored within the
|
|
588
|
+
* cache's bounds (#2899).
|
|
491
589
|
*/
|
|
492
|
-
const eachHeldRow = (store, listed, before) => Effect.fnUntraced(function* (oids, each) {
|
|
493
|
-
|
|
494
|
-
|
|
590
|
+
const eachHeldRow = (store, listed, before, cache) => Effect.fnUntraced(function* (oids, each) {
|
|
591
|
+
const unique = [...new Set(oids)];
|
|
592
|
+
const missed = [];
|
|
593
|
+
for (const oid of unique) {
|
|
594
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") {
|
|
595
|
+
yield* each(emptyTreeObject);
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
const cached = cache?.get(oid);
|
|
599
|
+
if (cached === void 0) {
|
|
600
|
+
missed.push(oid);
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (cached.kind === "whole") {
|
|
604
|
+
yield* each(cached.object);
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
const object = yield* objectOfRow(cached.row);
|
|
608
|
+
cache?.putWhole(object);
|
|
609
|
+
yield* each(object);
|
|
610
|
+
}
|
|
611
|
+
if (missed.length === 0) return;
|
|
612
|
+
yield* eachRow(store, listed, missed, Effect.fnUntraced(function* (row) {
|
|
495
613
|
const chunked = chunkedOf(row.value);
|
|
496
|
-
if (chunked === void 0)
|
|
614
|
+
if (chunked === void 0) {
|
|
615
|
+
const object = yield* objectOfRow(row);
|
|
616
|
+
cache?.putWhole(object);
|
|
617
|
+
return yield* each(object);
|
|
618
|
+
}
|
|
497
619
|
if (before !== void 0 && !(yield* before(row.id, chunked.size))) return;
|
|
498
620
|
yield* each(yield* chunkReaderOf(store, listed, row.id, chunked).whole());
|
|
499
621
|
}));
|
|
@@ -507,19 +629,38 @@ const heldRows = (store, listed) => Effect.fnUntraced(function* (oids) {
|
|
|
507
629
|
/**
|
|
508
630
|
* The type and size of each of `oids`' rows the repo holds, the empty tree's among them, the size
|
|
509
631
|
* from each row's base64: no body decoded or hashed, though each row is read whole, as the store
|
|
510
|
-
* has no part read.
|
|
632
|
+
* has no part read. When `cache` is provided, cached headers are returned without a store read and
|
|
633
|
+
* newly read inline rows are stored raw within the cache's bounds (#2899).
|
|
511
634
|
*/
|
|
512
|
-
const rowHeaders = (store, listed) => Effect.fnUntraced(function* (oids) {
|
|
635
|
+
const rowHeaders = (store, listed, onRow, cache) => Effect.fnUntraced(function* (oids) {
|
|
513
636
|
const headers = /* @__PURE__ */ new Map();
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
637
|
+
const missed = [];
|
|
638
|
+
for (const oid of new Set(oids)) {
|
|
639
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") {
|
|
640
|
+
headers.set(emptyTree, {
|
|
641
|
+
type: "tree",
|
|
642
|
+
size: 0
|
|
643
|
+
});
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const cached = cache?.headerOf(oid);
|
|
647
|
+
if (cached !== void 0) {
|
|
648
|
+
headers.set(oid, cached);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
missed.push(oid);
|
|
652
|
+
}
|
|
653
|
+
if (missed.length === 0) return headers;
|
|
654
|
+
yield* eachRow(store, listed, missed, Effect.fnUntraced(function* (row) {
|
|
655
|
+
const header = yield* headerOfRow(row);
|
|
656
|
+
if (cache !== void 0 && chunkedOf(row.value) === void 0) cache.putRaw(row, header);
|
|
657
|
+
headers.set(row.id, header);
|
|
658
|
+
onRow?.(row, header);
|
|
659
|
+
}));
|
|
519
660
|
return headers;
|
|
520
661
|
});
|
|
521
662
|
/** The size of each of `oids`' rows the repo holds, as `rowHeaders` reads it. */
|
|
522
|
-
const rowSizes = (store, listed) => (oids) => Effect.map(rowHeaders(store, listed)(oids), (headers) => new Map([...headers].map(([oid, { size }]) => [oid, size])));
|
|
663
|
+
const rowSizes = (store, listed, cache) => (oids) => Effect.map(rowHeaders(store, listed, void 0, cache)(oids), (headers) => new Map([...headers].map(([oid, { size }]) => [oid, size])));
|
|
523
664
|
/**
|
|
524
665
|
* The IDs of `repo`'s object rows that start with `prefix`, at most `count` from each place it
|
|
525
666
|
* reads, lowest first, deduplicated, and the version they're read at: `objects` and every published
|
|
@@ -628,4 +769,4 @@ const startingOf = (found, most) => {
|
|
|
628
769
|
more: all.length > most
|
|
629
770
|
};
|
|
630
771
|
};
|
|
631
|
-
export { ObjectRow, bodyPackBytes, copyRowsPage, eachHeldRow, eachPageAt, emptyTreeObject, gitObjectOf, headerOfRow, heldIdsAt, heldRows, largeBatch, noRows, objectKey, objectOfRow, objectRow, readsOwnChunks, receivedObject, receivedRows, rowHeaders, rowSizes, rowValueBytes, rowsMoved, rowsStartingWith, startingOf, tooLargeRead };
|
|
772
|
+
export { ObjectRow, bodyPackBytes, copyRowsPage, eachHeldRow, eachPageAt, emptyTreeObject, gitObjectOf, headerOfRow, heldIdsAt, heldRows, largeBatch, noRows, objectKey, objectOfRow, objectRow, readStagedRows, readsOwnChunks, receivedObject, receivedRows, rowAt, rowHeaders, rowInflatedBytes, rowSizes, rowValueBytes, rowsInflatedBytes, rowsMoved, rowsStartingWith, startingOf, tooLargeRead, wholePageRows };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
3
3
|
import { DeltaError } from "../protocol/packs/delta.mjs";
|
|
4
|
-
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
4
|
+
import { oidBytes, writeOidBytes } from "../protocol/packs/idx.mjs";
|
|
5
5
|
import { PackIndexer } from "../protocol/packs/indexer.mjs";
|
|
6
6
|
import { PackError, PackTransportError, boundedSource, readEntryHeader, readPackFrom } from "../protocol/packs/reader.mjs";
|
|
7
7
|
import { stepEffect } from "../protocol/packs/step.mjs";
|
|
@@ -12,7 +12,7 @@ import { typeCodes } from "./index-files.mjs";
|
|
|
12
12
|
import { packFiles } from "./layout.mjs";
|
|
13
13
|
import { headerLimits, packIndexerLimits } from "./pack-reads.mjs";
|
|
14
14
|
import { locateAll, locateAllBytes, rangeRanks, readExactly } from "./pack-ranges.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { compareIdsFrom, idsBytes, orderByIdWithFanout } from "./raw-ids.mjs";
|
|
16
16
|
import * as Effect from "effect/Effect";
|
|
17
17
|
import * as Result from "effect/Result";
|
|
18
18
|
// src/storage/pack-order.ts
|
|
@@ -139,9 +139,9 @@ var SliceLinks = class SliceLinks {
|
|
|
139
139
|
}
|
|
140
140
|
/** One link of the object begun last: the 20 bytes of `bytes` from `at`. */
|
|
141
141
|
add = (bytes, at) => {
|
|
142
|
-
if (!this.#fit(this.sources, this.size + 1)) return;
|
|
143
|
-
const ids = this.#ids;
|
|
144
142
|
const to = this.size * 20;
|
|
143
|
+
if (this.#refused || to + 20 > this.#ids.length && !this.#fit(this.sources, this.size + 1)) return;
|
|
144
|
+
const ids = this.#ids;
|
|
145
145
|
for (let each = 0; each < 20; each += 1) ids[to + each] = bytes[at + each] ?? 0;
|
|
146
146
|
this.size += 1;
|
|
147
147
|
this.#starts[this.sources] = this.size;
|
|
@@ -191,6 +191,14 @@ var SliceLinks = class SliceLinks {
|
|
|
191
191
|
linksOf(at) {
|
|
192
192
|
return [this.#starts[at] ?? 0, this.#starts[at + 1] ?? 0];
|
|
193
193
|
}
|
|
194
|
+
/** Where the `at`th object's links start in `ids`. */
|
|
195
|
+
linkStart(at) {
|
|
196
|
+
return this.#starts[at] ?? 0;
|
|
197
|
+
}
|
|
198
|
+
/** Where the `at`th object's links end in `ids` (exclusive). */
|
|
199
|
+
linkEnd(at) {
|
|
200
|
+
return this.#starts[at + 1] ?? 0;
|
|
201
|
+
}
|
|
194
202
|
/** Whether the `at`th object's `link`th link may name an object the repo lacks. */
|
|
195
203
|
mayLack(at, link) {
|
|
196
204
|
return mayLack(this.#kinds[at] ?? 0, link);
|
|
@@ -295,11 +303,14 @@ const sliceEntries = /* @__PURE__ */ Effect.fnUntraced(function* (ranges, at, by
|
|
|
295
303
|
const places = new Uint32Array(length);
|
|
296
304
|
for (let each = 0; each < length; each += 1) places[each] = placeOf(sorted, offsets[each] ?? 0);
|
|
297
305
|
const ids = yield* idsOf(ranges, ranks.subarray(0, length), places);
|
|
306
|
+
const end = Number.isFinite(next) ? next : ranges.pack.bytes - 20;
|
|
307
|
+
const ordered = orderByIdWithFanout(ids, length);
|
|
298
308
|
return {
|
|
299
309
|
offsets: sorted,
|
|
300
|
-
end
|
|
310
|
+
end,
|
|
301
311
|
ids,
|
|
302
|
-
byId:
|
|
312
|
+
byId: ordered.order,
|
|
313
|
+
fanout: ordered.fanout,
|
|
303
314
|
held: capacity * 104
|
|
304
315
|
};
|
|
305
316
|
});
|
|
@@ -333,14 +344,19 @@ const idsOf = /* @__PURE__ */ Effect.fnUntraced(function* (ranges, ranks, places
|
|
|
333
344
|
}
|
|
334
345
|
return ids;
|
|
335
346
|
});
|
|
336
|
-
/** The entry of the slice whose ID is `id`'s 20 bytes, by
|
|
347
|
+
/** The entry of the slice whose ID is `id`'s 20 bytes, narrowed by its 12-bit prefix fanout, or -1. */
|
|
337
348
|
const entryById = (entries, id) => {
|
|
338
|
-
|
|
339
|
-
|
|
349
|
+
const b0 = id[0] ?? 0;
|
|
350
|
+
const b1 = id[1] ?? 0;
|
|
351
|
+
const bucket = b0 << 4 | b1 >>> 4;
|
|
352
|
+
let low = entries.fanout[bucket] ?? 0;
|
|
353
|
+
let high = entries.fanout[bucket + 1] ?? entries.byId.length;
|
|
340
354
|
while (low < high) {
|
|
341
355
|
const middle = low + high >>> 1;
|
|
342
356
|
const each = entries.byId[middle] ?? 0;
|
|
343
|
-
const
|
|
357
|
+
const off = each * 20;
|
|
358
|
+
const diff1 = (entries.ids[off + 1] ?? 0) - b1;
|
|
359
|
+
const compared = diff1 !== 0 ? diff1 : compareIdsFrom(entries.ids, off, id, 0, 2);
|
|
344
360
|
if (compared === 0) return each;
|
|
345
361
|
if (compared < 0) low = middle + 1;
|
|
346
362
|
else high = middle;
|
|
@@ -568,18 +584,26 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
568
584
|
asked = bytes;
|
|
569
585
|
return allot(held + asked);
|
|
570
586
|
};
|
|
571
|
-
const
|
|
587
|
+
const holdingMoreStep = (bytes) => {
|
|
572
588
|
held += bytes;
|
|
573
|
-
return
|
|
589
|
+
return holding(asked);
|
|
574
590
|
};
|
|
591
|
+
const holdingMore = (bytes) => stepEffect(holdingMoreStep(bytes));
|
|
575
592
|
const known = new Uint8Array(entries.offsets.length).fill(unknown);
|
|
576
593
|
const last = entries.offsets.length - 1;
|
|
577
|
-
const
|
|
594
|
+
const lookupId = /* @__PURE__ */ new Uint8Array(20);
|
|
595
|
+
const withinOf = (oid) => {
|
|
596
|
+
writeOidBytes(oid, lookupId, 0);
|
|
597
|
+
return entryById(entries, lookupId);
|
|
598
|
+
};
|
|
578
599
|
const outside = outsideBases(bucket, ranges, withinOf, holdingMore, {
|
|
579
600
|
before: at.position,
|
|
580
601
|
types: input.storedTypes
|
|
581
602
|
});
|
|
603
|
+
let cachedBaseOid;
|
|
604
|
+
let cachedBaseOffset = 0;
|
|
582
605
|
const offsetOf = (oid) => {
|
|
606
|
+
if (oid === cachedBaseOid) return cachedBaseOffset;
|
|
583
607
|
const within = withinOf(oid);
|
|
584
608
|
return within >= 0 ? entries.offsets[within] ?? 0 : outside.offsetOf(oid);
|
|
585
609
|
};
|
|
@@ -598,18 +622,22 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
598
622
|
};
|
|
599
623
|
let read = 0;
|
|
600
624
|
let skipped = 0;
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
const resolved = yield* stepEffect(indexer.settle()).pipe(Effect.mapError((error) => error instanceof DeltaError ? lost(`Pack ${pack.id}'s delta at ${entry.offset} won't apply: ${error.message}`) : error));
|
|
604
|
-
if (resolved.kind === "unindexable") return yield* Effect.fail(lost(`Pack ${pack.id}'s entry at ${entry.offset} won't resolve: ${resolved.why}`));
|
|
625
|
+
const finishSettled = (entry, within, target, resolved) => {
|
|
626
|
+
if (resolved.kind === "unindexable") return Effect.fail(lost(`Pack ${pack.id}'s entry at ${entry.offset} won't resolve: ${resolved.why}`));
|
|
605
627
|
const { kind, bytes } = resolved.object;
|
|
606
628
|
known[within] = typeCodes[kind];
|
|
607
|
-
if (kind === "blob") return;
|
|
629
|
+
if (kind === "blob") return void 0;
|
|
608
630
|
target.begin(ranges.base + entry.index, kind);
|
|
609
631
|
const malformed = rawLinks(kind, bytes, target.add);
|
|
610
|
-
if (malformed !== void 0) return
|
|
611
|
-
if (target.refused) return
|
|
612
|
-
}
|
|
632
|
+
if (malformed !== void 0) return Effect.fail(lost(`Pack ${pack.id}'s ${kind} at ${entry.offset} is malformed: ${malformed}`));
|
|
633
|
+
if (target.refused) return Effect.fail(linksPastMemory());
|
|
634
|
+
};
|
|
635
|
+
const settled = (entry, within, target) => {
|
|
636
|
+
read += 1;
|
|
637
|
+
const resolved = indexer.settle();
|
|
638
|
+
if (!Effect.isEffect(resolved)) return finishSettled(entry, within, target, resolved);
|
|
639
|
+
return Effect.flatMap(Effect.mapError(resolved, (error) => error instanceof DeltaError ? lost(`Pack ${pack.id}'s delta at ${entry.offset} won't apply: ${error.message}`) : error), (done) => finishSettled(entry, within, target, done) ?? Effect.void);
|
|
640
|
+
};
|
|
613
641
|
let current = 0;
|
|
614
642
|
let spentMost;
|
|
615
643
|
let skip = false;
|
|
@@ -622,8 +650,13 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
622
650
|
if (entry.base?.kind !== "oid") return Effect.fail(lost(`Pack ${pack.id}'s entry at ${entry.offset} is an offset delta, which no stored pack holds`));
|
|
623
651
|
const oid = entry.base.oid;
|
|
624
652
|
const within = withinOf(oid);
|
|
625
|
-
if (within < 0 || within < current && known[within] === unknown) return {
|
|
653
|
+
if (within < 0 || within < current && known[within] === unknown) return {
|
|
654
|
+
base: oid,
|
|
655
|
+
inSlice: within
|
|
656
|
+
};
|
|
626
657
|
baseAt(entry.index, at.position + within);
|
|
658
|
+
cachedBaseOid = oid;
|
|
659
|
+
cachedBaseOffset = entries.offsets[within] ?? 0;
|
|
627
660
|
return { type: within < current ? known[within] ?? unknown : unknown };
|
|
628
661
|
};
|
|
629
662
|
const sink = {
|
|
@@ -640,12 +673,14 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
640
673
|
deferring = {
|
|
641
674
|
entry,
|
|
642
675
|
oid: typed.base,
|
|
676
|
+
inSlice: typed.inSlice,
|
|
643
677
|
within: current,
|
|
644
678
|
pieces: keeps ? [] : void 0
|
|
645
679
|
};
|
|
646
680
|
const bytes = deferredEntryBytes + (keeps ? entry.size : 0);
|
|
647
681
|
deferredBytes += bytes;
|
|
648
|
-
|
|
682
|
+
const step = holdingMoreStep(bytes);
|
|
683
|
+
return Effect.isEffect(step) ? step : void 0;
|
|
649
684
|
}
|
|
650
685
|
skip = typed.type === typeCodes.blob;
|
|
651
686
|
if (skip) return void 0;
|
|
@@ -662,13 +697,21 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
662
697
|
if (deferring === void 0) indexer.data(bytes);
|
|
663
698
|
else deferring.pieces?.push(bytes.slice());
|
|
664
699
|
},
|
|
665
|
-
entryEnd:
|
|
666
|
-
|
|
667
|
-
|
|
700
|
+
entryEnd: (ended) => {
|
|
701
|
+
const active = deferring;
|
|
702
|
+
const within = current;
|
|
668
703
|
deferring = void 0;
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
|
|
704
|
+
const pauseAfter = () => {
|
|
705
|
+
const full = deferred.length >= 16384 || deferredBytes >= 16777216;
|
|
706
|
+
return within === last || full || links.size >= input.bounds.links ? "pause" : void 0;
|
|
707
|
+
};
|
|
708
|
+
if (active !== void 0) {
|
|
709
|
+
deferred.push(active);
|
|
710
|
+
return pauseAfter();
|
|
711
|
+
}
|
|
712
|
+
const done = settled(ended, within, links);
|
|
713
|
+
return done === void 0 ? pauseAfter() : Effect.map(done, pauseAfter);
|
|
714
|
+
}
|
|
672
715
|
};
|
|
673
716
|
const reading = yield* Effect.uninterruptibleMask((restore) => Effect.flatMap(refusedIfSpent(bucketStream(bucket, packFiles(pack.id).pack, {
|
|
674
717
|
offset: at.offset,
|
|
@@ -706,24 +749,31 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
706
749
|
if (counted + later.size >= input.bounds.links) return links.positionOf(streamed) - ranges.base - at.position + 1;
|
|
707
750
|
}
|
|
708
751
|
};
|
|
709
|
-
const settleDeferred =
|
|
710
|
-
const { entry, within } = each;
|
|
711
|
-
const inSlice = withinOf(each.oid);
|
|
752
|
+
const settleDeferred = (each, types) => {
|
|
753
|
+
const { entry, within, inSlice } = each;
|
|
712
754
|
const base = inSlice >= 0 ? {
|
|
713
755
|
offset: entries.offsets[inSlice] ?? 0,
|
|
714
756
|
position: at.position + inSlice
|
|
715
757
|
} : outside.placeOf(each.oid);
|
|
716
|
-
if (base === void 0) return
|
|
758
|
+
if (base === void 0) return Effect.fail(lost(`Pack ${pack.id}'s delta at ${entry.offset} names ${each.oid}, which the pack lacks`));
|
|
717
759
|
baseAt(entry.index, base.position);
|
|
718
760
|
if ((inSlice >= 0 ? inSlice < within ? known[inSlice] ?? unknown : unknown : types.get(each.oid) ?? unknown) === typeCodes.blob) {
|
|
719
761
|
known[within] = typeCodes.blob;
|
|
720
762
|
skipped += 1;
|
|
721
763
|
return;
|
|
722
764
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
765
|
+
cachedBaseOid = each.oid;
|
|
766
|
+
cachedBaseOffset = base.offset;
|
|
767
|
+
const began = indexer.entry(entry);
|
|
768
|
+
if (!Effect.isEffect(began)) {
|
|
769
|
+
for (const piece of each.pieces ?? []) indexer.data(piece);
|
|
770
|
+
return settled(entry, within, later);
|
|
771
|
+
}
|
|
772
|
+
return Effect.flatMap(began, () => {
|
|
773
|
+
for (const piece of each.pieces ?? []) indexer.data(piece);
|
|
774
|
+
return settled(entry, within, later) ?? Effect.void;
|
|
775
|
+
});
|
|
776
|
+
};
|
|
727
777
|
const types = /* @__PURE__ */ new Map();
|
|
728
778
|
let size = input.calls === void 0 ? deferred.length : 16;
|
|
729
779
|
let perBaseLast = 0;
|
|
@@ -731,7 +781,7 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
731
781
|
if (from > 0) size = nextChunk(input.calls, perBaseLast, size, deferred.length - from);
|
|
732
782
|
const made = input.calls?.made() ?? 0;
|
|
733
783
|
const chunk = deferred.slice(from, from + size);
|
|
734
|
-
const named = idsBytes(chunk.flatMap((each) =>
|
|
784
|
+
const named = idsBytes(chunk.flatMap((each) => each.inSlice < 0 && !types.has(each.oid) ? [each.oid] : []));
|
|
735
785
|
const found = yield* Effect.result(cutAtSpent(outside.find(named.sorted, named.bytes)));
|
|
736
786
|
if (Result.isFailure(found)) {
|
|
737
787
|
spentMost = spentOf(found.failure)?.most;
|
|
@@ -748,12 +798,15 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
748
798
|
const { within } = each;
|
|
749
799
|
cut = cutBefore(within);
|
|
750
800
|
if (cut !== void 0) break chunks;
|
|
751
|
-
const
|
|
752
|
-
if (
|
|
753
|
-
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
|
|
801
|
+
const step = settleDeferred(each, types);
|
|
802
|
+
if (step !== void 0) {
|
|
803
|
+
const done = yield* Effect.result(cutAtSpent(step));
|
|
804
|
+
if (Result.isFailure(done)) {
|
|
805
|
+
spentMost = spentOf(done.failure)?.most;
|
|
806
|
+
if (spentMost === void 0) return yield* Effect.fail(done.failure);
|
|
807
|
+
cut = within;
|
|
808
|
+
break chunks;
|
|
809
|
+
}
|
|
757
810
|
}
|
|
758
811
|
each.pieces = void 0;
|
|
759
812
|
if (counted + later.size >= input.bounds.links) {
|