示例#1
0
 @Override
 public void populateDisplayData(DisplayData.Builder builder) {
   super.populateDisplayData(builder);
   builder
       .addIfNotDefault(
           DisplayData.item("host", host).withLabel("Datastore Service"), DEFAULT_HOST)
       .addIfNotNull(DisplayData.item("dataset", datasetId).withLabel("Output Dataset"));
 }
示例#2
0
 @Override
 public void populateDisplayData(DisplayData.Builder builder) {
   super.populateDisplayData(builder);
   builder
       .addIfNotNull(
           DisplayData.item("filePattern", filepattern).withLabel("Input File Pattern"))
       .addIfNotDefault(
           DisplayData.item("validation", validate).withLabel("Validation Enabled"), true);
 }
示例#3
0
    @Override
    public void populateDisplayData(DisplayData.Builder builder) {
      super.populateDisplayData(builder);
      builder
          .addIfNotDefault(
              DisplayData.item("host", host).withLabel("Datastore Service"), DEFAULT_HOST)
          .addIfNotNull(DisplayData.item("dataset", datasetId).withLabel("Input Dataset"))
          .addIfNotNull(DisplayData.item("namespace", namespace).withLabel("App Engine Namespace"));

      if (query != null) {
        builder.add(DisplayData.item("query", query.toString()).withLabel("Query"));
      }
    }
示例#4
0
  /**
   * Populate display data for the {@code combineFns} that make up a composed combine transform.
   *
   * <p>The same combineFn class may be used multiple times, in which case we must take special care
   * to register display data with unique namespaces.
   */
  private static void populateDisplayData(
      DisplayData.Builder builder, List<? extends HasDisplayData> combineFns) {

    // NB: ArrayListMultimap necessary to maintain ordering of combineFns of the same type.
    Multimap<Class<?>, HasDisplayData> combineFnMap = ArrayListMultimap.create();

    for (int i = 0; i < combineFns.size(); i++) {
      HasDisplayData combineFn = combineFns.get(i);
      builder.add(
          DisplayData.item("combineFn" + (i + 1), combineFn.getClass())
              .withLabel("Combine Function"));
      combineFnMap.put(combineFn.getClass(), combineFn);
    }

    for (Map.Entry<Class<?>, Collection<HasDisplayData>> combineFnEntries :
        combineFnMap.asMap().entrySet()) {

      Collection<HasDisplayData> classCombineFns = combineFnEntries.getValue();
      if (classCombineFns.size() == 1) {
        // Only one combineFn of this type, include it directly.
        builder.include(Iterables.getOnlyElement(classCombineFns));

      } else {
        // Multiple combineFns of same type, add a namespace suffix so display data is
        // unique and ordered.
        String baseNamespace = combineFnEntries.getKey().getName();
        for (int i = 0; i < combineFns.size(); i++) {
          HasDisplayData combineFn = combineFns.get(i);
          String namespace = String.format("%s#%d", baseNamespace, i + 1);
          builder.include(combineFn, namespace);
        }
      }
    }
  }
示例#5
0
  @Test
  public void testDisplayData() {
    Top.Largest<Integer> comparer = new Top.Largest<Integer>();
    Combine.Globally<Integer, List<Integer>> top = Top.of(1234, comparer);
    DisplayData displayData = DisplayData.from(top);

    assertThat(displayData, hasDisplayItem("count", 1234));
    assertThat(displayData, hasDisplayItem("comparer", comparer.getClass()));
  }
示例#6
0
 @Override
 public void populateDisplayData(DisplayData.Builder builder) {
   super.populateDisplayData(builder);
   builder
       .add(DisplayData.item("schema", type).withLabel("Record Schema"))
       .addIfNotNull(
           DisplayData.item("filePrefix", filenamePrefix).withLabel("Output File Prefix"))
       .addIfNotDefault(
           DisplayData.item("shardNameTemplate", shardTemplate)
               .withLabel("Output Shard Name Template"),
           DEFAULT_SHARD_TEMPLATE)
       .addIfNotDefault(
           DisplayData.item("fileSuffix", filenameSuffix).withLabel("Output File Suffix"), "")
       .addIfNotDefault(
           DisplayData.item("numShards", numShards).withLabel("Maximum Output Shards"), 0)
       .addIfNotDefault(
           DisplayData.item("validation", validate).withLabel("Validation Enabled"), true);
 }