-
Notifications
You must be signed in to change notification settings - Fork 142
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: John Mazanec <jmazane@amazon.com>
- Loading branch information
1 parent
833312f
commit f0a57c4
Showing
7 changed files
with
68 additions
and
12 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
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
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
55 changes: 55 additions & 0 deletions
55
...va/org/opensearch/knn/index/codec/derivedsource/DerivedSourceStoredFieldsFormatTests.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,55 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.codec.derivedsource; | ||
|
||
import lombok.SneakyThrows; | ||
import org.apache.lucene.codecs.Codec; | ||
import org.apache.lucene.codecs.lucene101.Lucene101Codec; | ||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.document.Field; | ||
import org.apache.lucene.document.TextField; | ||
import org.apache.lucene.index.DirectoryReader; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.index.IndexWriterConfig; | ||
import org.apache.lucene.index.SerialMergeScheduler; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.tests.index.RandomIndexWriter; | ||
import org.opensearch.knn.KNNTestCase; | ||
import org.opensearch.knn.index.codec.KNN10010Codec.KNN10010Codec; | ||
|
||
import static org.apache.lucene.codecs.lucene101.Lucene101Codec.Mode.BEST_COMPRESSION; | ||
|
||
public class DerivedSourceStoredFieldsFormatTests extends KNNTestCase { | ||
|
||
@SneakyThrows | ||
public void testCustomCodecDelegate() { | ||
// TODO: We need to replace this with a custom codec so that we can properly test. See | ||
// https://github.com/opensearch-project/custom-codecs/blob/main/src/main/java/org/opensearch/index/codec/customcodecs/Lucene912CustomCodec.java#L37 | ||
Codec codec = new KNN10010Codec(new Lucene101Codec(BEST_COMPRESSION), KNN10010Codec.DEFAULT_KNN_VECTOR_FORMAT, null); | ||
|
||
Directory dir = newFSDirectory(createTempDir()); | ||
IndexWriterConfig iwc = newIndexWriterConfig(); | ||
iwc.setMergeScheduler(new SerialMergeScheduler()); | ||
iwc.setCodec(codec); | ||
|
||
String fieldName = "test"; | ||
String randomString = randomAlphaOfLengthBetween(100, 1000); | ||
TextField basicTextField = new TextField(fieldName, randomString, Field.Store.YES); | ||
try (RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc)) { | ||
Document doc = new Document(); | ||
doc.add(basicTextField); | ||
writer.addDocument(doc); | ||
} | ||
|
||
try (IndexReader indexReader = DirectoryReader.open(dir)) { | ||
IndexSearcher searcher = new IndexSearcher(indexReader); | ||
Document doc = searcher.storedFields().document(0); | ||
assertEquals(randomString, doc.get(fieldName)); | ||
} | ||
dir.close(); | ||
} | ||
} |
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