Skip to content

Commit

Permalink
add time when reindexing lucenes
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Dec 4, 2024
1 parent aea8d1e commit 2c228ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public long getMeasure() {
return end - ini;
}

public long getMeasureMillis() {
return (end - ini) / 1_000_000;
}

public long stopAndGet() {
stop();
return getMeasure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.the_qa_company.qendpoint.core.hdt.HDTManager;
import com.the_qa_company.qendpoint.core.options.HDTOptions;
import com.the_qa_company.qendpoint.core.triples.TripleString;
import com.the_qa_company.qendpoint.core.util.StopWatch;
import com.the_qa_company.qendpoint.store.EndpointFiles;
import com.the_qa_company.qendpoint.store.EndpointStore;
import com.the_qa_company.qendpoint.store.exception.EndpointStoreException;
Expand Down Expand Up @@ -216,6 +217,26 @@ public NotifyingSail getSource() {
return source;
}

private void reindexSail(LuceneSail sail) {
// bypass filtering system to use the source
NotifyingSail oldSail = sail.getBaseSail();
try {
sail.setBaseSail(source);
String indexId = sail.getParameter(LuceneSail.INDEX_ID);
if (indexId == null || indexId.isEmpty()) {
indexId = "<no id>";
}
StopWatch sw = new StopWatch();
sw.reset();
logger.info("Reindexing sail {}", indexId);
sail.reindex();
sw.stop();
logger.info("Sail {} reindexed in {} ({}ms)", indexId, sw, sw.getMeasureMillis());
} finally {
sail.setBaseSail(oldSail);
}
}

/**
* reindex all the compiled lucene sails
*
Expand All @@ -225,19 +246,7 @@ public NotifyingSail getSource() {
public void reindexLuceneSails() throws SailException {
for (LuceneSail sail : luceneSails) {
// bypass filtering system to use the source
NotifyingSail oldSail = sail.getBaseSail();
try {
sail.setBaseSail(source);
String indexId = sail.getParameter(LuceneSail.INDEX_ID);
if (indexId == null || indexId.isEmpty()) {
indexId = "no id";
}
logger.info("Reindexing sail: {}", indexId);
sail.reindex();
} finally {
sail.setBaseSail(oldSail);
}

reindexSail(sail);
}
}

Expand All @@ -254,20 +263,7 @@ public void reindexLuceneSail(String index) throws SailException {
if (!index.equals(sail.getParameter(LuceneSail.INDEX_ID))) {
continue; // ignore
}
// bypass filtering system to use the source
NotifyingSail oldSail = sail.getBaseSail();
try {
sail.setBaseSail(source);
String indexId = sail.getParameter(LuceneSail.INDEX_ID);
if (indexId == null || indexId.isEmpty()) {
indexId = "no id";
}
logger.info("Reindexing sail: {}", indexId);
sail.reindex();
} finally {
sail.setBaseSail(oldSail);
}

reindexSail(sail);
}
}

Expand Down

0 comments on commit 2c228ce

Please sign in to comment.