public override void AddProx(int numProx, DataInput positions, DataInput offsets) { Debug.Assert((CurField.HasPositions) == (positions != null)); Debug.Assert((CurField.HasOffsets) == (offsets != null)); if (CurField.HasPositions) { int posStart = CurField.PosStart + CurField.TotalPositions; if (posStart + numProx > PositionsBuf.Length) { PositionsBuf = ArrayUtil.Grow(PositionsBuf, posStart + numProx); } int position = 0; if (CurField.HasPayloads) { int payStart = CurField.PayStart + CurField.TotalPositions; if (payStart + numProx > PayloadLengthsBuf.Length) { PayloadLengthsBuf = ArrayUtil.Grow(PayloadLengthsBuf, payStart + numProx); } for (int i = 0; i < numProx; ++i) { int code = positions.ReadVInt(); if ((code & 1) != 0) { // this position has a payload int payloadLength = positions.ReadVInt(); PayloadLengthsBuf[payStart + i] = payloadLength; PayloadBytes.CopyBytes(positions, payloadLength); } else { PayloadLengthsBuf[payStart + i] = 0; } position += (int)((uint)code >> 1); PositionsBuf[posStart + i] = position; } } else { for (int i = 0; i < numProx; ++i) { position += ((int)((uint)positions.ReadVInt() >> 1)); PositionsBuf[posStart + i] = position; } } } if (CurField.HasOffsets) { int offStart = CurField.OffStart + CurField.TotalPositions; if (offStart + numProx > StartOffsetsBuf.Length) { int newLength = ArrayUtil.Oversize(offStart + numProx, 4); StartOffsetsBuf = Arrays.CopyOf(StartOffsetsBuf, newLength); LengthsBuf = Arrays.CopyOf(LengthsBuf, newLength); } int lastOffset = 0, startOffset, endOffset; for (int i = 0; i < numProx; ++i) { startOffset = lastOffset + offsets.ReadVInt(); endOffset = startOffset + offsets.ReadVInt(); lastOffset = endOffset; StartOffsetsBuf[offStart + i] = startOffset; LengthsBuf[offStart + i] = endOffset - startOffset; } } CurField.TotalPositions += numProx; }
public override void AddProx(int numProx, DataInput positions, DataInput offsets) { if (Debugging.AssertsEnabled) { Debugging.Assert((curField.hasPositions) == (positions != null)); Debugging.Assert((curField.hasOffsets) == (offsets != null)); } if (curField.hasPositions) { int posStart = curField.posStart + curField.totalPositions; if (posStart + numProx > positionsBuf.Length) { positionsBuf = ArrayUtil.Grow(positionsBuf, posStart + numProx); } int position = 0; if (curField.hasPayloads) { int payStart = curField.payStart + curField.totalPositions; if (payStart + numProx > payloadLengthsBuf.Length) { payloadLengthsBuf = ArrayUtil.Grow(payloadLengthsBuf, payStart + numProx); } for (int i = 0; i < numProx; ++i) { int code = positions.ReadVInt32(); if ((code & 1) != 0) { // this position has a payload int payloadLength = positions.ReadVInt32(); payloadLengthsBuf[payStart + i] = payloadLength; payloadBytes.CopyBytes(positions, payloadLength); } else { payloadLengthsBuf[payStart + i] = 0; } position += code.TripleShift(1); positionsBuf[posStart + i] = position; } } else { for (int i = 0; i < numProx; ++i) { position += positions.ReadVInt32().TripleShift(1); positionsBuf[posStart + i] = position; } } } if (curField.hasOffsets) { int offStart = curField.offStart + curField.totalPositions; if (offStart + numProx > startOffsetsBuf.Length) { int newLength = ArrayUtil.Oversize(offStart + numProx, 4); startOffsetsBuf = Arrays.CopyOf(startOffsetsBuf, newLength); lengthsBuf = Arrays.CopyOf(lengthsBuf, newLength); } int lastOffset = 0, startOffset, endOffset; for (int i = 0; i < numProx; ++i) { startOffset = lastOffset + offsets.ReadVInt32(); endOffset = startOffset + offsets.ReadVInt32(); lastOffset = endOffset; startOffsetsBuf[offStart + i] = startOffset; lengthsBuf[offStart + i] = endOffset - startOffset; } } curField.totalPositions += numProx; }