liran-funaro commented on a change in pull request #10335:
URL: https://github.com/apache/druid/pull/10335#discussion_r501517293



##########
File path: 
processing/src/main/java/org/apache/druid/segment/incremental/OffheapIncrementalIndex.java
##########
@@ -346,4 +349,99 @@ public void close()
     }
     aggBuffers.clear();
   }
+
+  public static class Builder extends AppendableIndexBuilder
+  {
+    @Nullable
+    NonBlockingPool<ByteBuffer> bufferPool = null;
+
+    public Builder setBufferPool(final NonBlockingPool<ByteBuffer> bufferPool)
+    {
+      this.bufferPool = bufferPool;
+      return this;
+    }
+
+    @Override
+    public void validate()
+    {
+      super.validate();
+      if (bufferPool == null) {
+        throw new IllegalArgumentException("bufferPool cannot be null");
+      }
+    }
+
+    @Override
+    protected OffheapIncrementalIndex buildInner()
+    {
+      return new OffheapIncrementalIndex(
+          Objects.requireNonNull(incrementalIndexSchema, 
"incrementalIndexSchema is null"),
+          deserializeComplexMetrics,
+          concurrentEventAdd,
+          sortFacts,
+          maxRowCount,
+          Objects.requireNonNull(bufferPool, "bufferPool is null")
+      );
+    }
+  }
+
+  public static class Spec implements AppendableIndexSpec, Supplier<ByteBuffer>
+  {
+    public static final String TYPE = "offheap";
+    static final int DEFAULT_BUFFER_SIZE = 1 << 23;
+    static final int DEFAULT_CACHE_SIZE = 1 << 30;
+
+    final int bufferSize;
+    final int cacheSize;
+    final NonBlockingPool<ByteBuffer> bufferPool;
+
+    @JsonCreator
+    public Spec(
+        final @JsonProperty("bufferSize") @Nullable Integer bufferSize,
+        final @JsonProperty("cacheSize") @Nullable Integer cacheSize
+    )
+    {
+      this.bufferSize = bufferSize != null && bufferSize > 0 ? bufferSize : 
DEFAULT_BUFFER_SIZE;
+      this.cacheSize = cacheSize != null && cacheSize > this.bufferSize ? 
cacheSize : DEFAULT_CACHE_SIZE;
+      this.bufferPool = new StupidPool<>(
+          "Offheap incremental-index buffer pool",
+          this,
+          0,
+          this.cacheSize / this.bufferSize

Review comment:
       Removed




----------------------------------------------------------------
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]



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

Reply via email to