aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2016-09-20 17:20:41 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-21 07:07:07 +0000
commite6b9dc2f8d94e5611b7c45cc7692c49b999904df (patch)
treeeba0c9bc438fb2084260f147e65770d7771b2e27 /src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java
parent07f6fcf8a88791aef887b05c79b907760b989ea9 (diff)
Introduce a new method on the StreamedFormatter interface for creating a callback for streaming a precomputed result.
-- MOS_MIGRATED_REVID=133720742
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java
index f47d94942b..8a3c4b6318 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/output/OutputFormatter.java
@@ -31,6 +31,7 @@ import com.google.devtools.build.lib.packages.License;
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.query2.engine.OutputFormatterCallback;
+import com.google.devtools.build.lib.query2.engine.QueryEnvironment;
import com.google.devtools.build.lib.query2.output.QueryOptions.OrderOutput;
import com.google.devtools.build.lib.syntax.EvalUtils;
import com.google.devtools.build.lib.syntax.Printer;
@@ -154,7 +155,8 @@ public abstract class OutputFormatter implements Serializable {
* the graph maintained by the QueryEnvironment), and print it to "out".
*/
public abstract void output(QueryOptions options, Digraph<Target> result, PrintStream out,
- AspectResolver aspectProvider) throws IOException, InterruptedException;
+ AspectResolver aspectProvider)
+ throws IOException, InterruptedException;
/**
* Unordered streamed output formatter (wrt. dependency ordering).
@@ -177,8 +179,18 @@ public abstract class OutputFormatter implements Serializable {
*
* <p>Takes any options specified via the most recent call to {@link #setOptions} into
* consideration.
+ *
+ * <p>Intended to be use for streaming out during evaluation of a query.
+ */
+ OutputFormatterCallback<Target> createStreamCallback(
+ PrintStream out, QueryOptions options, @Nullable QueryEnvironment<?> env);
+
+ /**
+ * Same as {@link #createStreamCallback}, but intended to be used for outputting the
+ * already-computed result of a query.
*/
- OutputFormatterCallback<Target> createStreamCallback(PrintStream out, QueryOptions options);
+ OutputFormatterCallback<Target> createPostFactoStreamCallback(
+ PrintStream out, QueryOptions options);
}
/**
@@ -209,11 +221,14 @@ public abstract class OutputFormatter implements Serializable {
}
@Override
- public void output(QueryOptions options, Digraph<Target> result, PrintStream out,
+ public void output(
+ QueryOptions options,
+ Digraph<Target> result,
+ PrintStream out,
AspectResolver aspectResolver) throws IOException, InterruptedException {
setOptions(options, aspectResolver);
OutputFormatterCallback.processAllTargets(
- createStreamCallback(out, options), getOrderedTargets(result, options));
+ createPostFactoStreamCallback(out, options), getOrderedTargets(result, options));
}
}
@@ -235,7 +250,7 @@ public abstract class OutputFormatter implements Serializable {
}
@Override
- public OutputFormatterCallback<Target> createStreamCallback(
+ public OutputFormatterCallback<Target> createPostFactoStreamCallback(
final PrintStream out, final QueryOptions options) {
return new OutputFormatterCallback<Target>() {
@@ -253,6 +268,12 @@ public abstract class OutputFormatter implements Serializable {
}
};
}
+
+ @Override
+ public OutputFormatterCallback<Target> createStreamCallback(
+ PrintStream out, QueryOptions options, QueryEnvironment<?> env) {
+ return createPostFactoStreamCallback(out, options);
+ }
}
/**
@@ -279,7 +300,7 @@ public abstract class OutputFormatter implements Serializable {
}
@Override
- public OutputFormatterCallback<Target> createStreamCallback(
+ public OutputFormatterCallback<Target> createPostFactoStreamCallback(
final PrintStream out, final QueryOptions options) {
return new OutputFormatterCallback<Target>() {
private final Set<String> packageNames = Sets.newTreeSet();
@@ -302,6 +323,12 @@ public abstract class OutputFormatter implements Serializable {
}
};
}
+
+ @Override
+ public OutputFormatterCallback<Target> createStreamCallback(
+ PrintStream out, QueryOptions options, QueryEnvironment<?> env) {
+ return createPostFactoStreamCallback(out, options);
+ }
}
/**
@@ -318,7 +345,7 @@ public abstract class OutputFormatter implements Serializable {
}
@Override
- public OutputFormatterCallback<Target> createStreamCallback(
+ public OutputFormatterCallback<Target> createPostFactoStreamCallback(
final PrintStream out, final QueryOptions options) {
return new OutputFormatterCallback<Target>() {
@@ -339,6 +366,12 @@ public abstract class OutputFormatter implements Serializable {
}
};
}
+
+ @Override
+ public OutputFormatterCallback<Target> createStreamCallback(
+ PrintStream out, QueryOptions options, QueryEnvironment<?> env) {
+ return createPostFactoStreamCallback(out, options);
+ }
}
/**
@@ -354,7 +387,7 @@ public abstract class OutputFormatter implements Serializable {
}
@Override
- public OutputFormatterCallback<Target> createStreamCallback(
+ public OutputFormatterCallback<Target> createPostFactoStreamCallback(
final PrintStream out, final QueryOptions options) {
return new OutputFormatterCallback<Target>() {
private final Set<Label> printed = CompactHashSet.create();
@@ -412,6 +445,12 @@ public abstract class OutputFormatter implements Serializable {
}
};
}
+
+ @Override
+ public OutputFormatterCallback<Target> createStreamCallback(
+ PrintStream out, QueryOptions options, QueryEnvironment<?> env) {
+ return createPostFactoStreamCallback(out, options);
+ }
}
private static class RankAndLabel implements Comparable<RankAndLabel> {