com.google.api.services.bigquery.model.TableRow.getF()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.google.api.services.bigquery.model.TableRow.getF()方法的一些代码示例,展示了TableRow.getF()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableRow.getF()方法的具体详情如下:
包路径:com.google.api.services.bigquery.model.TableRow
类名称:TableRow
方法名:getF

TableRow.getF介绍

[英]Represents a single row in the result set, consisting of one or more fields.
[中]表示结果集中的一行,由一个或多个字段组成。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

@Override
 public FieldValueList apply(TableRow rowPb) {
  return FieldValueList.fromPb(rowPb.getF(), null);
 }
}));

代码示例来源:origin: stackoverflow.com

System.out.print("\nQuery Results, Page #" + page + ":\n------------\n");
for (TableRow row : rows) {
 for (TableCell field : row.getF()) {
 System.out.printf("%-50s", field.getV());

代码示例来源:origin: com.google.cloud/google-cloud-bigquery

@Override
 public FieldValueList apply(TableRow rowPb) {
  return FieldValueList.fromPb(rowPb.getF(), null);
 }
}));

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

private String formatRows(int totalNumRows) {
  StringBuilder samples = new StringBuilder();
  List<TableRow> rows = response.getRows();
  for (int i = 0; i < totalNumRows && i < rows.size(); i++) {
   samples.append(String.format("%n\t\t"));
   for (TableCell field : rows.get(i).getF()) {
    samples.append(String.format("%-10s", field.getV()));
   }
  }
  if (rows.size() > totalNumRows) {
   samples.append(String.format("%n\t\t..."));
  }
  return samples.toString();
 }
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

private String generateHash(@Nonnull List<TableRow> rows) {
 List<HashCode> rowHashes = Lists.newArrayList();
 for (TableRow row : rows) {
  List<String> cellsInOneRow = Lists.newArrayList();
  for (TableCell cell : row.getF()) {
   cellsInOneRow.add(Objects.toString(cell.getV()));
   Collections.sort(cellsInOneRow);
  }
  rowHashes.add(Hashing.sha1().hashString(cellsInOneRow.toString(), StandardCharsets.UTF_8));
 }
 return Hashing.combineUnordered(rowHashes).toString();
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

/**
 * Tries to parse the JSON {@link TableRow} from BigQuery.
 *
 * <p>Only supports basic types and arrays. Doesn't support date types.
 */
public static Row toBeamRow(Schema rowSchema, TableSchema bqSchema, TableRow jsonBqRow) {
 List<TableFieldSchema> bqFields = bqSchema.getFields();
 Map<String, Integer> bqFieldIndices =
   IntStream.range(0, bqFields.size())
     .boxed()
     .collect(toMap(i -> bqFields.get(i).getName(), i -> i));
 List<Object> rawJsonValues =
   rowSchema
     .getFields()
     .stream()
     .map(field -> bqFieldIndices.get(field.getName()))
     .map(index -> jsonBqRow.getF().get(index).getV())
     .collect(toList());
 return IntStream.range(0, rowSchema.getFieldCount())
   .boxed()
   .map(index -> toBeamValue(rowSchema.getField(index).getType(), rawJsonValues.get(index)))
   .collect(toRow(rowSchema));
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

cells = row.getF();

代码示例来源:origin: com.spotify/scio-bigquery

cells = row.getF();

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

private void verifyLegacyQueryRes() throws Exception {
 LOG.info("Starting verifyLegacyQueryRes in outputTable {}", outputTable);
 List<String> legacyQueryExpectedRes = ImmutableList.of("apple", "orange");
 QueryResponse response =
   bqClient.queryWithRetries(String.format("SELECT fruit from [%s];", outputTable), project);
 LOG.info("Finished to query result table {}", this.outputTable);
 List<String> tableResult =
   response
     .getRows()
     .stream()
     .flatMap(row -> row.getF().stream().map(cell -> cell.getV().toString()))
     .sorted()
     .collect(Collectors.toList());
 assertEquals(legacyQueryExpectedRes, tableResult);
}

代码示例来源:origin: googlearchive/bigquery-samples-java

/**
 * Makes an API call to the BigQuery API
 *
 * @param bigquery     an authorized BigQuery client
 * @param projectId    a string containing the current project ID
 * @param completedJob to the completed Job
 * @throws IOException
 */
private static void displayQueryResults(Bigquery bigquery,
                    String projectId, Job completedJob) throws IOException {
 GetQueryResultsResponse queryResult = bigquery.jobs()
   .getQueryResults(
     projectId, completedJob
     .getJobReference()
     .getJobId()
   ).execute();
 List<TableRow> rows = queryResult.getRows();
 System.out.print("\nQuery Results:\n------------\n");
 for (TableRow row : rows) {
  for (TableCell field : row.getF()) {
  System.out.printf("%-50s", field.getV());
   }
  System.out.println();
 }
}
// [END display_result]

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

row -> {
 String res = "";
 for (TableCell cell : row.getF()) {
  if (res.isEmpty()) {
   res = cell.getV().toString();

代码示例来源:origin: org.apache.beam/beam-examples-java

@Test
 public void testE2ETrafficMaxLaneFlow() throws Exception {
  this.options.setBigQuerySchema(FormatMaxesFn.getSchema());
  this.options.setProject(this.projectId);
  this.options.setBigQueryDataset(this.outputDatasetId);
  this.options.setBigQueryTable(this.outputTable);
  TrafficMaxLaneFlow.runTrafficMaxLaneFlow(this.options);

  QueryResponse response =
    this.bqClient.queryWithRetries(
      String.format(
        "SELECT count(*) as total FROM [%s:%s.%s]",
        this.projectId, this.outputDatasetId, this.outputTable),
      this.projectId);
  String res = response.getRows().get(0).getF().get(0).getV().toString();
  assertEquals("9763", res);
 }
}

代码示例来源:origin: org.apache.beam/beam-examples-java

@Test
 public void testE2ETrafficRoutes() throws Exception {
  this.options.setBigQuerySchema(FormatStatsFn.getSchema());
  this.options.setProject(this.projectId);
  this.options.setBigQueryDataset(this.outputDatasetId);
  this.options.setBigQueryTable(this.outputTable);
  TrafficRoutes.runTrafficRoutes(options);

  QueryResponse response =
    this.bqClient.queryWithRetries(
      String.format(
        "SELECT count(*) as total FROM [%s:%s.%s]",
        this.projectId, this.outputDatasetId, this.outputTable),
      this.projectId);
  String res = response.getRows().get(0).getF().get(0).getV().toString();
  assertEquals("27", res);
 }
}

相关文章