Skip to content

Commit

Permalink
attempt at fixing spi
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Alfonsi <[email protected]>
  • Loading branch information
Peter Alfonsi committed Jan 8, 2025
1 parent 0e02c73 commit 9be42f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.util.bkd.BKDWriter;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;

import java.io.IOException;

/**
* Codec exposing configurable maxPointsInLeafNode for BKD trees.
*/
public class ConfigurableBKDLeafSizeCodec extends FilterCodec {

public static final String CONFIGURABLE_BKD_LEAF_SIZE_CODEC_NAME = "ConfigurableBKDLeafSizeCodec";
Expand All @@ -36,6 +40,13 @@ public class ConfigurableBKDLeafSizeCodec extends FilterCodec {

private final int maxPointsInLeafNode;

// May be needed for SPI. Hopefully this not actually invoked on running, as if so there's not a good way to pass the actual setting value
// I think it is ok, bc the no-arg constructor for Composite912Codec uses null for mapperService,
// but I know from debugging the mapperService isn't null at lease
public ConfigurableBKDLeafSizeCodec() {
this(BKD_MAX_POINTS_IN_LEAF_SETTING.getDefault(Settings.EMPTY));
}

public ConfigurableBKDLeafSizeCodec(int maxPointsInLeafNode) {
super(CONFIGURABLE_BKD_LEAF_SIZE_CODEC_NAME, new Lucene912Codec());
this.maxPointsInLeafNode = maxPointsInLeafNode;
Expand All @@ -46,6 +57,9 @@ public final PointsFormat pointsFormat() {
return new LeafSizePointsFormat(maxPointsInLeafNode);
}

/**
* Custom PointsFormat which uses a PointsWriter with configurable maxPointsInLeafNode.
*/
public static class LeafSizePointsFormat extends PointsFormat {

private final int maxPointsInLeafNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/**
* Package for configurable leaf size codec in BKD trees.
*/
package org.opensearch.index.codec.leaf_size;

0 comments on commit 9be42f9

Please sign in to comment.