当前位置: 首页>>代码示例>>Java>>正文


Java KV.getKey方法代码示例

本文整理汇总了Java中com.google.cloud.dataflow.sdk.values.KV.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java KV.getKey方法的具体用法?Java KV.getKey怎么用?Java KV.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.cloud.dataflow.sdk.values.KV的用法示例。


在下文中一共展示了KV.getKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.google.cloud.dataflow.sdk.values.KV; //导入方法依赖的package包/类
@Override
public KV<String, WorkflowArgs> apply(Iterable<KV<String, WorkflowArgs>> input) {
  String key = null;
  WorkflowArgs retval = null;

  // Merge arguments
  for (KV<String, WorkflowArgs> kv : input) {

    // Modify a copy
    WorkflowArgs wa = new WorkflowArgs(kv.getValue());

    // First time, nothing to merge
    if (retval == null) {
      key = kv.getKey();
      retval = wa;
    // Find differences and merge
    } else {
      retval.gatherArgs(wa);
    }
  }
  return KV.of(key, retval);
}
 
开发者ID:googlegenomics,项目名称:dockerflow,代码行数:23,代码来源:MergeBranches.java

示例2: processElement

import com.google.cloud.dataflow.sdk.values.KV; //导入方法依赖的package包/类
@Override
public void processElement(ProcessContext c) throws Exception {
    List<KV<T, Iterable<U>>> kvs2 = c.sideInput(view);
    KV<T, Iterable<U>> kv1 = c.element();
    T k1 = kv1.getKey();
    Iterable<U> v1 = kv1.getValue();
    boolean foundMatch = false;
    for (KV<T, Iterable<U>> kv2 : kvs2) {
        if (k1.equals(kv2.getKey())) {
            // Found the key, now check the values (in any permutation).
            if (CollectionUtils.isEqualCollection(Lists.newArrayList(v1), Lists.newArrayList(kv2.getValue()))) {
                // Found a match!
                foundMatch = true;
            }
        }
    }
    Assert.assertTrue(foundMatch, "Unable to find a match for " + kv1.toString() + " in p2");
}
 
开发者ID:broadinstitute,项目名称:gatk-dataflow,代码行数:19,代码来源:DataflowTestUtils.java

示例3: processElement

import com.google.cloud.dataflow.sdk.values.KV; //导入方法依赖的package包/类
/**
 * Converts a Key-Value pair of (FilePath, FileContent) to (GCPResource, GCPResourceState).
 * The FilePath is a list of Strings which represents the location of a file.
 * The FileContent is the content of the file described by the FilePath.
 * The path is used to obtain the resource, and the content describes the state of that resource.
 * @param processContext The ProcessContext object that contains processContext-specific
 * methods and objects.
 */
@Override
public void processElement(ProcessContext processContext) {
  KV<List<String>, String> input = processContext.element();
  List<String> filePath = input.getKey();
  String fileContent = input.getValue();

  String orgName = filePath.size() > 0 ? filePath.get(0) : null;
  String projectId = filePath.size() > 1 ? filePath.get(1) : null;
  String policyFileName = filePath.size() > 2 ? filePath.get(2) : null;
  GCPProject project = new GCPProject(projectId, orgName);

  if (filePath.size() == 3 && GCPResourcePolicy.getPolicyFile().equals(policyFileName)) {
    // only project policies are supported for now.
    // filePath.size() must be 3 and of the form org_id/project_id/POLICY_FILE.
    Gson gson = new Gson();
    try {
      List<PolicyBinding> bindings = Arrays.asList(
          gson.fromJson(fileContent, PolicyBinding[].class));
      GCPResourceState policy = new GCPResourcePolicy(project, bindings);
      processContext.output(KV.of((GCPResource) project, policy));
      return;
    } catch (JsonSyntaxException jse) {
      addToSideOutput(
          processContext,
          project,
          String.format("Invalid policy json %s/%s/%s", orgName, projectId, policyFileName));
    }
  }
  addToSideOutput(
      processContext,
      project,
      String.format("Invalid policy filepath %s/%s/%s", orgName, projectId, policyFileName));
}
 
开发者ID:GoogleCloudPlatform,项目名称:policyscanner,代码行数:42,代码来源:FileToState.java


注:本文中的com.google.cloud.dataflow.sdk.values.KV.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。