apache / apache/datasketches-java
Non-deterministic result when merging an empty KllFloatsSketch with two others
- Ngôn ngữ chính
- Java
- Star
- 958
- Fork
- 226
- Merge trung bình
- 3 ngày 40 phút
- Pull request đã merge (30 ngày)
- 13
Mô tả
Merging an empty KllFloatsSketch with two KllFloatsSketch, with 1 and 200 "items" respectively, does not always produce the same result
I would have expected the following test scenario to pass:
```
@Test
public void test() throws NoSuchAlgorithmException {
KllFloatsSketch t1 = KllFloatsSketch.newHeapInstance();
t1.update(1f);
byte[] tb1 = t1.toByteArray();
KllFloatsSketch t2 = KllFloatsSketch.newHeapInstance();
for(int i=0; i<200; i++) {
t2.update(1f*i);
}
byte[] tb2 = t2.toByteArray();
HashSet digests = new HashSet<>();
for(int i=0; i<30; i++) {
KllFloatsSketch start = KllFloatsSketch.newHeapInstance();
byte[] h1 = Arrays.copyOf(tb1, tb1.length);
byte[] h2 = Arrays.copyOf(tb2, tb2.length);
KllFloatsSketch kll1 = KllFloatsSketch.heapify(MemorySegment.ofArray(h1));
start.merge(kll1);
KllFloatsSketch kll2 = KllFloatsSketch.heapify(MemorySegment.ofArray(h2));
start.merge(kll2);
MessageDigest md5 = MessageDigest.getInstance("MD5");
BigInteger digest = new BigInteger(md5.digest(start.toByteArray()));
digests.add(digest);
System.out.println(digest);
}
assertEquals(1, digests.size());
}
```
The digests are:
```
115710133967357289505160160937439690295
-100233422360292323003164315945381734567
-100233422360292323003164315945381734567
-100233422360292323003164315945381734567
115710133967357289505160160937439690295
115710133967357289505160160937439690295
...
```
And therefore the test throws:
```
java.lang.AssertionError:
Expected :2
Actual :1
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện test được cung cấp xoay quanh KllFloatsSketch.newHeapInstance(), heapify(), merge() và toByteArray(). So sánh các kết quả được serialize lặp lại khi merge các sketch chứa 1 và 200 item, sau đó trace hành vi merge và serialization. Hoàn thành khi test lặp lại tạo ra một digest xác định duy nhất và luôn pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- data
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100