public long copyUsingLengthPrefix(BytesRef bytes) {if (bytes.length >= 32768) {throw new IllegalArgumentException("max length is 32767 (got " + bytes.length + ")");}if (upto + bytes.length + 2 > blockSize) {if (bytes.length + 2 > blockSize) {throw new IllegalArgumentException("block size " + blockSize + " is too small to store length " + bytes.length + " bytes");}if (currentBlock != null) {addBlock(currentBlock);}currentBlock = new byte[blockSize];upto = 0;}final long pointer = getPointer();if (bytes.length < 128) {currentBlock[upto++] = (byte) bytes.length;} else {currentBlock[upto++] = (byte) (0x80 | (bytes.length >> 8));currentBlock[upto++] = (byte) (bytes.length & 0xff);}System.arraycopy(bytes.bytes, bytes.offset, currentBlock, upto, bytes.length);upto += bytes.length;return pointer;}

public long CopyUsingLengthPrefix(BytesRef bytes){if (bytes.Length >= 32768){throw new System.ArgumentException("max length is 32767 (got " + bytes.Length + ")");}if (upto + bytes.Length + 2 > blockSize){if (bytes.Length + 2 > blockSize){throw new System.ArgumentException("block size " + blockSize + " is too small to store length " + bytes.Length + " bytes");}if (currentBlock != null){blocks.Add(currentBlock);blockEnd.Add(upto);}currentBlock = new byte[blockSize];upto = 0;}long pointer = GetPointer();if (bytes.Length < 128){currentBlock[upto++] = (byte)bytes.Length;}else{currentBlock[upto++] = unchecked((byte)(0x80 | (bytes.Length >> 8)));currentBlock[upto++] = unchecked((byte)(bytes.Length & 0xff));}Array.Copy(bytes.Bytes, bytes.Offset, currentBlock, upto, bytes.Length);upto += bytes.Length;return pointer;}
