/** * Append the specified IEntryResult[] to the IEntryResult to create a single result representing * an index entry that was split across multiple index records. * * @param result * @param continuationResults * @param blockSize */ public static IEntryResult joinEntryResults( final IEntryResult result, final IEntryResult[] continuationResults, final int blockSize) { CoreArgCheck.isNotNull(result); // If the IEntryResult is not continued on another record, return the original char[] baseResult = result.getWord(); if (baseResult.length < blockSize || baseResult[blockSize - 1] != IndexConstants.RECORD_TYPE.RECORD_CONTINUATION) { return result; } // Extract the UUID string from the original result String baseStr = new String(baseResult); String objectID = extractUUIDString(result); // Create and initialize a StringBuffer to store the concatenated result StringBuffer sb = new StringBuffer(); sb.append(baseStr.substring(0, blockSize - 1)); // Append the continuation results onto the original - // assumes the IEntryResult[] are in ascending order of segment number final IEntryResult[] sortedResults = sortContinuationResults(objectID, continuationResults); for (int i = 0; i < sortedResults.length; i++) { char[] continuation = sortedResults[i].getWord(); int segNumber = getContinuationSegmentNumber(objectID, sortedResults[i]); int beginIndex = objectID.length() + Integer.toString(segNumber).length() + 5; for (int j = beginIndex; j < continuation.length; j++) { if (j < blockSize - 1) { sb.append(continuation[j]); } } } return new EntryResult(sb.toString().toCharArray(), result.getFileReferences()); }