2727import org .apache .lucene .index .SortedNumericDocValues ;
2828import org .apache .lucene .index .SortedSetDocValues ;
2929import org .apache .lucene .index .TermsEnum ;
30+ import org .apache .lucene .internal .hppc .IntObjectHashMap ;
3031import org .apache .lucene .store .ByteArrayDataInput ;
3132import org .apache .lucene .store .ChecksumIndexInput ;
3233import org .apache .lucene .store .DataInput ;
4041import org .elasticsearch .core .IOUtils ;
4142
4243import java .io .IOException ;
43- import java .util .HashMap ;
44- import java .util .Map ;
4544
4645import static org .elasticsearch .index .codec .tsdb .ES87TSDBDocValuesFormat .TERMS_DICT_BLOCK_LZ4_SHIFT ;
4746
4847public class ES87TSDBDocValuesProducer extends DocValuesProducer {
49- private final Map < String , NumericEntry > numerics ;
50- private final Map < String , BinaryEntry > binaries ;
51- private final Map < String , SortedEntry > sorted ;
52- private final Map < String , SortedSetEntry > sortedSets ;
53- private final Map < String , SortedNumericEntry > sortedNumerics ;
48+ private final IntObjectHashMap < NumericEntry > numerics ;
49+ private final IntObjectHashMap < BinaryEntry > binaries ;
50+ private final IntObjectHashMap < SortedEntry > sorted ;
51+ private final IntObjectHashMap < SortedSetEntry > sortedSets ;
52+ private final IntObjectHashMap < SortedNumericEntry > sortedNumerics ;
5453 private final IndexInput data ;
5554 private final int maxDoc ;
5655 private final int version ;
5756 private final boolean merging ;
5857
5958 ES87TSDBDocValuesProducer (SegmentReadState state , String dataCodec , String dataExtension , String metaCodec , String metaExtension )
6059 throws IOException {
61- this .numerics = new HashMap <>();
62- this .binaries = new HashMap <>();
63- this .sorted = new HashMap <>();
64- this .sortedSets = new HashMap <>();
65- this .sortedNumerics = new HashMap <>();
60+ this .numerics = new IntObjectHashMap <>();
61+ this .binaries = new IntObjectHashMap <>();
62+ this .sorted = new IntObjectHashMap <>();
63+ this .sortedSets = new IntObjectHashMap <>();
64+ this .sortedNumerics = new IntObjectHashMap <>();
6665 this .maxDoc = state .segmentInfo .maxDoc ();
6766 this .merging = false ;
6867
@@ -123,11 +122,11 @@ public class ES87TSDBDocValuesProducer extends DocValuesProducer {
123122 }
124123
125124 private ES87TSDBDocValuesProducer (
126- Map < String , NumericEntry > numerics ,
127- Map < String , BinaryEntry > binaries ,
128- Map < String , SortedEntry > sorted ,
129- Map < String , SortedSetEntry > sortedSets ,
130- Map < String , SortedNumericEntry > sortedNumerics ,
125+ IntObjectHashMap < NumericEntry > numerics ,
126+ IntObjectHashMap < BinaryEntry > binaries ,
127+ IntObjectHashMap < SortedEntry > sorted ,
128+ IntObjectHashMap < SortedSetEntry > sortedSets ,
129+ IntObjectHashMap < SortedNumericEntry > sortedNumerics ,
131130 IndexInput data ,
132131 int maxDoc ,
133132 int version ,
@@ -151,13 +150,13 @@ public DocValuesProducer getMergeInstance() {
151150
152151 @ Override
153152 public NumericDocValues getNumeric (FieldInfo field ) throws IOException {
154- NumericEntry entry = numerics .get (field .name );
153+ NumericEntry entry = numerics .get (field .number );
155154 return getNumeric (entry , -1 );
156155 }
157156
158157 @ Override
159158 public BinaryDocValues getBinary (FieldInfo field ) throws IOException {
160- BinaryEntry entry = binaries .get (field .name );
159+ BinaryEntry entry = binaries .get (field .number );
161160 if (entry .docsWithFieldOffset == -2 ) {
162161 return DocValues .emptyBinary ();
163162 }
@@ -315,7 +314,7 @@ public boolean advanceExact(int target) throws IOException {
315314
316315 @ Override
317316 public SortedDocValues getSorted (FieldInfo field ) throws IOException {
318- SortedEntry entry = sorted .get (field .name );
317+ SortedEntry entry = sorted .get (field .number );
319318 return getSorted (entry );
320319 }
321320
@@ -671,13 +670,13 @@ public int docFreq() throws IOException {
671670
672671 @ Override
673672 public SortedNumericDocValues getSortedNumeric (FieldInfo field ) throws IOException {
674- SortedNumericEntry entry = sortedNumerics .get (field .name );
673+ SortedNumericEntry entry = sortedNumerics .get (field .number );
675674 return getSortedNumeric (entry , -1 );
676675 }
677676
678677 @ Override
679678 public SortedSetDocValues getSortedSet (FieldInfo field ) throws IOException {
680- SortedSetEntry entry = sortedSets .get (field .name );
679+ SortedSetEntry entry = sortedSets .get (field .number );
681680 if (entry .singleValueEntry != null ) {
682681 return DocValues .singleton (getSorted (entry .singleValueEntry ));
683682 }
@@ -756,15 +755,15 @@ private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
756755 }
757756 byte type = meta .readByte ();
758757 if (type == ES87TSDBDocValuesFormat .NUMERIC ) {
759- numerics .put (info .name , readNumeric (meta ));
758+ numerics .put (info .number , readNumeric (meta ));
760759 } else if (type == ES87TSDBDocValuesFormat .BINARY ) {
761- binaries .put (info .name , readBinary (meta ));
760+ binaries .put (info .number , readBinary (meta ));
762761 } else if (type == ES87TSDBDocValuesFormat .SORTED ) {
763- sorted .put (info .name , readSorted (meta ));
762+ sorted .put (info .number , readSorted (meta ));
764763 } else if (type == ES87TSDBDocValuesFormat .SORTED_SET ) {
765- sortedSets .put (info .name , readSortedSet (meta ));
764+ sortedSets .put (info .number , readSortedSet (meta ));
766765 } else if (type == ES87TSDBDocValuesFormat .SORTED_NUMERIC ) {
767- sortedNumerics .put (info .name , readSortedNumeric (meta ));
766+ sortedNumerics .put (info .number , readSortedNumeric (meta ));
768767 } else {
769768 throw new CorruptIndexException ("invalid type: " + type , meta );
770769 }
0 commit comments