mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 03:25:20 +00:00
A retained decode_android_resources result could only be read back whole.
It carries the full manifest text and every returned string, so on VLC
3.7.2 it was 180,996 bytes.
The android-resources view pages one retained decode. Facet strings lists
{locale, name, value} rows across the decoded tables, selected by locales
(null is the default table) and matched by exact names or name prefixes;
coverage.total counts every match, and each page carries the selected
tables' own counts, pages and coverage. A locale the decode did not return
is refused with the decoded tables named. Facet manifest pages the manifest
text by UTF-16 offset.
Pages stop at the analysis-view page bytes through a shared
selectByteBoundedViewRows: a row that does not fit ends the page with
byte_limited and next_offset after the last returned row, and a row that
cannot fit alone is refused naming the retained parent. Unfiltered pages
visit only their own rows, and the flattened string rows are built once
per retained decode. A decode recorded with include_strings false refuses
the strings facet instead of reporting an empty table.
The summary keeps the client, target, metadata, locales, decoded file
count and coverage, each table's counts and page without its strings, and
the manifest length without its text.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { ANALYSIS_VIEW_PAGE_BYTES } from "./analysisViewErrors.js";
|
|
import { selectByteBoundedViewRows } from "./byteBoundedViewRows.js";
|
|
|
|
const owner = {
|
|
parentEvidenceId: `ev_${"a".repeat(64)}`,
|
|
envelope: { kind: "probe" },
|
|
facet: "rows",
|
|
};
|
|
|
|
it("projects only the page's rows when unfiltered", () => {
|
|
const projected: number[] = [];
|
|
const page = selectByteBoundedViewRows(
|
|
Array.from({ length: 1_000 }, (_, index) => index),
|
|
{ offset: 10, limit: 3 },
|
|
{
|
|
matches: undefined,
|
|
project: (row) => {
|
|
projected.push(row);
|
|
return { row };
|
|
},
|
|
},
|
|
owner,
|
|
);
|
|
expect(page).toEqual({
|
|
ok: true,
|
|
value: {
|
|
rows: [{ row: 10 }, { row: 11 }, { row: 12 }],
|
|
total: 1_000,
|
|
byte_limited: false,
|
|
},
|
|
});
|
|
expect(projected).toEqual([10, 11, 12]);
|
|
});
|
|
|
|
it("counts every match after a byte-limited page", () => {
|
|
const big = "x".repeat(ANALYSIS_VIEW_PAGE_BYTES / 3);
|
|
const page = selectByteBoundedViewRows(
|
|
Array.from({ length: 8 }, (_, index) => ({ index, big })),
|
|
{ offset: 0, limit: 64 },
|
|
{ matches: (row) => row.index % 2 === 0, project: (row) => row },
|
|
owner,
|
|
);
|
|
if (!page.ok) throw page.error;
|
|
expect(page.value.rows.map((row) => row.index)).toEqual([0, 2]);
|
|
expect(page.value).toMatchObject({ total: 4, byte_limited: true });
|
|
});
|
|
|
|
it("refuses a row that cannot fit a page alone and names the parent", () => {
|
|
const page = selectByteBoundedViewRows(
|
|
["x".repeat(ANALYSIS_VIEW_PAGE_BYTES)],
|
|
{ offset: 0, limit: 1 },
|
|
{ matches: undefined, project: (row) => row },
|
|
owner,
|
|
);
|
|
expect(page).toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
_tag: "AnalysisResourceConstraintError",
|
|
reportedLimits: {
|
|
parent_evidence_id: owner.parentEvidenceId,
|
|
facet: "rows",
|
|
limit_bytes: ANALYSIS_VIEW_PAGE_BYTES,
|
|
},
|
|
},
|
|
});
|
|
});
|