-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
- Loading branch information
1 parent
096c354
commit 91e1f2f
Showing
65 changed files
with
5,079 additions
and
702 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
server/src/main/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumerWrapper.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,40 @@ | ||
/* | ||
* 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.apache.lucene.codecs.lucene90; | ||
|
||
import org.apache.lucene.codecs.DocValuesConsumer; | ||
import org.apache.lucene.index.SegmentWriteState; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This class is an abstraction of the {@link DocValuesConsumer} for the Star Tree index structure. | ||
* It is responsible to consume various types of document values (numeric, binary, sorted, sorted numeric, | ||
* and sorted set) for fields in the Star Tree index. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class Lucene90DocValuesConsumerWrapper { | ||
|
||
private final Lucene90DocValuesConsumer lucene90DocValuesConsumer; | ||
|
||
public Lucene90DocValuesConsumerWrapper( | ||
SegmentWriteState state, | ||
String dataCodec, | ||
String dataExtension, | ||
String metaCodec, | ||
String metaExtension | ||
) throws IOException { | ||
lucene90DocValuesConsumer = new Lucene90DocValuesConsumer(state, dataCodec, dataExtension, metaCodec, metaExtension); | ||
} | ||
|
||
public Lucene90DocValuesConsumer getLucene90DocValuesConsumer() { | ||
return lucene90DocValuesConsumer; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
server/src/main/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducerWrapper.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,52 @@ | ||
/* | ||
* 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.apache.lucene.codecs.lucene90; | ||
|
||
import org.apache.lucene.codecs.DocValuesProducer; | ||
import org.apache.lucene.index.SegmentReadState; | ||
import org.apache.lucene.index.SortedNumericDocValues; | ||
import org.opensearch.index.codec.composite.DocValuesProvider; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This class is a custom abstraction of the {@link DocValuesProducer} for the Star Tree index structure. | ||
* It is responsible for providing access to various types of document values (numeric, binary, sorted, sorted numeric, | ||
* and sorted set) for fields in the Star Tree index. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class Lucene90DocValuesProducerWrapper implements DocValuesProvider { | ||
|
||
private final Lucene90DocValuesProducer lucene90DocValuesProducer; | ||
private final SegmentReadState state; | ||
|
||
public Lucene90DocValuesProducerWrapper( | ||
SegmentReadState state, | ||
String dataCodec, | ||
String dataExtension, | ||
String metaCodec, | ||
String metaExtension | ||
) throws IOException { | ||
lucene90DocValuesProducer = new Lucene90DocValuesProducer(state, dataCodec, dataExtension, metaCodec, metaExtension); | ||
this.state = state; | ||
} | ||
|
||
// returns the field doc id set iterator based on field name | ||
@Override | ||
public SortedNumericDocValues getSortedNumeric(String fieldName) throws IOException { | ||
return this.lucene90DocValuesProducer.getSortedNumeric(state.fieldInfos.fieldInfo(fieldName)); | ||
} | ||
|
||
@Override | ||
public DocValuesProducer getDocValuesProducer() { | ||
return lucene90DocValuesProducer; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
server/src/main/java/org/apache/lucene/index/SortedNumericDocValuesWriterWrapper.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,53 @@ | ||
/* | ||
* 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.apache.lucene.index; | ||
|
||
import org.apache.lucene.util.Counter; | ||
|
||
/** | ||
* A wrapper class for writing sorted numeric doc values. | ||
* <p> | ||
* This class provides a convenient way to add sorted numeric doc values to a field | ||
* and retrieve the corresponding {@link SortedNumericDocValues} instance. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class SortedNumericDocValuesWriterWrapper { | ||
|
||
private final SortedNumericDocValuesWriter sortedNumericDocValuesWriter; | ||
|
||
/** | ||
* Sole constructor. Constructs a new {@link SortedNumericDocValuesWriterWrapper} instance. | ||
* | ||
* @param fieldInfo the field information for the field being written | ||
* @param counter a counter for tracking memory usage | ||
*/ | ||
public SortedNumericDocValuesWriterWrapper(FieldInfo fieldInfo, Counter counter) { | ||
sortedNumericDocValuesWriter = new SortedNumericDocValuesWriter(fieldInfo, counter); | ||
} | ||
|
||
/** | ||
* Adds a value to the sorted numeric doc values for the specified document. | ||
* | ||
* @param docID the document ID | ||
* @param value the value to add | ||
*/ | ||
public void addValue(int docID, long value) { | ||
sortedNumericDocValuesWriter.addValue(docID, value); | ||
} | ||
|
||
/** | ||
* Returns the {@link SortedNumericDocValues} instance containing the sorted numeric doc values | ||
* | ||
* @return the {@link SortedNumericDocValues} instance | ||
*/ | ||
public SortedNumericDocValues getDocValues() { | ||
return sortedNumericDocValuesWriter.getDocValues(); | ||
} | ||
} |
87 changes: 0 additions & 87 deletions
87
server/src/main/java/org/opensearch/index/codec/composite/Composite99DocValuesReader.java
This file was deleted.
Oops, something went wrong.
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
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
38 changes: 38 additions & 0 deletions
38
server/src/main/java/org/opensearch/index/codec/composite/DocValuesProvider.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,38 @@ | ||
/* | ||
* 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.composite; | ||
|
||
import org.apache.lucene.codecs.DocValuesProducer; | ||
import org.apache.lucene.index.SortedNumericDocValues; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* An interface that provides access to document values for a specific field. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public interface DocValuesProvider { | ||
|
||
/** | ||
* Returns the sorted numeric document values for the specified field. | ||
* | ||
* @param fieldName The name of the field for which to retrieve the sorted numeric document values. | ||
* @return The sorted numeric document values for the specified field. | ||
* @throws IOException If an error occurs while retrieving the sorted numeric document values. | ||
*/ | ||
SortedNumericDocValues getSortedNumeric(String fieldName) throws IOException; | ||
|
||
/** | ||
* Returns the DocValuesProducer instance. | ||
* | ||
* @return The DocValuesProducer instance. | ||
*/ | ||
DocValuesProducer getDocValuesProducer(); | ||
} |
46 changes: 46 additions & 0 deletions
46
...er/src/main/java/org/opensearch/index/codec/composite/LuceneDocValuesConsumerFactory.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,46 @@ | ||
/* | ||
* 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.composite; | ||
|
||
import org.apache.lucene.codecs.DocValuesConsumer; | ||
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesConsumerWrapper; | ||
import org.apache.lucene.index.SegmentWriteState; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opensearch.index.codec.composite.composite99.Composite99Codec.COMPOSITE_INDEX_CODEC_NAME; | ||
|
||
/** | ||
* A factory class that provides a factory method for creating {@link DocValuesConsumer} instances | ||
* based on the specified composite codec. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class LuceneDocValuesConsumerFactory { | ||
|
||
public static DocValuesConsumer getDocValuesConsumerForCompositeCodec( | ||
String compositeCodec, | ||
SegmentWriteState state, | ||
String dataCodec, | ||
String dataExtension, | ||
String metaCodec, | ||
String metaExtension | ||
) throws IOException { | ||
|
||
switch (compositeCodec) { | ||
case COMPOSITE_INDEX_CODEC_NAME: | ||
return new Lucene90DocValuesConsumerWrapper(state, dataCodec, dataExtension, metaCodec, metaExtension) | ||
.getLucene90DocValuesConsumer(); | ||
default: | ||
throw new IllegalStateException("Invalid composite codec " + "[" + compositeCodec + "]"); | ||
} | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...er/src/main/java/org/opensearch/index/codec/composite/LuceneDocValuesProducerFactory.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,44 @@ | ||
/* | ||
* 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.composite; | ||
|
||
import org.apache.lucene.codecs.DocValuesConsumer; | ||
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducerWrapper; | ||
import org.apache.lucene.index.SegmentReadState; | ||
import org.opensearch.index.codec.composite.composite99.Composite99Codec; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A factory class that provides a factory method for creating {@link DocValuesConsumer} instances | ||
* based on the specified composite codec. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class LuceneDocValuesProducerFactory { | ||
|
||
public static DocValuesProvider getDocValuesProducerForCompositeCodec( | ||
String compositeCodec, | ||
SegmentReadState state, | ||
String dataCodec, | ||
String dataExtension, | ||
String metaCodec, | ||
String metaExtension | ||
) throws IOException { | ||
|
||
switch (compositeCodec) { | ||
case Composite99Codec.COMPOSITE_INDEX_CODEC_NAME: | ||
return new Lucene90DocValuesProducerWrapper(state, dataCodec, dataExtension, metaCodec, metaExtension); | ||
default: | ||
throw new IllegalStateException("Invalid composite codec " + "[" + compositeCodec + "]"); | ||
} | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.