This is an automated email from the ASF dual-hosted git repository. dcapwell pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git
The following commit(s) were added to refs/heads/trunk by this push: new 0d8f60f (Accord) NPE while trying to serialize FoundKnownMap as value is null half the time but unexpected while serializing (#78) 0d8f60f is described below commit 0d8f60f742d443365a50115397ff1f0ab10fc694 Author: dcapwell <dcapw...@apache.org> AuthorDate: Tue Jan 9 15:49:24 2024 -0800 (Accord) NPE while trying to serialize FoundKnownMap as value is null half the time but unexpected while serializing (#78) patch by David Capwell; reviewed by Blake Eggleston for CASSANDRA-19253 --- .../main/java/accord/impl/CommandTimeseries.java | 4 ++-- .../src/test/java/accord/utils/AccordGens.java | 26 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/accord-core/src/main/java/accord/impl/CommandTimeseries.java b/accord-core/src/main/java/accord/impl/CommandTimeseries.java index 4cc5046..d7d37dc 100644 --- a/accord-core/src/main/java/accord/impl/CommandTimeseries.java +++ b/accord-core/src/main/java/accord/impl/CommandTimeseries.java @@ -130,12 +130,12 @@ public class CommandTimeseries<D> { if (result == null) { - result = Timestamp.min(loader.txnId(data), loader.executeAt(data)); + result = Timestamp.nonNullOrMin(loader.txnId(data), loader.executeAt(data)); } else { result = Timestamp.min(result, loader.txnId(data)); - result = Timestamp.min(result, loader.executeAt(data)); + result = Timestamp.nonNullOrMin(result, loader.executeAt(data)); } } return result; diff --git a/accord-core/src/test/java/accord/utils/AccordGens.java b/accord-core/src/test/java/accord/utils/AccordGens.java index 87c012a..29b5839 100644 --- a/accord-core/src/test/java/accord/utils/AccordGens.java +++ b/accord-core/src/test/java/accord/utils/AccordGens.java @@ -29,6 +29,7 @@ import accord.api.RoutingKey; import accord.impl.IntHashKey; import accord.impl.IntKey; import accord.local.Node; +import accord.primitives.Ballot; import accord.primitives.Deps; import accord.primitives.KeyDeps; import accord.primitives.Range; @@ -55,6 +56,21 @@ public class AccordGens return nodes.map(Node.Id::new); } + public static Gen.IntGen flags() + { + return rs -> rs.nextInt(0, 1 << 16); + } + + public static Gen<Timestamp> timestamps() + { + return timestamps(epochs()::nextLong, rs -> rs.nextLong(0, Long.MAX_VALUE), flags(), RandomSource::nextInt); + } + + public static Gen<Timestamp> timestamps(Gen.LongGen epochs, Gen.LongGen hlcs, Gen.IntGen flags, Gen.IntGen nodes) + { + return rs -> Timestamp.fromValues(epochs.nextLong(rs), hlcs.nextLong(rs), flags.nextInt(rs), new Node.Id(nodes.nextInt(rs))); + } + public static Gen<TxnId> txnIds() { return txnIds(epochs()::nextLong, rs -> rs.nextLong(0, Long.MAX_VALUE), RandomSource::nextInt); @@ -67,6 +83,16 @@ public class AccordGens return rs -> new TxnId(epochs.nextLong(rs), hlcs.nextLong(rs), kinds.next(rs), domains.next(rs), new Node.Id(nodes.nextInt(rs))); } + public static Gen<Ballot> ballot() + { + return ballot(epochs()::nextLong, rs -> rs.nextLong(0, Long.MAX_VALUE), flags(), RandomSource::nextInt); + } + + public static Gen<Ballot> ballot(Gen.LongGen epochs, Gen.LongGen hlcs, Gen.IntGen flags, Gen.IntGen nodes) + { + return rs -> Ballot.fromValues(epochs.nextLong(rs), hlcs.nextLong(rs), flags.nextInt(rs), new Node.Id(nodes.nextInt(rs))); + } + public static Gen<Key> intKeys() { return rs -> new IntKey.Raw(rs.nextInt()); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org