/** * Crops the existing result file and extracts a subset from the given starting point to the * ending point. * * @param start the beginning of the subset. * @param length the end of the subset. * @return ResultSet a subset of the current result set. */ public ResultSet getResultSet(int start, int length) { length = length < docids.length ? length : docids.length; QueryResultSet resultSet = new QueryResultSet(length); resultSet.setExactResultSize(this.exactResultSize); System.arraycopy(docids, start, resultSet.getDocids(), 0, length); System.arraycopy(scores, start, resultSet.getScores(), 0, length); System.arraycopy(occurrences, start, resultSet.getOccurrences(), 0, length); return resultSet; }
/** * Extracts a subset of the resultset given by the list parameter, which contains a list of * <b>positions</b> in the resultset that should be saved. <br> * <b>NB:</b>The metadata hashtable is NOT reduced. * * @param positions int[] the list of elements in the current list that should be kept. * @return a subset of the current result set specified by the list. */ public ResultSet getResultSet(int[] positions) { int NewSize = positions.length; // if (logger.isDebugEnabled()) // logger.debug("New results size is "+NewSize); QueryResultSet resultSet = new QueryResultSet(NewSize); resultSet.setExactResultSize(this.exactResultSize); int newDocids[] = resultSet.getDocids(); double newScores[] = resultSet.getScores(); short newOccurs[] = resultSet.getOccurrences(); int thisPosition; for (int i = 0; i < NewSize; i++) { thisPosition = positions[i]; // if (logger.isDebugEnabled()) // logger.debug("adding result at "+i); newDocids[i] = docids[thisPosition]; newScores[i] = scores[thisPosition]; newOccurs[i] = occurrences[thisPosition]; } return resultSet; }