Skip to content

Commit

Permalink
Fix hashcode
Browse files Browse the repository at this point in the history
  • Loading branch information
nck-mlcnv committed Sep 5, 2024
1 parent f9ce17a commit 8e2a09c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ public QueryHandler(Config config) throws IOException {
querySource = createQuerySource(instancePath);
} else {
querySource = new StringListQuerySource(instances);
queryList = new FileBasedQueryList(querySource); // inMemQueryList would just store the queries in a list again
this.hashCode = queryList.hashCode();
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ public abstract class QuerySource {
* performance reasons, so that the hashcode does not have to be calculated every time it is needed.
* (It's needed everytime the id of a query is requested.)
*/
final protected int hashCode;
protected int hashCode;

public QuerySource(Path path) {
this.path = path;
this.hashCode = FileUtils.getHashcodeFromFileContent(path);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.aksw.iguana.cc.query.source.impl;

import org.aksw.iguana.cc.query.source.QuerySource;
import org.aksw.iguana.cc.utils.files.FileUtils;
import org.aksw.iguana.cc.utils.files.IndexedQueryReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -45,6 +46,7 @@ public FileSeparatorQuerySource(Path path) throws IOException {
public FileSeparatorQuerySource(Path path, String separator) throws IOException {
super(path);
iqr = getIqr(path, separator);
hashCode = FileUtils.getHashcodeFromFileContent(path);
}

private static IndexedQueryReader getIqr(Path path, String separator) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public InputStream getQueryStream(int index) throws IOException {
public List<String> getAllQueries() throws IOException {
return Collections.unmodifiableList(queries);
}

@Override
public int hashCode() {
return queries.hashCode();
}
}

0 comments on commit 8e2a09c

Please sign in to comment.