Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions core/src/main/java/overflowdb/ReferenceManager.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package overflowdb;

import overflowdb.storage.OdbStorage;
import overflowdb.util.NamedThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import overflowdb.storage.OdbStorage;
import overflowdb.util.NamedThreadFactory;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -83,8 +83,8 @@ private void syncClearReferences(final int releaseCount) {
if (!refsToClear.isEmpty()) {
safelyClearReferences(refsToClear);
if (logger.isInfoEnabled()) logger.info("completed clearing of " + refsToClear.size() + " references");
if (logger.isDebugEnabled()) logger.debug("current clearable queue size: " + clearableRefs.size());
if (logger.isDebugEnabled()) logger.debug("references cleared in total: " + totalReleaseCount);
if (logger.isDebugEnabled()) logger.debug("remaining clearable references: " + clearableRefs.size());
if (logger.isTraceEnabled()) logger.trace("references cleared in total: " + totalReleaseCount);
}
}

Expand Down Expand Up @@ -161,17 +161,26 @@ private static SerializedNode serializeReference(NodeRef ref) {
return null;
}


/**
* writes all references to disk overflow, blocks until complete.
* useful when saving the graph
*/
public void clearAllReferences() {
int initialRefCount = clearableRefs.size();
int clearedCount = 0;
while (!clearableRefs.isEmpty()) {
int clearableRefsSize = clearableRefs.size();
logger.info("clearing all (" + clearableRefsSize + ") references - this may take some time");
try {
syncClearReferences(clearableRefsSize);
final List<NodeRef> refsToClear = collectRefsToClear(releaseCount);
if (!refsToClear.isEmpty()) {
int clearCountCurr = refsToClear.size();
safelyClearReferences(refsToClear);
clearedCount += clearCountCurr;
}

if (logger.isInfoEnabled()) {
float progressPercent = 100f * clearedCount / initialRefCount;
logger.info(String.format("progress of clearing references: %.2f%s", Float.min(100f, progressPercent), "%"));
}
} catch (Exception e) {
throw new RuntimeException("error while clearing references to disk", e);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/overflowdb/storage/OdbStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public <A extends Node> A readNode(final long id) throws IOException {
/** flush any remaining changes in underlying storage to disk */
public void flush() {
if (mvstore != null) {
logger.debug("flushing to disk");
logger.trace("flushing to disk");
mvstore.commit();
}
}
Expand Down