This is an automated email from the ASF dual-hosted git repository.
xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 9f2a727722 Making mutable Index class pluggable. (#14609)
9f2a727722 is described below
commit 9f2a72772290e4f991ccbc46c4ec070c8df653df
Author: RAGHVENDRA KUMAR YADAV <[email protected]>
AuthorDate: Mon Dec 9 12:36:54 2024 -0800
Making mutable Index class pluggable. (#14609)
* Making mutable Index class pluggable.
* Making mutable Index class pluggable.
* Fixing build.
---
.../local/segment/index/map/MapIndexType.java | 20 +++++++++++++++++---
.../local/segment/index/map/MutableMapIndexImpl.java | 3 ++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MapIndexType.java
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MapIndexType.java
index c8a2ac4b09..00d83f9750 100644
---
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MapIndexType.java
+++
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MapIndexType.java
@@ -20,6 +20,7 @@
package org.apache.pinot.segment.local.segment.index.map;
import com.google.common.base.Preconditions;
+import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
@@ -55,6 +56,7 @@ public class MapIndexType extends
AbstractIndexType<MapIndexConfig, MapIndexRead
Collections.singletonList(V1Constants.Indexes.MAP_INDEX_FILE_EXTENSION);
private static final String MAP_INDEX_CREATOR_CLASS_NAME =
"mapIndexCreatorClassName";
private static final String MAP_INDEX_READER_CLASS_NAME =
"mapIndexReaderClassName";
+ private static final String MUTABLE_MAP_INDEX_CLASS_NAME =
"mutableMapIndexClassName";
protected MapIndexType() {
super(StandardIndexes.MAP_ID);
@@ -98,8 +100,8 @@ public class MapIndexType extends
AbstractIndexType<MapIndexConfig, MapIndexRead
String className =
indexConfig.getConfigs().get(MAP_INDEX_CREATOR_CLASS_NAME).toString();
Preconditions.checkNotNull(className, "MapIndexCreator class name must
be provided");
return (BaseMapIndexCreator) Class.forName(className)
- .getConstructor(String.class, String.class, MapIndexConfig.class)
- .newInstance(context.getIndexDir(),
context.getFieldSpec().getName(), indexConfig);
+ .getConstructor(File.class, String.class,
IndexCreationContext.class, MapIndexConfig.class)
+ .newInstance(context.getIndexDir(),
context.getFieldSpec().getName(), context, indexConfig);
}
throw new IllegalArgumentException("MapIndexCreator class name must be
provided");
}
@@ -166,6 +168,18 @@ public class MapIndexType extends
AbstractIndexType<MapIndexConfig, MapIndexRead
if (!context.getFieldSpec().isSingleValueField()) {
return null;
}
- return new MutableMapIndexImpl(config);
+
+ if (config.getConfigs().containsKey(MUTABLE_MAP_INDEX_CLASS_NAME)) {
+ String className =
config.getConfigs().get(MUTABLE_MAP_INDEX_CLASS_NAME).toString();
+ Preconditions.checkNotNull(className, "MutableMapIndex class name must
be provided");
+ try {
+ return (MutableIndex)
Class.forName(className).getConstructor(MutableIndexContext.class,
MapIndexConfig.class)
+ .newInstance(context, config);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create MutableMapIndex", e);
+ }
+ }
+
+ return new MutableMapIndexImpl(context, config);
}
}
diff --git
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MutableMapIndexImpl.java
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MutableMapIndexImpl.java
index c73dc9ecb3..7e1b160f60 100644
---
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MutableMapIndexImpl.java
+++
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/map/MutableMapIndexImpl.java
@@ -22,11 +22,12 @@ import java.io.IOException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.pinot.segment.spi.index.mutable.MutableIndex;
+import org.apache.pinot.segment.spi.index.mutable.provider.MutableIndexContext;
import org.apache.pinot.spi.config.table.MapIndexConfig;
public class MutableMapIndexImpl implements MutableIndex {
- public MutableMapIndexImpl(MapIndexConfig config) {
+ public MutableMapIndexImpl(MutableIndexContext context, MapIndexConfig
config) {
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]