public static byte[] copyContent(ByteArrayPointable bytePtr) { return Arrays.copyOfRange(bytePtr.getByteArray(), bytePtr.getContentStartOffset(), bytePtr.getContentStartOffset() + bytePtr.getContentLength()); }
@Override public int hash() { if (hash == 0) { int h = 0; int realLength = getContentLength(); int startOffset = getContentStartOffset(); for (int i = 0; i < realLength; ++i) { h = 31 * h + bytes[startOffset + i]; } hash = h; } return hash; }
@Override public int compareTo(byte[] thatBytes, int thatStart, int thatLength) { int thisArrayLen = getContentLength(this.bytes, this.start); int thatArrayLen = getContentLength(thatBytes, thatStart); int thisArrayStart = this.getContentStartOffset(); int thatArrayStart = thatStart + getNumberBytesToStoreMeta(thatArrayLen); for (int thisIndex = 0, thatIndex = 0; thisIndex < thisArrayLen && thatIndex < thatArrayLen; ++thisIndex, ++thatIndex) { if (this.bytes[thisArrayStart + thisIndex] != thatBytes[thatArrayStart + thatIndex]) { return (0xff & this.bytes[thisArrayStart + thisIndex]) - (0xff & thatBytes[thatArrayStart + thatIndex]); } } return thisArrayLen - thatArrayLen; }
@Override public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException { resultStorage.reset(); for (int i = 0; i < pointables.length; ++i) { evaluators[i].evaluate(tuple, pointables[i]); } int fromOffset = getFromOffset(tuple); ATypeTag textTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0].getStartOffset()]]; ATypeTag wordTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1].getStartOffset()]]; checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag); textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1, pointables[0].getLength() - 1); wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1, pointables[1].getLength() - 1); int pos = indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(), textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(), wordPtr.getContentLength(), fromOffset); result.setValue(pos < 0 ? pos : pos + baseOffset); intSerde.serialize(result, dataOutput); resultPointable.set(resultStorage); }
dataOutput.write(metaBuffer, 0, metaLength); dataOutput.write(byteArrayPointable.getByteArray(), byteArrayPointable.getContentStartOffset() + subStart, subLength); } catch (IOException e) {