optimized QueryGoal (reducing mem and computation by removing all_hashes)

- all_hashes used for text highlighting and word distance computation which can be done with include_hashes only
pull/1/head
reger 11 years ago
parent f106345eef
commit 29967102a2

@ -609,7 +609,7 @@ public class IndexControlRWIs_p {
final Bitfield filter) {
final HandleSet queryhashes = QueryParams.hashes2Set(ASCII.String(keyhash));
final QueryGoal qg = new QueryGoal(queryhashes, null, queryhashes);
final QueryGoal qg = new QueryGoal(queryhashes, null);
final QueryParams query = new QueryParams(
qg,
new QueryModifier(),

@ -222,7 +222,7 @@ public final class search {
if (query.isEmpty() && abstractSet != null) {
// this is _not_ a normal search, only a request for index abstracts
final Segment indexSegment = sb.index;
QueryGoal qg = new QueryGoal(abstractSet, new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0), abstractSet);
QueryGoal qg = new QueryGoal(abstractSet, new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0));
theQuery = new QueryParams(
qg,
modifier,
@ -286,7 +286,7 @@ public final class search {
RowHandleSet allHashes = new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0);
try {allHashes.putAll(queryhashes);} catch (final SpaceExceededException e) {}
try {allHashes.putAll(excludehashes);} catch (final SpaceExceededException e) {}
QueryGoal qg = new QueryGoal(queryhashes, excludehashes, allHashes);
QueryGoal qg = new QueryGoal(queryhashes, excludehashes);
theQuery = new QueryParams(
qg,
modifier,

@ -524,7 +524,7 @@ public class yacysearch {
// the query
final QueryGoal qg = new QueryGoal(originalquerystring, querystring.trim());
final int maxDistance = (querystring.indexOf('"', 0) >= 0) ? qg.getAllHashes().size() - 1 : Integer.MAX_VALUE;
final int maxDistance = (querystring.indexOf('"', 0) >= 0) ? qg.getIncludeHashes().size() - 1 : Integer.MAX_VALUE;
// filter out stopwords
final SortedSet<String> filtered = SetTools.joinConstructiveByTest(qg.getIncludeStrings(), Switchboard.stopwords); //find matching stopwords

@ -49,12 +49,12 @@ public class QueryGoal {
private static String seps = ".,/&_";
private String query_original;
private HandleSet include_hashes, exclude_hashes, all_hashes;
private HandleSet include_hashes, exclude_hashes;
private final ArrayList<String> include_words, exclude_words, all_words;
private final ArrayList<String> include_strings, exclude_strings, all_strings;
public QueryGoal(HandleSet include_hashes, HandleSet exclude_hashes, HandleSet all_hashes) {
public QueryGoal(HandleSet include_hashes, HandleSet exclude_hashes) {
this.query_original = null;
this.include_words = new ArrayList<String>();
this.exclude_words = new ArrayList<String>();
@ -64,7 +64,6 @@ public class QueryGoal {
this.all_strings = new ArrayList<String>();
this.include_hashes = include_hashes;
this.exclude_hashes = exclude_hashes;
this.all_hashes = all_hashes;
}
public QueryGoal(String query_original, String query_words) {
@ -99,7 +98,6 @@ public class QueryGoal {
this.include_hashes = null;
this.exclude_hashes = null;
this.all_hashes = null;
}
@ -172,12 +170,7 @@ public class QueryGoal {
if (exclude_hashes == null) exclude_hashes = Word.words2hashesHandles(exclude_words);
return exclude_hashes;
}
public HandleSet getAllHashes() {
if (all_hashes == null) all_hashes = Word.words2hashesHandles(all_words);
return all_hashes;
}
public ArrayList<String> getIncludeStrings() {
return include_strings;
}

@ -382,7 +382,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
* @return line with marked words
*/
public String getLineMarked(final QueryGoal queryGoal) {
final HandleSet queryHashes = queryGoal.getAllHashes();
final HandleSet queryHashes = queryGoal.getIncludeHashes();
if (this.line == null) {
return "";
}

Loading…
Cancel
Save