forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add codec w hardcoded bkd leaf value as default
Signed-off-by: Peter Alfonsi <[email protected]>
- Loading branch information
Peter Alfonsi
committed
Jan 3, 2025
1 parent
7a0e8fb
commit 484ac00
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/opensearch/index/codec/leaf_size/ConfigurableBKDLeafSizeCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 org.opensearch.index.codec.leaf_size; | ||
|
||
import org.apache.lucene.codecs.FilterCodec; | ||
import org.apache.lucene.codecs.PointsFormat; | ||
import org.apache.lucene.codecs.lucene912.Lucene912Codec; | ||
import org.opensearch.common.settings.Setting; | ||
|
||
public class ConfigurableBKDLeafSizeCodec extends FilterCodec { | ||
|
||
public static final String CONFIGURABLE_BKD_LEAF_SIZE_CODEC_NAME = "ConfigurableBKDLeafSizeCodec"; | ||
|
||
public static final String BKD_MAX_POINTS_IN_LEAF_KEY = "bkd.max_leaf_points"; | ||
|
||
public static final Setting<Integer> BKD_MAX_POINTS_IN_LEAF_SETTING = Setting.intSetting( | ||
BKD_MAX_POINTS_IN_LEAF_KEY, | ||
512, | ||
Setting.Property.IndexScope | ||
); | ||
|
||
public ConfigurableBKDLeafSizeCodec() { | ||
super(CONFIGURABLE_BKD_LEAF_SIZE_CODEC_NAME, new Lucene912Codec()); | ||
} | ||
|
||
@Override | ||
public final PointsFormat pointsFormat() { | ||
return new LeafSizePointsFormat(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/opensearch/index/codec/leaf_size/LeafSizePointsFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 org.opensearch.index.codec.leaf_size; | ||
|
||
import org.apache.lucene.codecs.PointsFormat; | ||
import org.apache.lucene.codecs.PointsReader; | ||
import org.apache.lucene.codecs.PointsWriter; | ||
import org.apache.lucene.codecs.lucene90.Lucene90PointsReader; | ||
import org.apache.lucene.codecs.lucene90.Lucene90PointsWriter; | ||
import org.apache.lucene.index.SegmentReadState; | ||
import org.apache.lucene.index.SegmentWriteState; | ||
import org.apache.lucene.util.bkd.BKDWriter; | ||
import org.opensearch.common.settings.Setting; | ||
|
||
import java.io.IOException; | ||
|
||
public class LeafSizePointsFormat extends PointsFormat { | ||
|
||
public LeafSizePointsFormat() {} | ||
|
||
@Override | ||
public PointsWriter fieldsWriter(SegmentWriteState state) throws IOException { | ||
return new Lucene90PointsWriter(state, 1024, BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP); // TODO: Connect this to OpenSearch setting | ||
} | ||
|
||
@Override | ||
public PointsReader fieldsReader(SegmentReadState state) throws IOException { | ||
return new Lucene90PointsReader(state); | ||
} | ||
} |