gianm commented on a change in pull request #9181: Speed up String first/last 
aggregators when folding isn't needed.
URL: https://github.com/apache/druid/pull/9181#discussion_r367656532
 
 

 ##########
 File path: 
processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastBufferAggregatorTest.java
 ##########
 @@ -81,6 +82,43 @@ public void testBufferAggregate()
 
   }
 
+  @Test
+  public void testBufferAggregateWithFoldCheck()
+  {
+    final long[] timestamps = {1526724600L, 1526724700L, 1526724800L, 
1526725900L, 1526725000L};
+    final String[] strings = {"AAAA", "BBBB", "CCCC", "DDDD", "EEEE"};
+    Integer maxStringBytes = 1024;
+
+    TestLongColumnSelector longColumnSelector = new 
TestLongColumnSelector(timestamps);
+    TestObjectColumnSelector<String> objectColumnSelector = new 
TestObjectColumnSelector<>(strings);
+
+    StringLastAggregatorFactory factory = new StringLastAggregatorFactory(
+        "billy", "billy", maxStringBytes
+    );
+
+    StringLastBufferAggregator agg = new StringLastBufferAggregator(
+        longColumnSelector,
+        objectColumnSelector,
+        maxStringBytes,
+        true
+    );
+
+    ByteBuffer buf = ByteBuffer.allocate(factory.getMaxIntermediateSize());
+    int position = 0;
+
+    agg.init(buf, position);
+    //noinspection ForLoopReplaceableByForEach
+    for (int i = 0; i < timestamps.length; i++) {
+      aggregateBuffer(longColumnSelector, objectColumnSelector, agg, buf, 
position);
+    }
+
+    SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, 
position));
+
+
+    Assert.assertEquals("expectec last string value", "DDDD", sp.rhs);
 
 Review comment:
   Updated.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to