Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie authored and sarthakaggarwal97 committed Jul 5, 2024
1 parent 1ad4231 commit 910e863
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.opensearch.common.Nullable;
import org.opensearch.common.collect.MapBuilder;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.codec.composite.Composite99Codec;
import org.opensearch.index.codec.composite.CompositeCodecFactory;
import org.opensearch.index.mapper.MapperService;

import java.util.Map;
Expand Down Expand Up @@ -78,10 +78,8 @@ public CodecService(@Nullable MapperService mapperService, IndexSettings indexSe
// We can still support all the compression codecs when composite index is present
// hence we're defining the codecs like below
if (mapperService.isCompositeIndexPresent()) {
codecs.put(DEFAULT_CODEC, new Composite99Codec(Mode.BEST_SPEED, mapperService, logger));
codecs.put(LZ4, new Composite99Codec(Mode.BEST_SPEED, mapperService, logger));
codecs.put(BEST_COMPRESSION_CODEC, new Composite99Codec(Mode.BEST_COMPRESSION, mapperService, logger));
codecs.put(ZLIB, new Composite99Codec(Mode.BEST_COMPRESSION, mapperService, logger));
CompositeCodecFactory compositeCodecFactory = new CompositeCodecFactory();
codecs.putAll(compositeCodecFactory.getCompositeCodecs(mapperService, logger));
} else {
codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger));
codecs.put(LZ4, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ public DocValuesConsumer fieldsConsumer(SegmentWriteState state) throws IOExcept

@Override
public DocValuesProducer fieldsProducer(SegmentReadState state) throws IOException {
return new Composite90DocValuesReader(delegate.fieldsProducer(state), state, mapperService);
return new Composite90DocValuesReader(delegate.fieldsProducer(state), state);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
@ExperimentalApi
public class Composite90DocValuesReader extends DocValuesProducer implements CompositeIndexReader {
private DocValuesProducer delegate;
Set<CompositeMappedFieldType> compositeMappedFieldTypes;
MapperService mapperService;

public Composite90DocValuesReader(DocValuesProducer producer, SegmentReadState state, MapperService mapperService) throws IOException {
public Composite90DocValuesReader(DocValuesProducer producer, SegmentReadState state) throws IOException {
this.delegate = producer;
this.mapperService = mapperService;
this.compositeMappedFieldTypes = mapperService.getCompositeFieldTypes();
// TODO : read star tree files
}

Expand Down Expand Up @@ -82,13 +78,14 @@ public void close() throws IOException {
@Override
public List<String> getCompositeIndexFields() {
// todo : read from file formats and get the field names.
return null;
throw new UnsupportedOperationException();

}

@Override
public CompositeIndexValues getCompositeIndexValues(String field, CompositeMappedFieldType.CompositeFieldType fieldType)
throws IOException {
// TODO : read compositeIndexValues [starTreeValues] from star tree files
return null;
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 java.util.HashMap;
import java.util.Map;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene99.Lucene99Codec;
import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.index.mapper.MapperService;

import static org.opensearch.index.codec.CodecService.BEST_COMPRESSION_CODEC;
import static org.opensearch.index.codec.CodecService.DEFAULT_CODEC;
import static org.opensearch.index.codec.CodecService.LZ4;
import static org.opensearch.index.codec.CodecService.ZLIB;


/**
* Factory class to return the latest composite codec for all the modes
*
* @opensearch.experimental
*/
@ExperimentalApi
public class CompositeCodecFactory {
public CompositeCodecFactory() {}

public Map<String,Codec> getCompositeCodecs(MapperService mapperService, Logger logger) {
Map<String, Codec> codecs = new HashMap<>();
codecs.put(DEFAULT_CODEC, new Composite99Codec(Lucene99Codec.Mode.BEST_SPEED, mapperService, logger));
codecs.put(LZ4, new Composite99Codec(Lucene99Codec.Mode.BEST_SPEED, mapperService, logger));
codecs.put(BEST_COMPRESSION_CODEC, new Composite99Codec(Lucene99Codec.Mode.BEST_COMPRESSION, mapperService, logger));
codecs.put(ZLIB, new Composite99Codec(Lucene99Codec.Mode.BEST_COMPRESSION, mapperService, logger));
return codecs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import org.opensearch.common.annotation.ExperimentalApi;

/**
* Abstract class for composite index values
* Interface for composite index values
*
* @opensearch.experimental
*/
@ExperimentalApi
public abstract class CompositeIndexValues {
public abstract CompositeIndexValues getValues();
public interface CompositeIndexValues {
CompositeIndexValues getValues();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @opensearch.experimental
*/
@ExperimentalApi
public class StarTreeValues extends CompositeIndexValues {
public class StarTreeValues implements CompositeIndexValues {
private final List<String> dimensionsOrder;

// TODO : come up with full set of vales such as dimensions and metrics doc values + star tree
Expand Down

0 comments on commit 910e863

Please sign in to comment.