From 3020cdf50f2e38e9cf2107dfacef2d5586f22184 Mon Sep 17 00:00:00 2001 From: elliVM <47@teragrep.com> Date: Thu, 21 Nov 2024 12:32:08 +0200 Subject: [PATCH] use setLong instead of setInt and update test for partition values larger than max int --- .../com/teragrep/pth10/steps/teragrep/TeragrepBloomStep.java | 2 +- .../pth10/steps/teragrep/bloomfilter/TeragrepBloomFilter.java | 4 ++-- .../steps/teragrep/bloomfilter/TeragrepBloomFilterTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/teragrep/pth10/steps/teragrep/TeragrepBloomStep.java b/src/main/java/com/teragrep/pth10/steps/teragrep/TeragrepBloomStep.java index d20ae85..1380de7 100644 --- a/src/main/java/com/teragrep/pth10/steps/teragrep/TeragrepBloomStep.java +++ b/src/main/java/com/teragrep/pth10/steps/teragrep/TeragrepBloomStep.java @@ -190,7 +190,7 @@ private void writeFilterTypes(final Config config) { } final String sql = "INSERT IGNORE INTO `filtertype` (`expectedElements`, `targetFpp`, `pattern`) VALUES (?, ?, ?)"; try (final PreparedStatement stmt = connection.prepareStatement(sql)) { - stmt.setInt(1, entry.getKey().intValue()); // filtertype.expectedElements + stmt.setLong(1, entry.getKey()); // filtertype.expectedElements stmt.setDouble(2, entry.getValue()); // filtertype.targetFpp stmt.setString(3, pattern); // filtertype.pattern stmt.executeUpdate(); diff --git a/src/main/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilter.java b/src/main/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilter.java index 257d843..6e4358b 100644 --- a/src/main/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilter.java +++ b/src/main/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilter.java @@ -110,8 +110,8 @@ public void saveFilter(final Boolean overwrite) { ); filter.writeTo(baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); - stmt.setInt(1, Integer.parseInt(partitionID)); // bloomfilter.partition_id - stmt.setInt(2, (int) selectedExpectedNumOfItems); // filtertype.expectedElements + stmt.setLong(1, Long.parseLong(partitionID)); // bloomfilter.partition_id + stmt.setLong(2, selectedExpectedNumOfItems); // filtertype.expectedElements stmt.setDouble(3, selectedFpp); // filtertype.targetFpp stmt.setString(4, pattern); // filtertype.pattern stmt.setBlob(5, is); // bloomfilter.filter diff --git a/src/test/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilterTest.java b/src/test/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilterTest.java index a354f06..fede82a 100644 --- a/src/test/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilterTest.java +++ b/src/test/java/com/teragrep/pth10/steps/teragrep/bloomfilter/TeragrepBloomFilterTest.java @@ -341,6 +341,6 @@ private Row generatedRow(SortedMap filterMap, List tokens) Assertions.assertDoesNotThrow(() -> { bf.writeTo(baos); }); - return RowFactory.create("1", baos.toByteArray()); + return RowFactory.create("9999999999", baos.toByteArray()); } }