本文整理汇总了Java中org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE属性的典型用法代码示例。如果您正苦于以下问题:Java WriteDisposition.WRITE_TRUNCATE属性的具体用法?Java WriteDisposition.WRITE_TRUNCATE怎么用?Java WriteDisposition.WRITE_TRUNCATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.WriteDisposition
的用法示例。
在下文中一共展示了WriteDisposition.WRITE_TRUNCATE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateDispositions
private boolean validateDispositions(Table table, CreateDisposition createDisposition,
WriteDisposition writeDisposition)
throws InterruptedException, IOException {
if (table == null) {
if (createDisposition == CreateDisposition.CREATE_NEVER) {
return false;
}
} else if (writeDisposition == WriteDisposition.WRITE_TRUNCATE) {
datasetService.deleteTable(table.getTableReference());
} else if (writeDisposition == WriteDisposition.WRITE_EMPTY) {
List<TableRow> allRows = datasetService.getAllRows(table.getTableReference().getProjectId(),
table.getTableReference().getDatasetId(), table.getTableReference().getTableId());
if (!allRows.isEmpty()) {
return false;
}
}
return true;
}
示例2: writeAllTablesToBigQuery
/**
* @param bqrows
* @param webresourceRowsUnindexed
* @param webresourceDeduped
* @param options
*/
private static void writeAllTablesToBigQuery(PCollectionTuple bqrows,
PCollection<TableRow> webresourceRowsUnindexed, PCollection<TableRow> webresourceDeduped,
IndexerPipelineOptions options) {
PCollection<TableRow> webresourceRows = bqrows.get(PipelineTags.webresourceTag);
PCollection<TableRow> documentRows = bqrows.get(PipelineTags.documentTag);
PCollection<TableRow> sentimentRows = bqrows.get(PipelineTags.sentimentTag);
// Now write to BigQuery
WriteDisposition dispo = options.getWriteTruncate() ?
WriteDisposition.WRITE_TRUNCATE: WriteDisposition.WRITE_APPEND;
//Merge all collections with WebResource table records
PCollectionList<TableRow> webresourceRowsList = (webresourceDeduped == null) ?
PCollectionList.of(webresourceRows).and(webresourceRowsUnindexed) :
PCollectionList.of(webresourceRows).and(webresourceRowsUnindexed).and(webresourceDeduped);
PCollection<TableRow> allWebresourceRows =
webresourceRowsList.apply(Flatten.<TableRow>pCollections());
allWebresourceRows = !options.isStreaming() ?
allWebresourceRows.apply("Reshuffle Webresources", new Reshuffle<TableRow>()) :
allWebresourceRows;
allWebresourceRows
.apply("Write to webresource",
BigQueryIO.writeTableRows()
.to(getWebResourcePartitionedTableRef(options))
.withSchema(getWebResourceSchema())
.withCreateDisposition(CreateDisposition.CREATE_NEVER)
.withWriteDisposition(dispo));
documentRows = !options.isStreaming() ?
documentRows.apply("Reshuffle Documents", new Reshuffle<TableRow>()):
documentRows;
documentRows
.apply("Write to document",
BigQueryIO.writeTableRows()
.to(getDocumentPartitionedTableRef(options))
.withSchema(getDocumentTableSchema())
.withCreateDisposition(CreateDisposition.CREATE_NEVER)
.withWriteDisposition(dispo));
sentimentRows = !options.isStreaming() ?
sentimentRows.apply("Reshuffle Sentiments", new Reshuffle<TableRow>()):
sentimentRows;
sentimentRows
.apply("Write to sentiment",
BigQueryIO.writeTableRows()
.to(getSentimentPartitionedTableRef(options))
.withSchema(getSentimentSchema())
.withCreateDisposition(CreateDisposition.CREATE_NEVER)
.withWriteDisposition(dispo));
}