Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 836f487

Browse files
committed
remove prints
1 parent 7d9c20f commit 836f487

File tree

4 files changed

+3
-56
lines changed

4 files changed

+3
-56
lines changed

algo/src/main/java/org/neo4j/graphalgo/impl/pagerank/BaseComputeStep.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public abstract class BaseComputeStep implements ComputeStep {
4848
final int startNode;
4949
final int endNode;
5050
double l2Norm;
51-
int iteration;
5251

5352
BaseComputeStep(
5453
double dampingFactor,
@@ -73,8 +72,6 @@ public void setStarts(int starts[], int[] lengths) {
7372

7473
@Override
7574
public void run() {
76-
String name = String.format("[%s,startNode:%d,partitionSize:%d,iteration:%d,run] - run with current state: %s", this.getClass().getSimpleName(), this.startNode, this.partitionSize,this.iteration, state);
77-
System.out.println(name);
7875
if (state == S_CALC) {
7976
singleIteration();
8077
state = S_SYNC;
@@ -126,9 +123,7 @@ private void initialize() {
126123

127124
@Override
128125
public void prepareNormalizeDeltas(double l2Norm, int iteration) {
129-
// System.out.println("l2Norm = " + l2Norm + ", iteration = " + iteration);
130126
this.l2Norm = l2Norm;
131-
this.iteration = iteration;
132127
}
133128

134129
public void prepareNextIteration(int[][] prevScores) {

algo/src/main/java/org/neo4j/graphalgo/impl/pagerank/EigenvectorCentralityComputeStep.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ protected double initialValue() {
8080

8181
@Override
8282
void synchronizeScores(int[] allScores) {
83-
double[] before = deltas.clone();
84-
8583
double[] pageRank = this.pageRank;
8684

8785
int length = allScores.length;
@@ -94,25 +92,12 @@ void synchronizeScores(int[] allScores) {
9492
allScores[i] = 0;
9593
}
9694

97-
String name = String.format("[%s,%d,%d, %d, synchronizeScores]", this.getClass().getSimpleName(), this.startNode, this.partitionSize, this.iteration);
98-
System.out.println(name + "\nbefore: " + Arrays.toString(before) + "\nafter: " + Arrays.toString(deltas));
9995
}
10096

10197
@Override
10298
void normalizeDeltas() {
103-
// double[] before = deltas.clone();
10499
for (int i = 0; i < deltas.length; i++) {
105100
deltas[i] = deltas[i] / l2Norm;
106101
}
107-
// String name = String.format("[%s,%d,%d, %d]", this.getClass().getSimpleName(), this.startNode, this.partitionSize, this.iteration);
108-
// System.out.println(name + "\nnorm: " + l2Norm + "\nbefore: " + Arrays.toString(before) + "\nafter: " + Arrays.toString(deltas));
109-
}
110-
111-
@Override
112-
public String toString() {
113-
return "EigenvectorCentralityComputeStep{" +
114-
"partitionSize=" + partitionSize +
115-
", startNode=" + startNode +
116-
'}';
117102
}
118103
}

algo/src/main/java/org/neo4j/graphalgo/impl/pagerank/PageRank.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,49 +351,38 @@ CentralityResult getPageRank() {
351351

352352
private void run(int iterations) {
353353
// initialize data structures
354-
System.out.println("[pre iterations] init data structures");
355354
ParallelUtil.runWithConcurrency(concurrency, steps, pool);
356355
for (int iteration = 0; iteration < iterations && running(); iteration++) {
357-
System.out.println("-------");
358-
System.out.println("[iteration started] iteration:" + iteration);
359356
// calculate scores
360357
ParallelUtil.runWithConcurrency(concurrency, steps, 3, 1, TimeUnit.SECONDS, pool);
361358

362359
// sync scores
363-
System.out.println("[sync scores] iteration:" + iteration + ", steps:" + steps.size());
364360
synchronizeScores();
365361
ParallelUtil.runWithConcurrency(concurrency, steps, 3, 1, TimeUnit.SECONDS, pool);
366362

367363
// normalize deltas
368-
System.out.println("[norm computation] iteration:" + iteration + ", steps:" + steps.size());
369364
normalizeDeltas(iteration);
370365
ParallelUtil.runWithConcurrency(concurrency, steps, 3, 1, TimeUnit.SECONDS, pool);
371-
372-
System.out.println("[iteration finished] iteration:" + iteration);
373-
System.out.println("-------");
374366
}
375367
}
376368

377369
private void normalizeDeltas(int iteration) {
378-
double l2Norm = computeNorm(iteration);
370+
double l2Norm = computeNorm();
379371

380372
for (ComputeStep step : steps) {
381373
step.prepareNormalizeDeltas(l2Norm, iteration);
382374
}
383375
}
384376

385-
private double computeNorm(int iteration) {
377+
private double computeNorm() {
386378
double l2Norm = 0.0;
387379
for (ComputeStep step : steps) {
388380
double[] deltas = step.deltas();
389-
System.out.println("[norm computation] iteration:" + iteration + ", deltas:" + Arrays.toString(deltas));
390381
l2Norm += Arrays.stream(deltas).map(score -> score * score).sum();
391382
}
392383

393384
l2Norm = Math.sqrt(l2Norm);
394385

395-
System.out.println("[norm computation] iteration:" + iteration + ", l2Norm: " + l2Norm );
396-
397386
l2Norm = l2Norm <= 0 ? 1 : l2Norm;
398387
return l2Norm;
399388
}

core/src/main/java/org/neo4j/graphalgo/core/utils/ParallelUtil.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ private static void runWithConcurrency(
671671
int maxWaitRetries,
672672
TerminationFlag terminationFlag,
673673
ExecutorService executor) {
674-
System.out.println("[ParallelUtil#runWithConcurrency] running with " + tasks.size() + " tasks" + ", and concurrency of " + concurrency);
675674
if (!canRunInParallel(executor)
676675
|| tasks.size() == 1
677676
|| concurrency <= 1) {
@@ -692,7 +691,6 @@ private static void runWithConcurrency(
692691
// generally assumes that tasks.size is notably larger than concurrency
693692
try {
694693
//noinspection StatementWithEmptyBody - add first concurrency tasks
695-
System.out.println("[ParallelUtil#runWithConcurrency] submit tasks");
696694
while (concurrency-- > 0
697695
&& terminationFlag.running()
698696
&& completionService.trySubmit(ts));
@@ -701,15 +699,12 @@ private static void runWithConcurrency(
701699
return;
702700
}
703701

704-
System.out.println("[ParallelUtil#runWithConcurrency] submit more tasks");
705702
// submit all remaining tasks
706703
int tries = 0;
707704
while (ts.hasNext()) {
708705
if (completionService.hasTasks()) {
709706
try {
710-
System.out.println("[ParallelUtil#runWithConcurrency] waiting for task to finish... " + executor);
711707
completionService.awaitNext();
712-
System.out.println("[ParallelUtil#runWithConcurrency] task finished... " + executor);
713708
} catch (ExecutionException e) {
714709
error = Exceptions.chain(error, e.getCause());
715710
} catch (CancellationException ignore) {
@@ -720,18 +715,15 @@ private static void runWithConcurrency(
720715
}
721716
if (!completionService.trySubmit(ts) && !completionService.hasTasks()) {
722717
if (++tries >= maxWaitRetries) {
723-
System.out.println("[ParallelUtil#runWithConcurrency] exceeded max wait retries");
724718
break;
725719
}
726720
LockSupport.parkNanos(waitNanos);
727721
}
728722
}
729723

730-
System.out.println("[ParallelUtil#runWithConcurrency] wait for tasks");
731724
// wait for all tasks to finish
732725
while (completionService.hasTasks() && terminationFlag.running()) {
733726
try {
734-
System.out.println("[ParallelUtil#runWithConcurrency] waiting for next task");
735727
completionService.awaitNext();
736728
} catch (ExecutionException e) {
737729
error = Exceptions.chain(error, e.getCause());
@@ -743,7 +735,6 @@ private static void runWithConcurrency(
743735
} finally {
744736
finishRunWithConcurrency(completionService, error);
745737
}
746-
System.out.println("[ParallelUtil#runWithConcurrency] finished running with " + tasks.size() + " tasks");
747738
}
748739

749740
private static void finishRunWithConcurrency(
@@ -890,9 +881,7 @@ protected void done() {
890881
if (executor instanceof ThreadPoolExecutor) {
891882
pool = (ThreadPoolExecutor) executor;
892883
availableConcurrency = pool.getCorePoolSize();
893-
// availableConcurrency = 2;
894884
int capacity = Math.max(targetConcurrency, availableConcurrency) + 1;
895-
System.out.println("[ParallelUtil#runWithConcurrency] capacity = " + capacity + " [target:" + targetConcurrency + ",available:" + availableConcurrency + "]");
896885
completionQueue = new ArrayBlockingQueue<>(capacity);
897886
} else {
898887
pool = null;
@@ -939,17 +928,7 @@ void cancelAll() {
939928
}
940929

941930
private boolean canSubmit() {
942-
int activeCount = 0;
943-
boolean canSubmit = pool == null || (activeCount = pool.getActiveCount()) < availableConcurrency;
944-
945-
if(!canSubmit) {
946-
System.out.println("[ParallelUtil#runWithConcurrency] unable to submit task and pool:" + pool + ", activeCount:" + activeCount + ", availableConcurrency:" + availableConcurrency);
947-
// throw new RuntimeException();
948-
} else {
949-
System.out.println("[ParallelUtil#runWithConcurrency] submitted task and pool:" + pool + ", activeCount:" + activeCount + ", availableConcurrency:" + availableConcurrency);
950-
}
951-
952-
return canSubmit;
931+
return pool == null || pool.getActiveCount() < availableConcurrency;
953932
}
954933

955934
private void stopFutures(Collection<Future<Void>> futures) {
@@ -1001,7 +980,6 @@ public T next() {
1001980

1002981
void pushBack(T element) {
1003982
if (pushedElement != null) {
1004-
System.out.println("[ParallelUtil#runWithConcurrency] unable to reschedule task");
1005983
throw new IllegalArgumentException("Cannot push back twice");
1006984
}
1007985
pushedElement = element;

0 commit comments

Comments
 (0)