Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/main/java/org/apache/datasketches/common/Family.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, Family> lookupID = new HashMap<>();
private static final Map<String, Family> lookupFamName = new HashMap<>();
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/org/apache/datasketches/common/FamilyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading