use of org.sirix.diff.DiffFactory.DiffOptimized in project sirix by sirixdb.
the class TraverseCompareTree method call.
@Override
public Void call() {
final long startTime = System.nanoTime();
LOGWRAPPER.debug("Build sunburst items.");
try {
firePropertyChange("progress", null, 0);
// Invoke diff.
LOGWRAPPER.debug("CountDownLatch: " + mStart.getCount());
POOL.submit(new Callable<Void>() {
@Override
public Void call() throws SirixException {
DiffOptimized optimized = DiffOptimized.NO;
if (mPrune == Pruning.DIFF || mPrune == Pruning.DIFF_WITHOUT_SAMEHASHES) {
optimized = DiffOptimized.HASHED;
}
DiffFactory.invokeStructuralDiff(new DiffFactory.Builder(mDb.getSession(), mNewRevision, mOldRtx.getRevisionNumber(), optimized, ImmutableSet.of(mObserver)).setNewDepth(mDepth).setOldDepth(mDepth).setNewStartKey(mNewStartKey).setOldStartKey(mOldStartKey));
return null;
}
});
if (PROCESSORS == 2) {
final ExecutorService pool = Executors.newSingleThreadExecutor();
mDepthMax = pool.submit(new Callable<Integer>() {
@Override
public Integer call() {
// Maximum depth in old revision.
return getDepthMax();
}
}).get();
pool.shutdown();
} else {
mDepthMax = POOL.submit(new Callable<Integer>() {
@Override
public Integer call() {
// Maximum depth in old revision.
return getDepthMax();
}
}).get();
}
// Wait for diff list to complete.
final boolean done = mStart.await(TIMEOUT_S, TimeUnit.SECONDS);
if (!done) {
LOGWRAPPER.error("Diff failed - Timeout occured after " + TIMEOUT_S + " seconds!");
}
final int size = mDiffs.size();
if (mEntries > DIFF_THRESHOLD) {
final int mapSize = mDiffDatabase.getMap().size();
LOGWRAPPER.debug("mapSize: " + mapSize);
}
LOGWRAPPER.debug("size: " + size);
int i = 0;
if (mMoveDetection) {
detectMoves();
}
i = 0;
final Map<Integer, DiffTuple> diffs = mEntries > DIFF_THRESHOLD ? mDiffDatabase.getMap() : mDiffs;
firePropertyChange("diffs", null, diffs);
for (mAxis = new DiffSunburstAxis(IncludeSelf.YES, this, mNewRtx, mOldRtx, diffs, mDepthMax, mDepth, mPrune); mAxis.hasNext(); i++) {
mAxis.next();
if (mCompare == ECompare.SINGLEINCREMENTAL) {
final int progress = (int) ((i / (float) size) * 100);
firePropertyChange("progress", null, progress);
}
}
} catch (final InterruptedException | ExecutionException e) {
LOGWRAPPER.error(e.getMessage(), e);
}
try {
mOldRtx.close();
mNewRtx.close();
} catch (final SirixException e) {
LOGWRAPPER.error(e.getMessage(), e);
}
LOGWRAPPER.info(mItems.size() + " SunburstItems created!");
LOGWRAPPER.debug("oldMaxDepth: " + mDepthMax);
mLock.acquireUninterruptibly();
// Order of property changes is significant.
firePropertyChange("oldRev", null, mOldRevision);
firePropertyChange("newRev", null, mNewRevision);
firePropertyChange("oldmaxdepth", null, mDepthMax);
firePropertyChange("maxDepth", null, mNewDepthMax);
firePropertyChange("items", null, mItems);
firePropertyChange("updated", null, mHasUpdatedNodes);
firePropertyChange("revision", null, mNewRevision);
firePropertyChange("done", null, true);
firePropertyChange("progress", null, 100);
LOGWRAPPER.debug("Property changes sent!");
// Lock is released in the controller.
// mDiffDatabase.close();
final long endTime = System.nanoTime();
System.out.println((endTime - startTime) * 1e-6 / 1000);
return null;
}
Aggregations