public CachedOrds(OrdinalsSegmentReader source, int maxDoc){Offsets = new int[maxDoc + 1];int[] ords = new int[maxDoc]; long totOrds = 0;Int32sRef values = new Int32sRef(32);for (int docID = 0; docID < maxDoc; docID++){Offsets[docID] = (int)totOrds;source.Get(docID, values);long nextLength = totOrds + values.Length;if (nextLength > ords.Length){if (nextLength > ArrayUtil.MAX_ARRAY_LENGTH){throw new ThreadStateException("too many ordinals (>= " + nextLength + ") to cache");}ords = ArrayUtil.Grow(ords, (int)nextLength);}Array.Copy(values.Int32s, 0, ords, (int)totOrds, values.Length);totOrds = nextLength;}Offsets[maxDoc] = (int)totOrds;if ((double)totOrds / ords.Length < 0.9){this.Ordinals = new int[(int)totOrds];Array.Copy(ords, 0, this.Ordinals, 0, (int)totOrds);}else{this.Ordinals = ords;}}