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


Java WriteDisposition.valueOf方法代码示例

本文整理汇总了Java中org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java WriteDisposition.valueOf方法的具体用法?Java WriteDisposition.valueOf怎么用?Java WriteDisposition.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition的用法示例。


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

示例1: runLoadJob

import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition; //导入方法依赖的package包/类
private JobStatus runLoadJob(JobReference jobRef, JobConfigurationLoad load)
    throws InterruptedException, IOException {
  TableReference destination = load.getDestinationTable();
  TableSchema schema = load.getSchema();
  checkArgument(schema != null, "No schema specified");
  List<ResourceId> sourceFiles = filesForLoadJobs.get(jobRef.getProjectId(), jobRef.getJobId());
  WriteDisposition writeDisposition = WriteDisposition.valueOf(load.getWriteDisposition());
  CreateDisposition createDisposition = CreateDisposition.valueOf(load.getCreateDisposition());
  checkArgument(load.getSourceFormat().equals("NEWLINE_DELIMITED_JSON"));
  Table existingTable = datasetService.getTable(destination);
  if (!validateDispositions(existingTable, createDisposition, writeDisposition)) {
    return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
  }
  if (existingTable == null) {
    TableReference strippedDestination =
        destination
            .clone()
            .setTableId(BigQueryHelpers.stripPartitionDecorator(destination.getTableId()));
    existingTable =
        new Table()
            .setTableReference(strippedDestination)
            .setSchema(schema);
    if (load.getTimePartitioning() != null) {
      existingTable = existingTable.setTimePartitioning(load.getTimePartitioning());
    }
    datasetService.createTable(existingTable);
  }

  List<TableRow> rows = Lists.newArrayList();
  for (ResourceId filename : sourceFiles) {
    rows.addAll(readRows(filename.toString()));
  }
  datasetService.insertAll(destination, rows, null);
  FileSystems.delete(sourceFiles);
  return new JobStatus().setState("DONE");
}
 
开发者ID:apache,项目名称:beam,代码行数:37,代码来源:FakeJobService.java

示例2: runCopyJob

import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition; //导入方法依赖的package包/类
private JobStatus runCopyJob(JobConfigurationTableCopy copy)
    throws InterruptedException, IOException {
  List<TableReference> sources = copy.getSourceTables();
  TableReference destination = copy.getDestinationTable();
  WriteDisposition writeDisposition = WriteDisposition.valueOf(copy.getWriteDisposition());
  CreateDisposition createDisposition = CreateDisposition.valueOf(copy.getCreateDisposition());
  Table existingTable = datasetService.getTable(destination);
  if (!validateDispositions(existingTable, createDisposition, writeDisposition)) {
    return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
  }
  TimePartitioning partitioning = null;
  TableSchema schema = null;
  boolean first = true;
  List<TableRow> allRows = Lists.newArrayList();
  for (TableReference source : sources) {
    Table table = checkNotNull(datasetService.getTable(source));
    if (!first) {
      if (partitioning != table.getTimePartitioning()) {
        return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
      }
      if (schema != table.getSchema()) {
        return new JobStatus().setState("FAILED").setErrorResult(new ErrorProto());
      }
    }
    partitioning = table.getTimePartitioning();
    schema = table.getSchema();
    first = false;
    allRows.addAll(datasetService.getAllRows(
        source.getProjectId(), source.getDatasetId(), source.getTableId()));
  }
  datasetService.createTable(new Table()
      .setTableReference(destination)
      .setSchema(schema)
      .setTimePartitioning(partitioning));
  datasetService.insertAll(destination, allRows, null);
  return new JobStatus().setState("DONE");
}
 
开发者ID:apache,项目名称:beam,代码行数:38,代码来源:FakeJobService.java


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