Visitar URL original
feat: columnar faceting (plans 1-6) by robfrank · Pull Request #10855 · ArcadeData/arcadedb · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
5a2ecdd
docs(columnar): faceting design spec, roadmap, plans 1-6 and overview
robfrank Oct 28, 2026
a511628
test(columnar): plan 1 feasibility spike
robfrank Oct 28, 2026
b5375ea
feat(columnar): plan 2 task 1 - Move the four codecs to `com.arcadedb…
robfrank Oct 28, 2026
c91ba66
feat(columnar): plan 2 task 2 - `BitPackedCodec`
robfrank Oct 28, 2026
b1e8209
feat(columnar): plan 2 task 3 - `LinearCodec`
robfrank Oct 28, 2026
0b26eec
feat(columnar): plan 2 task 4 - `BlockwiseLinearCodec`
robfrank Oct 28, 2026
8298455
feat(columnar): plan 2 task 5 - `NumericCodecChooser`
robfrank Oct 28, 2026
253fe8a
feat(columnar): plan 2 task 6 - `BlockHeader`
robfrank Oct 28, 2026
d0ebc9e
feat(columnar): plan 2 task 7 - `BLOCK_CACHE_MAX_BYTES` and `BlockCache`
robfrank Oct 28, 2026
d9ffd0e
fix(columnar): plan 2 final review fixes
robfrank Oct 28, 2026
48b27a8
feat(columnar): plan 3 task 1 - PositionBitmap
robfrank Oct 28, 2026
c4430a7
feat(columnar): plan 3 task 2 - GlobalDictionary
robfrank Oct 28, 2026
bc5429a
feat(columnar): plan 3 task 3 - ColumnarValueExtractor (GROUP BY conv…
robfrank Oct 28, 2026
dbd98ef
feat(columnar): plan 3 task 4 - Segment writer and reader
robfrank Oct 28, 2026
c2faad2
feat(columnar): plan 3 task 5 - Store, dead sets and manifest (spec 5.5)
robfrank Oct 28, 2026
18156ba
feat(columnar): plan 3 task 6 - Overlay, content owner map, projectio…
robfrank Oct 28, 2026
b3d71a1
feat(columnar): plan 3 task 7 - DirtyPageTracker (spec 6.2)
robfrank Oct 28, 2026
c8f2744
feat(columnar): plan 3 task 8 - ColumnarProjection
robfrank Oct 28, 2026
65c342a
feat(columnar): plan 3 task 9 - Configuration keys and dedicated pools
robfrank Oct 28, 2026
c02cb92
feat(columnar): plan 3 task 10 - Flush and merge
robfrank Oct 28, 2026
5c9cf8a
feat(columnar): plan 3 task 11 - COLUMNAR index type, metadata, build…
robfrank Oct 28, 2026
e89bc7d
feat(columnar): plan 3 task 12 - ColumnarIndexManager lifecycle
robfrank Oct 28, 2026
bc85563
feat(columnar): plan 3 task 13 - Dirty page hooks on commit, Raft app…
robfrank Oct 28, 2026
4480924
feat(columnar): plan 3 task 14 - LocalBucket committed page slot API
robfrank Oct 28, 2026
7428ecf
feat(columnar): plan 3 task 15 - Apply pass
robfrank Oct 28, 2026
4c58602
feat(columnar): plan 3 task 16 - Recovery, rebuild and the WAL housek…
robfrank Oct 28, 2026
5361ff6
feat(columnar): plan 3 task 17 - Schema events and reconcile (spec 6.4)
robfrank Oct 28, 2026
f6d5716
feat(columnar): plan 3 task 18 - Metrics
robfrank Oct 28, 2026
8b71918
feat(columnar): plan 3 task 19 - Shared fixtures FacetOracle and Colu…
robfrank Oct 28, 2026
62dc4ca
feat(columnar): plan 3 task 20 - Engine equivalence integration tests
robfrank Oct 28, 2026
08ccfa8
feat(columnar): plan 3 task 21 - Engine crash tests
robfrank Oct 28, 2026
a929c20
feat(columnar): plan 3 task 22 - HA - exclusion from snapshots and ba…
robfrank Oct 28, 2026
9cc7135
feat(columnar): plan 3 task 23 - HA integration tests (BaseRaftHATest)
robfrank Oct 28, 2026
c2ef09e
feat(columnar): plan 3 task 24 - Dictionary compaction (spec 5.4)
robfrank Oct 28, 2026
b9232b5
fix(columnar): plan 3 final review fixes, batch 1
robfrank Oct 28, 2026
6f9f63e
fix(columnar): plan 3 final review fixes, batch 2
robfrank Oct 28, 2026
c87c83b
fix(columnar): plan 3 final review fixes, batch 3
robfrank Oct 28, 2026
f777bfa
feat(facets): plan 4 task 1 - Settings, FacetSpec types and the resul…
robfrank Oct 28, 2026
49ef3fc
feat(facets): plan 4 task 2 - FACETS grammar, keywords as identifiers…
robfrank Oct 28, 2026
e74d70f
feat(facets): plan 4 task 3 - FacetSpecCompiler (AST to specs, valida…
robfrank Oct 28, 2026
4143292
feat(facets): plan 4 task 4 - Calendar and fixed histogram boundaries…
robfrank Oct 28, 2026
4cdda59
feat(facets): plan 4 task 5 - Range bucketing, counters, ranking, mem…
robfrank Oct 28, 2026
47b0522
feat(facets): plan 4 task 6 - MatchSet
robfrank Oct 28, 2026
8f75f78
feat(facets): plan 4 task 7 - FacetExecutor - terms over the projecti…
robfrank Oct 28, 2026
c5d164d
feat(facets): plan 4 task 8 - Patching, own-transaction writes, budge…
robfrank Oct 28, 2026
dc0fcb2
feat(facets): plan 4 task 9 - Range and histogram execution
robfrank Oct 28, 2026
27a4950
feat(facets): plan 4 task 10 - Fallback scan, per-database cap, unava…
robfrank Oct 28, 2026
fd572a9
feat(facets): plan 4 task 11 - SQL wiring - FacetCollectStep, planner…
robfrank Oct 28, 2026
1b602b0
feat(facets): plan 4 task 12 - Disjunctive FILTER (one pass, post-fil…
robfrank Oct 28, 2026
2d2006c
feat(facets): plan 4 task 13 - Metrics
robfrank Oct 28, 2026
d4f16b8
feat(facets): plan 4 task 14 - HTTP JSON, ndjson, handler limits, Rem…
robfrank Oct 28, 2026
08b7e58
feat(facets): plan 4 task 15 - OpenAPI
robfrank Oct 28, 2026
3d918e7
feat(facets): plan 4 task 16 - gRPC proto, service, RemoteGrpcDatabase
robfrank Oct 28, 2026
138025c
feat(facets): plan 4 task 17 - Security IT and memory-budget IT
robfrank Oct 28, 2026
f9359b1
feat(facets): plan 4 task 18 - HA integration tests on followers
robfrank Oct 28, 2026
45da793
feat(facets): plan 4 task 19 - Facets vs GROUP BY benchmark (report o…
robfrank Oct 28, 2026
9b0f979
fix(facets): plan 4 final review fixes, batch 1
robfrank Oct 28, 2026
2040032
fix(facets): plan 4 final review fixes
robfrank Oct 28, 2026
b403a9e
feat(facets): plan 5 task 1 - Grammar and spec records for HIERARCHY,…
robfrank Oct 28, 2026
d5e0bad
feat(facets): plan 5 task 2 - Hierarchy definition in COLUMNAR METADATA
robfrank Oct 28, 2026
3486800
feat(facets): plan 5 task 3 - AncestorExpander (pure arrays)
robfrank Oct 28, 2026
205a586
feat(facets): plan 5 task 4 - HierarchyView and HierarchyBuilder
robfrank Oct 28, 2026
f9889fc
fix(columnar): adapt the projection's durability to group commit and …
robfrank Oct 29, 2026
ce35834
feat(facets): plan 5 task 5 - HierarchyManager, page-change generatio…
robfrank Oct 28, 2026
c3ce6cf
feat(facets): plan 5 task 6 - HIERARCHY facet collector and integrati…
robfrank Oct 28, 2026
936519d
feat(facets): plan 5 task 7 - HyperLogLog
robfrank Oct 28, 2026
26f3009
feat(facets): plan 5 task 8 - DISTINCT facet collector
robfrank Oct 28, 2026
47dea2f
feat(facets): plan 5 task 9 - STATS facet collector and public Numeri…
robfrank Oct 28, 2026
bfc9857
feat(facets): plan 5 task 10 - Dictionary prefix search and the AFTER…
robfrank Oct 28, 2026
7ea1592
feat(facets): plan 5 task 11 - facet.searchValues SQL function
robfrank Oct 28, 2026
136b78f
feat(facets): plan 5 task 12 - GROUP BY acceleration, eligibility and…
robfrank Oct 28, 2026
12a81d8
feat(facets): plan 5 task 13 - GROUP BY acceleration, execution and e…
robfrank Oct 28, 2026
c5f4748
feat(facets): plan 5 task 14 - Transports: HTTP IT, OpenAPI, gRPC, Re…
robfrank Oct 28, 2026
1756f9b
fix(facets): plan 5 final review fixes
robfrank Oct 28, 2026
798b38c
fix(facets): plan 6 task 0 - Lag floor in `FacetExecutor` (engine)
robfrank Oct 29, 2026
4c584b6
test(facets): plan 6 task 1 - Response and metric parsers
robfrank Oct 29, 2026
a8ea3a8
test(facets): plan 6 task 2 - Facet schema, statements and generator,…
robfrank Oct 29, 2026
0424c59
test(facets): plan 6 task 3 - `FacetDatabaseWrapper`
robfrank Oct 29, 2026
7926256
test(facets): plan 6 task 4 - `FacetCheck` and its HTTP reader
robfrank Oct 29, 2026
651fe22
test(facets): plan 6 task 5 - Report facet violations at the existing…
robfrank Oct 29, 2026
05114b0
test(facets): plan 6 task 6 - Facet workload beside the ledger workload
robfrank Oct 29, 2026
496ddb7
test(facets): plan 6 task 7 - Wire facets into `HaChaosIT` and `Chaos…
robfrank Oct 29, 2026
efaf24d
fix(facets): plan 6 task 8 - `LeaderFailoverIT` - a new replica rebui…
robfrank Oct 29, 2026
54d3420
test(facets): plan 6 task 9 - `RollingRestartIT` and `NetworkPartitio…
robfrank Oct 29, 2026
1c14252
test(facets): plan 6 task 10 - `SplitBrainIT` and `PacketLossIT`
robfrank Oct 29, 2026
18e1f02
test(facets): plan 6 task 11 - SingleServerFacetLoadTestIT (in progress)
robfrank Oct 29, 2026
81c9614
test(facets): plan 6 task 11 - SingleServerFacetLoadTestIT
robfrank Oct 30, 2026
0a8ed8f
fix(facets): plan 6 task 12 - ThreeNodesFacetLoadTestIT
robfrank Oct 30, 2026
9324955
fix(columnar): plan 6 final review fixes, engine
robfrank Oct 30, 2026
0dc6ba9
test(facets): plan 6 final review fixes, harness and docs
robfrank Oct 30, 2026
a6e7d30
perf(columnar): plan 7 tuning (#10662)
robfrank Nov 4, 2026
3c13f4c
fix(columnar): CI failures after the rebase on 26.11.1
robfrank Nov 5, 2026
6aaa468
fix(#10355): review follow-ups for codecs and BlockCache (LinearCodec…
robfrank Nov 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(facets): plan 6 task 5 - Report facet violations at the existing…
… checkpoint

Part of #10361.
  • Loading branch information
robfrank committed Nov 5, 2026
commit 651fe2271c8a4ea17d5562678460a74aab93113b
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

package com.arcadedb.containers.ha.chaos;

import com.arcadedb.serializer.json.JSONArray;
import com.arcadedb.serializer.json.JSONObject;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
* Writes the run's report under {@code target/chaos/<seed>/}. Step and trend lines are flushed as they are written,
Expand All @@ -41,6 +44,8 @@ public final class ChaosReport implements AutoCloseable {
private int reformats;
// Steps whose reformat counts could not be read, so that "none seen" is not mistaken for "none happened"
private int stepsWithUnreadReformats;
// FACET_META findings of every checkpoint: reported, never a failure
private final Set<String> facetWarnings = new LinkedHashSet<>();

public ChaosReport(final Path dir, final ChaosConfig config) throws IOException {
Files.createDirectories(dir);
Expand Down Expand Up @@ -85,6 +90,10 @@ public synchronized void trend(final TrendRow row) throws IOException {
trends.flush();
}

public synchronized void facetWarnings(final List<String> warnings) {
facetWarnings.addAll(warnings);
}

public void ledgerDiff(final List<Violation> violations) throws IOException {
final StringBuilder text = new StringBuilder();
for (final Violation violation : violations) {
Expand All @@ -107,7 +116,7 @@ private synchronized int stepsWithUnreadReformats() {
return stepsWithUnreadReformats;
}

public void summary(final ChaosResult result, final Ledger ledger, final long lateCommits) throws IOException {
public synchronized void summary(final ChaosResult result, final Ledger ledger, final long lateCommits) throws IOException {
final JSONObject counts = new JSONObject()
.put("acked", ledger.count(Ledger.ACKED))
.put("ackedLate", ledger.count(Ledger.ACKED_LATE))
Expand All @@ -128,6 +137,7 @@ public void summary(final ChaosResult result, final Ledger ledger, final long la
.put("lateCommits", lateCommits)
.put("reformats", reformats())
.put("stepsWithUnreadReformats", stepsWithUnreadReformats())
.put("facetWarnings", new JSONArray(facetWarnings))
.put("replay", config.replayCommand());
Files.writeString(dir.resolve("summary.json"), summary.toString(2), StandardCharsets.UTF_8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public ChaosResult run() {
}
load.close();
final Checkpoint.Result last = checkpoint.run();
report.facetWarnings(last.warnings());
if (!last.violations().isEmpty())
return finish(fromViolations(last.violations(), step));
return finish(new ChaosResult(ResultKind.PASS, "Completed " + step + " steps", step, List.of()));
Expand Down Expand Up @@ -203,6 +204,7 @@ private ChaosResult holdHealAndCheck(final int step, final Fault fault, final St
} finally {
load.resume();
}
report.facetWarnings(result.warnings());

// Read whatever the checkpoint found: a node that reformatted and then failed to converge is the case where the reformat is the
// most useful diagnostic. Before the step is written, so that its line carries the count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
package com.arcadedb.containers.ha.chaos;

import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.test.support.FacetSnapshot;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -51,13 +55,17 @@ private static ChaosConfig config(final String... overrides) {
}

private Harness harness(final ChaosConfig config) throws IOException {
return harness(config, null);
}

private Harness harness(final ChaosConfig config, final FacetCheck facets) throws IOException {
final Ledger ledger = new Ledger(config.writers());
final FakeNodeControl control = new FakeNodeControl();
final FakeLoad load = new FakeLoad(ledger);
final LedgerNodeReader reader = new LedgerNodeReader(ledger);
final InvariantChecker checker = new InvariantChecker(ledger);
final Checkpoint checkpoint = new Checkpoint(reader, ledger, checker, config.nodes(), Duration.ofSeconds(1),
Duration.ofMillis(1));
Duration.ofMillis(1), facets);
final ChaosReport report = new ChaosReport(dir.resolve(Long.toString(config.seed())), config);
final ChaosRunner runner = new ChaosRunner(config, new ClusterState(config.nodes()), control,
new FaultPicker(config.faultWeights(), config.electionTimeout()), load, ledger, checkpoint, checker, report, null,
Expand Down Expand Up @@ -410,4 +418,44 @@ void unreadableRestartCountsStillFailAFaultThatForbidsAReformat() throws IOExcep
assertThat(result.kind()).isEqualTo(ResultKind.HARNESS);
assertThat(result.message()).contains("in-place restart counts");
}

private static SortedMap<String, Long> facetCounts(final long nike) {
final SortedMap<String, Long> counts = new TreeMap<>();
counts.put("brand=Nike", nike);
counts.put("size=small", 3L);
return counts;
}

private static FakeFacetReader facetReader(final FacetSnapshot node1) {
final FakeFacetReader reader = new FakeFacetReader();
for (int node = 0; node < 3; node++)
reader.data.put(node, facetCounts(5));
if (node1 != null)
reader.script.put(1, new ArrayDeque<>(List.of(node1)));
return reader;
}

private static FacetCheck facetCheck(final FakeFacetReader reader) {
return new FacetCheck(reader, 3, Duration.ofSeconds(1), Duration.ofMillis(1));
}

@Test
void facetDriftEndsTheRunAsSafety() throws IOException {
final FakeFacetReader reader = facetReader(FakeFacetReader.sample(true, 0, "index", facetCounts(4)));
final ChaosResult result = harness(config(), facetCheck(reader)).runner().run();
assertThat(result.kind()).isEqualTo(ResultKind.SAFETY);
assertThat(result.steps()).isEqualTo(1);
assertThat(Files.readString(dir.resolve("7/ledger-diff.txt"))).contains("== FACET_DRIFT (SAFETY)");
assertThat(new JSONObject(Files.readString(dir.resolve("7/summary.json"))).getString("result")).isEqualTo("SAFETY");
}

@Test
void facetWarningsAreInTheSummaryAndDoNotFailTheRun() throws IOException {
final FakeFacetReader reader = facetReader(FakeFacetReader.sample(false, 0, "index", facetCounts(5)));
final ChaosResult result = harness(config(), facetCheck(reader)).runner().run();
assertThat(result.kind()).isEqualTo(ResultKind.PASS);
final JSONObject summary = new JSONObject(Files.readString(dir.resolve("7/summary.json")));
assertThat(summary.getJSONArray("facetWarnings").length()).isEqualTo(1);
assertThat(summary.getJSONArray("facetWarnings").getString(0)).contains("FACET_META").contains("node 1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@
* the same deadline), reports keys that differ between nodes, then checks node 0 against the ledger. Counts that never
* agree while every node's scans find the same records are a {@code COUNT_DRIFT}: the stored counters {@code count(*)}
* reads drifted from the data. A 5xx while scanning is a SAFETY {@code SCAN_ERROR} (the node is up but cannot serve
* its own data); any other scan failure is an AVAILABILITY {@code SCAN}.
* its own data); any other scan failure is an AVAILABILITY {@code SCAN}. When all of that found nothing and a
* {@link FacetCheck} was given, it runs last on the same converged cluster: its violations are reported like the ledger's, its
* warnings travel in {@link Result#warnings()} and never fail the run.
*/
public final class Checkpoint {
public record Result(List<Violation> violations, long[] counts, long convergenceMillis, long durationMillis) {
/**
* @param warnings facet findings that are reported but never fail the run ({@link FacetCheck#warnings()})
*/
public record Result(List<Violation> violations, long[] counts, long convergenceMillis, long durationMillis,
List<String> warnings) {
public Result(final List<Violation> violations, final long[] counts, final long convergenceMillis, final long durationMillis) {
this(violations, counts, convergenceMillis, durationMillis, List.of());
}
}

private final NodeReader reader;
Expand All @@ -45,13 +54,23 @@ public record Result(List<Violation> violations, long[] counts, long convergence
private final int nodes;
private final Duration convergenceTimeout;
private final Duration pollInterval;
private final FacetCheck facets;
private long[] lastCounts;
private String lastReadError;
private final boolean[] lastReadable;
private final String[] lastReadErrors;

public Checkpoint(final NodeReader reader, final Ledger ledger, final InvariantChecker checker, final int nodes,
final Duration convergenceTimeout, final Duration pollInterval) {
this(reader, ledger, checker, nodes, convergenceTimeout, pollInterval, null);
}

/**
* @param facets the facet check to run after the ledger checks, or null for none
*/
public Checkpoint(final NodeReader reader, final Ledger ledger, final InvariantChecker checker, final int nodes,
final Duration convergenceTimeout, final Duration pollInterval, final FacetCheck facets) {
this.facets = facets;
this.reader = reader;
this.ledger = ledger;
this.checker = checker;
Expand Down Expand Up @@ -122,6 +141,10 @@ public Result run() throws InterruptedException {
if (divergence.keys().length > 0)
violations.add(divergence);
violations.addAll(checker.check(snapshots[0]));
if (violations.isEmpty() && facets != null) {
violations.addAll(facets.run());
return new Result(violations, current, convergenceMillis, millisSince(start), List.copyOf(facets.warnings()));
}
return new Result(violations, current, convergenceMillis, millisSince(start));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

package com.arcadedb.containers.ha.chaos;

import com.arcadedb.test.support.FacetSnapshot;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -279,4 +283,86 @@ void countDriftNeedsEveryNodeScanned() throws InterruptedException {
assertThat(checkpoint(reader, Duration.ofMillis(300)).run().violations()).extracting(Violation::invariant)
.containsExactly("CONVERGENCE");
}

private static SortedMap<String, Long> facetCounts(final long nike) {
final SortedMap<String, Long> counts = new TreeMap<>();
counts.put("brand=Nike", nike);
counts.put("size=small", 3L);
return counts;
}

private static FakeFacetReader facetReader() {
final FakeFacetReader facets = new FakeFacetReader();
for (int node = 0; node < 3; node++)
facets.data.put(node, facetCounts(5));
return facets;
}

private static FacetCheck facetCheck(final FakeFacetReader facets) {
return new FacetCheck(facets, 3, Duration.ofMillis(300), Duration.ofMillis(5));
}

private Checkpoint checkpoint(final NodeReader reader, final FacetCheck facets) {
return new Checkpoint(reader, ledger, new InvariantChecker(ledger), 3, Duration.ofMillis(300), Duration.ofMillis(20), facets);
}

private ScriptedNodeReader identicalNodes() {
final long a = acked();
final ScriptedNodeReader reader = new ScriptedNodeReader();
for (int node = 0; node < 3; node++)
reader.rows.put(node, List.of(new long[] { a, 0 }));
return reader;
}

@Test
void facetDriftIsReportedAfterLedgerChecksPass() throws InterruptedException {
final FakeFacetReader facets = facetReader();
facets.script.put(0, new ArrayDeque<>(List.of(FakeFacetReader.sample(true, 0, "index", facetCounts(4)))));
final List<Violation> violations = checkpoint(identicalNodes(), facetCheck(facets)).run().violations();
assertThat(violations).extracting(Violation::invariant).containsExactly("FACET_DRIFT");
assertThat(violations.getFirst().kind()).isEqualTo(ResultKind.SAFETY);
}

@Test
void facetCheckIsSkippedWhenTheLedgerAlreadyFailed() throws InterruptedException {
final long a = acked();
final long b = acked();
final ScriptedNodeReader reader = new ScriptedNodeReader();
reader.rows.put(0, List.of(new long[] { a, 0 }, new long[] { b, 0 }));
reader.rows.put(1, List.of(new long[] { a, 0 }));
reader.rows.put(2, List.of(new long[] { a, 0 }, new long[] { b, 0 }));
final FakeFacetReader facets = facetReader();
facets.script.put(0, new ArrayDeque<>(List.of(FakeFacetReader.sample(true, 0, "index", facetCounts(4)))));
final List<Violation> violations = checkpoint(reader, facetCheck(facets)).run().violations();
assertThat(violations).extracting(Violation::invariant).containsExactly("CONVERGENCE");
assertThat(facets.groupByCalls).isZero();
}

@Test
void facetCheckIsSkippedWhenTheLedgerCheckFindsAViolation() throws InterruptedException {
final ScriptedNodeReader reader = identicalNodes();
acked();
final FakeFacetReader facets = facetReader();
facets.script.put(0, new ArrayDeque<>(List.of(FakeFacetReader.sample(true, 0, "index", facetCounts(4)))));
final List<Violation> violations = checkpoint(reader, facetCheck(facets)).run().violations();
assertThat(violations).isNotEmpty().extracting(Violation::invariant).doesNotContain("FACET_DRIFT");
assertThat(facets.groupByCalls).isZero();
}

@Test
void noFacetCheckKeepsTheOldBehaviour() throws InterruptedException {
final Checkpoint.Result result = checkpoint(identicalNodes(), Duration.ofSeconds(5)).run();
assertThat(result.violations()).isEmpty();
assertThat(result.warnings()).isEmpty();
}

@Test
void facetWarningsReachTheResultWithoutFailingIt() throws InterruptedException {
final FakeFacetReader facets = facetReader();
facets.script.put(1, new ArrayDeque<>(List.of(FakeFacetReader.sample(false, 0, "index", facetCounts(5)))));
final Checkpoint.Result result = checkpoint(identicalNodes(), facetCheck(facets)).run();
assertThat(result.violations()).isEmpty();
assertThat(result.warnings()).hasSize(1);
assertThat(result.warnings().getFirst()).contains("FACET_META").contains("node 1");
}
}