/** * Gets the length of the string in characters. * The first time call will need to go through the entire string, the following call will just return the pre-caculated result * * @return length of string in characters */ public int getStringLength() { if (stringLength < 0) { stringLength = UTF8StringUtil.getStringLength(bytes, start); } return stringLength; }
public int UTF8StringEditDistance(byte[] bytesLeft, int fsStart, byte[] bytesRight, int ssStart, int edThresh) throws HyracksDataException { int fsStrLen = UTF8StringUtil.getStringLength(bytesLeft, fsStart); int ssStrLen = UTF8StringUtil.getStringLength(bytesRight, ssStart); // length filter if (Math.abs(fsStrLen - ssStrLen) > edThresh) { return SIMILARITY_THRESHOLD_NOT_SATISFIED_VALUE; } int ed = getActualUTF8StringEditDistanceVal(bytesLeft, fsStart, bytesRight, ssStart, edThresh); if (ed > edThresh || ed < 0) { return SIMILARITY_THRESHOLD_NOT_SATISFIED_VALUE; } else { return ed; } }
@Override public void reset(byte[] data, int startOff) throws HyracksDataException { this.data = data; this.startOffset = startOff; this.length = UTF8StringUtil.getStringLength(data, startOffset); this.utfByteLength = UTF8StringUtil.getUTFLength(data, startOffset); this.metaLength = UTF8StringUtil.getNumBytesToStoreLength(utfByteLength); reset(); }
int cFieldLength = UTF8StringUtil.getStringLength(baaos.getByteArray(), serializedFieldNameOffsets[fIndex]); if (fieldNameComparator.compare(baaos.getByteArray(), serializedFieldNameOffsets[fIndex], cFieldLength, bytes, start, length) == 0) {
@Test public void testGetStringLength() throws Exception { byte[] buffer = writeStringToBytes(STRING_UTF8_MIX); assertEquals(STRING_UTF8_MIX.length(), getStringLength(buffer, 0)); }
for (int i = 0; i < fieldNames.length; i++) { int j = getFieldIndex(baaos.getByteArray(), serializedFieldNameOffsets[i], UTF8StringUtil.getStringLength(baaos.getByteArray(), serializedFieldNameOffsets[i])); if (j != i) { throw new RuntimeDataException(ErrorCode.DUPLICATE_FIELD_NAME, fieldNames[i]);