Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ private static BlockLoader blockLoader(String name) {
Lucene.KEYWORD_ANALYZER,
Lucene.KEYWORD_ANALYZER,
new KeywordFieldMapper.Builder(name, IndexVersion.current()).docValues(ft.docValuesType() != DocValuesType.NONE),
syntheticSource
syntheticSource,
false
).blockLoader(new MappedFieldType.BlockLoaderContext() {
@Override
public String indexName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.common.logging.LogConfigurator;
import org.elasticsearch.index.codec.Elasticsearch92Lucene103Codec;
import org.elasticsearch.index.codec.tsdb.BinaryDVCompressionMode;
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesFormat;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
Expand Down Expand Up @@ -257,7 +258,7 @@ private static IndexWriterConfig createIndexWriterConfig(boolean optimizedMergeE
);
config.setLeafSorter(DataStream.TIMESERIES_LEAF_READERS_SORTER);
config.setMergePolicy(new LogByteSizeMergePolicy());
var docValuesFormat = new ES819TSDBDocValuesFormat(4096, 512, optimizedMergeEnabled);
var docValuesFormat = new ES819TSDBDocValuesFormat(4096, 512, optimizedMergeEnabled, BinaryDVCompressionMode.COMPRESSED_WITH_LZ4);
config.setCodec(new Elasticsearch92Lucene103Codec() {
@Override
public DocValuesFormat getDocValuesFormatForField(String field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ public void testBlockLoaderDoesNotUseSyntheticSourceDelegateWhenIgnoreAboveIsSet
mock(NamedAnalyzer.class),
mock(NamedAnalyzer.class),
builder,
true
true,
false
);

MatchOnlyTextFieldMapper.MatchOnlyTextFieldType ft = new MatchOnlyTextFieldMapper.MatchOnlyTextFieldType(
Expand Down Expand Up @@ -346,7 +347,8 @@ public void testBlockLoaderDoesNotUseSyntheticSourceDelegateWhenIgnoreAboveIsSet
mock(NamedAnalyzer.class),
mock(NamedAnalyzer.class),
builder,
true
true,
false
);

MatchOnlyTextFieldMapper.MatchOnlyTextFieldType ft = new MatchOnlyTextFieldMapper.MatchOnlyTextFieldType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
if (IndexSettings.DOC_VALUES_SKIPPER) {
settings.add(IndexSettings.USE_DOC_VALUES_SKIPPER);
}
settings.add(IndexSettings.USE_BINARY_DOC_VALUES);
settings.add(IndexSettings.INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING);
BUILT_IN_INDEX_SETTINGS = Collections.unmodifiableSet(settings);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ public boolean isES87TSDBCodecEnabled() {
Property.Final
);

public static final Setting<Boolean> USE_BINARY_DOC_VALUES = Setting.boolSetting(
"index.mapping.use_binary_doc_values",
false,
Property.IndexScope,
Property.Final
);

/**
* The {@link IndexMode "mode"} of the index.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.codec.bloomfilter.ES87BloomFilterPostingsFormat;
import org.elasticsearch.index.codec.postings.ES812PostingsFormat;
import org.elasticsearch.index.codec.tsdb.BinaryDVCompressionMode;
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesFormat;
import org.elasticsearch.index.mapper.CompletionFieldMapper;
import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.index.mapper.KeywordFieldMapper;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
Expand Down Expand Up @@ -57,7 +59,10 @@ public class PerFieldFormatSupplier {

private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat();
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat();
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat(BinaryDVCompressionMode.NO_COMPRESS);
private static final DocValuesFormat compressedBinaryDocValuesFormat = new ES819TSDBDocValuesFormat(
BinaryDVCompressionMode.COMPRESSED_WITH_LZ4
);
private static final ES812PostingsFormat es812PostingsFormat = new ES812PostingsFormat();
private static final PostingsFormat completionPostingsFormat = PostingsFormat.forName("Completion101");

Expand Down Expand Up @@ -127,6 +132,13 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
}

public DocValuesFormat getDocValuesFormatForField(String field) {
if (mapperService != null) {
Mapper mapper = mapperService.mappingLookup().getMapper(field);
if (mapper != null && KeywordFieldMapper.CONTENT_TYPE.equals(mapper.typeName())) {
return compressedBinaryDocValuesFormat;
}
}

if (useTSDBDocValuesFormat(field)) {
return tsdbDocValuesFormat;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.index.codec.tsdb;

public enum BinaryDVCompressionMode {

NO_COMPRESS((byte) 0),
COMPRESSED_WITH_LZ4((byte) 1);

public final byte code;

BinaryDVCompressionMode(byte code) {
this.code = code;
}

public static BinaryDVCompressionMode fromMode(byte mode) {
return switch (mode) {
case 0 -> NO_COMPRESS;
case 1 -> COMPRESSED_WITH_LZ4;
default -> throw new IllegalStateException("unknown compression mode [" + mode + "]");
};
}
}
Loading