From 34ff14bc7a65cdf148935bde4c2bc53e7a5f2d66 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Fri, 20 Nov 2026 10:55:48 -0800 Subject: [PATCH] Family: reserve DENSITY(23) C++ moved the Density Sketch from family ID 19, which it shared with EBPPS, to 23 (ds-cpp #590, closing ds-cpp #589). Reserve the ID in Java so it is not reused. Java has no Density Sketch; the preamble sizes, 2 and 3 longs, follow the C++ 3- and 6-int preambles. Co-Authored-By: Claude Opus 5.5 --- .../java/org/apache/datasketches/common/Family.java | 10 +++++++++- .../org/apache/datasketches/common/FamilyTest.java | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/datasketches/common/Family.java b/src/main/java/org/apache/datasketches/common/Family.java index fef730d2a..d08c7b754 100644 --- a/src/main/java/org/apache/datasketches/common/Family.java +++ b/src/main/java/org/apache/datasketches/common/Family.java @@ -167,7 +167,15 @@ public enum Family { /** * Xor Filter */ - XORFILTER(22, "XORFILTER", 3, 3); + XORFILTER(22, "XORFILTER", 3, 3), + + /** + * Density Sketch, for estimating the density of multidimensional points with a kernel function. + * This ID is reserved for the C++ and Python Density Sketch, which has no Java implementation. + * Its preamble is 3 ints (empty) or 6 ints, so 2 or 3 longs. Earlier C++ releases + * serialized it with family ID 19, the ID of {@link #EBPPS}. + */ + DENSITY(23, "DENSITY", 2, 3); private static final Map lookupID = new HashMap<>(); private static final Map lookupFamName = new HashMap<>(); diff --git a/src/test/java/org/apache/datasketches/common/FamilyTest.java b/src/test/java/org/apache/datasketches/common/FamilyTest.java index 1c7c1a71f..5e4c43bad 100644 --- a/src/test/java/org/apache/datasketches/common/FamilyTest.java +++ b/src/test/java/org/apache/datasketches/common/FamilyTest.java @@ -54,6 +54,14 @@ public void checkFamilyEnum() { checkStringToFamily("AnotB"); checkStringToFamily("HLL"); checkStringToFamily("Quantiles"); + checkStringToFamily("Density"); + } + + @Test + public void checkDensityId() { + //shared with C++ and Python, which moved the Density Sketch from ID 19 (EBPPS) to 23 + assertEquals(idToFamily(23), Family.DENSITY); + assertEquals(idToFamily(19), Family.EBPPS); } private static void checkStringToFamily(final String inStr) {