You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/01/28 11:34:57 UTC

[GitHub] [druid] pjain1 commented on a change in pull request #10001: [Extension] oak-incremental-index: Low resource (RAM and CPU) incremental-index implementation using off-heap key/value map (OakMap)

pjain1 commented on a change in pull request #10001:
URL: https://github.com/apache/druid/pull/10001#discussion_r794428013



##########
File path: extensions-contrib/oak-incremental-index/src/main/java/org/apache/druid/segment/incremental/oak/OakIncrementalIndexSpec.java
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.segment.incremental.oak;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.segment.incremental.AppendableIndexSpec;
+import org.apache.druid.utils.JvmUtils;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Oak incremental index spec (describes the in-memory indexing method for data ingestion).
+ */
+public class OakIncrementalIndexSpec implements AppendableIndexSpec
+{
+  public static final String TYPE = "oak";
+
+  final long oakMaxMemoryCapacity;
+  final int oakBlockSize;
+  final int oakChunkMaxItems;
+
+  @JsonCreator
+  public OakIncrementalIndexSpec(
+      final @JsonProperty("oakMaxMemoryCapacity") @Nullable Long oakMaxMemoryCapacity,
+      final @JsonProperty("oakBlockSize") @Nullable Integer oakBlockSize,
+      final @JsonProperty("oakChunkMaxItems") @Nullable Integer oakChunkMaxItems
+  )
+  {
+    this.oakMaxMemoryCapacity = oakMaxMemoryCapacity != null && oakMaxMemoryCapacity > 0 ? oakMaxMemoryCapacity :
+        OakIncrementalIndex.Builder.DEFAULT_OAK_MAX_MEMORY_CAPACITY;
+    this.oakBlockSize = oakBlockSize != null && oakBlockSize > 0 ? oakBlockSize :
+        OakIncrementalIndex.Builder.DEFAULT_OAK_BLOCK_SIZE;
+    this.oakChunkMaxItems = oakChunkMaxItems != null && oakChunkMaxItems > 0 ? oakChunkMaxItems :
+        OakIncrementalIndex.Builder.DEFAULT_OAK_CHUNK_MAX_ITEMS;
+  }
+
+  @JsonProperty
+  public long getOakMaxMemoryCapacity()
+  {
+    return oakMaxMemoryCapacity;
+  }
+
+  @JsonProperty
+  public int getOakBlockSize()
+  {
+    return oakBlockSize;
+  }
+
+  @JsonProperty
+  public int getOakChunkMaxItems()
+  {
+    return oakChunkMaxItems;
+  }
+
+  @Nonnull
+  @Override
+  public OakIncrementalIndex.Builder builder()
+  {
+    return new OakIncrementalIndex.Builder()
+        .setOakMaxMemoryCapacity(oakMaxMemoryCapacity)
+        .setOakBlockSize(oakBlockSize)
+        .setOakChunkMaxItems(oakChunkMaxItems);
+  }
+
+  @Override
+  public long getDefaultMaxBytesInMemory()
+  {
+    // Oak allocates its keys/values directly so the JVM off-heap limitations does not apply on it.
+    // Yet, we want to respect these values if the user did not specify any specific limitation.
+    // In the realtime node, the entire JVM's direct memory is utilized for ingestion and persist operations.
+    // But maxBytesInMemory only refers to the active index size and not to the index being flushed to disk and the
+    // persist-buffer.
+    // To account for that, we set default to 1/2 of the max jvm's direct memory.
+    return JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes() / 2;

Review comment:
       this will throw exception with newer versions of Java, whats a good default in that case ?

##########
File path: extensions-contrib/oak-incremental-index/pom.xml
##########
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.druid.extensions</groupId>

Review comment:
       `org.apache.druid.extensions` -> `org.apache.druid.extensions.contrib`

##########
File path: benchmarks/pom.xml
##########
@@ -186,6 +186,12 @@
       <version>${project.parent.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.druid.extensions</groupId>

Review comment:
       `org.apache.druid.extensions` -> `org.apache.druid.extensions.contrib`




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

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org