@@ -73,6 +73,8 @@ final class ES819TSDBDocValuesConsumer extends XDocValuesConsumer {
7373 private final int minDocsPerOrdinalForOrdinalRangeEncoding ;
7474 final boolean enableOptimizedMerge ;
7575 private final int primarySortFieldNumber ;
76+ private final int numericBlockShift ;
77+ private final int numericBlockSize ;
7678 final SegmentWriteState state ;
7779 final BinaryDVCompressionMode binaryDVCompressionMode ;
7880 private final boolean enablePerBlockCompression ; // only false for testing
@@ -84,6 +86,7 @@ final class ES819TSDBDocValuesConsumer extends XDocValuesConsumer {
8486 int skipIndexIntervalSize ,
8587 int minDocsPerOrdinalForOrdinalRangeEncoding ,
8688 boolean enableOptimizedMerge ,
89+ int numericBlockShift ,
8790 String dataCodec ,
8891 String dataExtension ,
8992 String metaCodec ,
@@ -97,6 +100,9 @@ final class ES819TSDBDocValuesConsumer extends XDocValuesConsumer {
97100 this .minDocsPerOrdinalForOrdinalRangeEncoding = minDocsPerOrdinalForOrdinalRangeEncoding ;
98101 this .primarySortFieldNumber = ES819TSDBDocValuesProducer .primarySortFieldNumber (state .segmentInfo , state .fieldInfos );
99102 this .context = state .context ;
103+ this .numericBlockShift = numericBlockShift ;
104+ this .numericBlockSize = 1 << numericBlockShift ;
105+
100106 boolean success = false ;
101107 try {
102108 final String dataName = IndexFileNames .segmentFileName (state .segmentInfo .name , state .segmentSuffix , dataExtension );
@@ -108,6 +114,7 @@ final class ES819TSDBDocValuesConsumer extends XDocValuesConsumer {
108114 state .segmentInfo .getId (),
109115 state .segmentSuffix
110116 );
117+
111118 String metaName = IndexFileNames .segmentFileName (state .segmentInfo .name , state .segmentSuffix , metaExtension );
112119 meta = state .directory .createOutput (metaName , state .context );
113120 CodecUtil .writeIndexHeader (
@@ -117,6 +124,8 @@ final class ES819TSDBDocValuesConsumer extends XDocValuesConsumer {
117124 state .segmentInfo .getId (),
118125 state .segmentSuffix
119126 );
127+ meta .writeByte ((byte ) numericBlockShift );
128+
120129 maxDoc = state .segmentInfo .maxDoc ();
121130 this .skipIndexIntervalSize = skipIndexIntervalSize ;
122131 this .enableOptimizedMerge = enableOptimizedMerge ;
@@ -218,13 +227,13 @@ private long[] writeField(FieldInfo field, TsdbDocValuesProducer valuesProducer,
218227 indexWriter = DirectMonotonicWriter .getInstance (
219228 meta ,
220229 new ByteBuffersIndexOutput (indexOut , "temp-dv-index" , "temp-dv-index" ),
221- 1L + ((numValues - 1 ) >>> ES819TSDBDocValuesFormat . NUMERIC_BLOCK_SHIFT ),
230+ 1L + ((numValues - 1 ) >>> numericBlockShift ),
222231 ES819TSDBDocValuesFormat .DIRECT_MONOTONIC_BLOCK_SHIFT
223232 );
224233 meta .writeInt (DIRECT_MONOTONIC_BLOCK_SHIFT );
225- final long [] buffer = new long [ES819TSDBDocValuesFormat . NUMERIC_BLOCK_SIZE ];
234+ final long [] buffer = new long [numericBlockSize ];
226235 int bufferSize = 0 ;
227- final TSDBDocValuesEncoder encoder = new TSDBDocValuesEncoder (ES819TSDBDocValuesFormat . NUMERIC_BLOCK_SIZE );
236+ final TSDBDocValuesEncoder encoder = new TSDBDocValuesEncoder (numericBlockSize );
228237 values = valuesProducer .getSortedNumeric (field );
229238 final int bitsPerOrd = maxOrd >= 0 ? PackedInts .bitsRequired (maxOrd - 1 ) : -1 ;
230239 if (valuesProducer .mergeStats .supported () && numDocsWithValue < maxDoc ) {
@@ -240,7 +249,7 @@ private long[] writeField(FieldInfo field, TsdbDocValuesProducer valuesProducer,
240249 }
241250 for (int i = 0 ; i < count ; ++i ) {
242251 buffer [bufferSize ++] = values .nextValue ();
243- if (bufferSize == ES819TSDBDocValuesFormat . NUMERIC_BLOCK_SIZE ) {
252+ if (bufferSize == numericBlockSize ) {
244253 indexWriter .add (data .getFilePointer () - valuesDataOffset );
245254 if (maxOrd >= 0 ) {
246255 encoder .encodeOrdinals (buffer , data , bitsPerOrd );
@@ -254,7 +263,7 @@ private long[] writeField(FieldInfo field, TsdbDocValuesProducer valuesProducer,
254263 if (bufferSize > 0 ) {
255264 indexWriter .add (data .getFilePointer () - valuesDataOffset );
256265 // Fill unused slots in the block with zeroes rather than junk
257- Arrays .fill (buffer , bufferSize , ES819TSDBDocValuesFormat . NUMERIC_BLOCK_SIZE , 0L );
266+ Arrays .fill (buffer , bufferSize , numericBlockSize , 0L );
258267 if (maxOrd >= 0 ) {
259268 encoder .encodeOrdinals (buffer , data , bitsPerOrd );
260269 } else {
0 commit comments