本文整理了Java中com.google.api.services.bigquery.model.TableRow.get()
方法的一些代码示例,展示了TableRow.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableRow.get()
方法的具体详情如下:
包路径:com.google.api.services.bigquery.model.TableRow
类名称:TableRow
方法名:get
[英]Represents a single row in the result set, consisting of one or more fields.
[中]表示结果集中的一行,由一个或多个字段组成。
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
String countryCode = (String) row.get("ActionGeo_CountryCode");
String sqlDate = (String) row.get("SQLDATE");
String actor1Name = (String) row.get("Actor1Name");
String sourceUrl = (String) row.get("SOURCEURL");
String eventInfo = "Date: " + sqlDate + ", Actor1: " + actor1Name + ", url: " + sourceUrl;
c.output(KV.of(countryCode, eventInfo));
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
if ((Boolean) row.get("tornado")) {
c.output(Integer.parseInt((String) row.get("month")));
}
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
Integer month = Integer.parseInt((String) row.get("month"));
Double meanTemp = Double.parseDouble(row.get("mean_temp").toString());
c.output(KV.of(month, meanTemp));
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
int timestamp;
// TODO(BEAM-5390): Avoid this workaround.
try {
timestamp = ((BigDecimal) row.get("timestamp")).intValue();
} catch (ClassCastException e) {
timestamp = ((Integer) row.get("timestamp")).intValue();
}
String userName = (String) row.get("contributor_username");
if (userName != null) {
// Sets the implicit timestamp field to be used in windowing.
c.outputWithTimestamp(userName, new Instant(timestamp * 1000L));
}
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
String countryCode = (String) row.get("FIPSCC");
String countryName = (String) row.get("HumanName");
c.output(KV.of(countryCode, countryName));
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
Double meanTemp = Double.parseDouble(row.get("mean_temp").toString());
c.output(meanTemp);
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
Integer month;
month = (Integer) row.get("month");
if (month.equals(this.monthFilter)) {
c.output(row);
}
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
// Grab year, month, day, mean_temp from the row
Integer year = Integer.parseInt((String) row.get("year"));
Integer month = Integer.parseInt((String) row.get("month"));
Integer day = Integer.parseInt((String) row.get("day"));
Double meanTemp = Double.parseDouble(row.get("mean_temp").toString());
// Prepares the data for writing to BigQuery by building a TableRow object
TableRow outRow =
new TableRow()
.set("year", year)
.set("month", month)
.set("day", day)
.set("mean_temp", meanTemp);
c.output(outRow);
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
TableRow row = c.element();
String playName = (String) row.get("corpus");
String word = (String) row.get("word");
if (word.length() >= MIN_WORD_LENGTH) {
c.output(KV.of(word, playName));
} else {
// Track how many smaller words we're not including. This information will be
// visible in the Monitoring UI.
smallerWords.inc();
}
}
}
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) {
Double meanTemp =
Double.parseDouble(c.element().get("mean_temp").toString());
Double gTemp = c.sideInput(globalMeanTemp);
if (meanTemp < gTemp) {
c.output(c.element());
}
}
})
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform
List<TableRow> convertStringsToLong(List<TableRow> toConvert) {
// The numbers come back as String after JSON serialization. Change them back to
// longs so that we can assert the output.
List<TableRow> converted = Lists.newArrayList();
for (TableRow entry : toConvert) {
TableRow convertedEntry = entry.clone();
convertedEntry.set("number", Long.parseLong((String) convertedEntry.get("number")));
converted.add(convertedEntry);
}
return converted;
}
代码示例来源:origin: org.apache.beam/beam-runners-flink_2.11
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
TableRow row = c.element();
long timestamp = (Integer) row.get("timestamp");
String userName = (String) row.get("contributor_username");
if (userName != null) {
// Sets the timestamp field to be used in windowing.
c.outputWithTimestamp(userName, new Instant(timestamp * 1000L));
}
}
}))
代码示例来源:origin: org.apache.beam/beam-runners-flink_2.10
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
TableRow row = c.element();
long timestamp = (Integer) row.get("timestamp");
String userName = (String) row.get("contributor_username");
if (userName != null) {
// Sets the timestamp field to be used in windowing.
c.outputWithTimestamp(userName, new Instant(timestamp * 1000L));
}
}
}))
代码示例来源:origin: org.apache.beam/beam-runners-flink
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
TableRow row = c.element();
long timestamp = (Integer) row.get("timestamp");
String userName = (String) row.get("contributor_username");
if (userName != null) {
// Sets the timestamp field to be used in windowing.
c.outputWithTimestamp(userName, new Instant(timestamp * 1000L));
}
}
}))
代码示例来源:origin: yu-iskw/bigquery-to-datastore
/**
* Convert TableRow to Entity
*
* @param row TableRow of bigquery
* @return converted Entity
* @throws ParseException
*/
public Entity convertTableRowToEntity(TableRow row) throws ParseException {
String keyName = row.get(keyColumn).toString();
Key key = getKey(keyName);
Entity.Builder builder = Entity.newBuilder().setKey(key);
Set<Map.Entry<String, Object>> entries = row.entrySet();
for (Map.Entry<String, Object> entry : entries) {
// Skip on the key column
if (entry.getKey().equals(keyColumn)) {
continue;
}
// Put a value in the builder
String propertyName = entry.getKey();
Object value = entry.getValue();
Value v = convertToDatastoreValue(propertyName, value);
if (v != null) {
builder.putProperties(propertyName, v);
}
}
return builder.build();
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
c.output(
KV.of(
(String) c.element().get("name"),
Long.valueOf((String) c.element().get("number"))));
}
}));
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
c.output(
KV.of(
(String) c.element().get("name"),
Long.valueOf((String) c.element().get("number"))));
}
}));
代码示例来源:origin: org.apache.beam/beam-examples-java
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
TableRow element = c.element();
TableRow row =
new TableRow()
.set("trigger_type", element.get("trigger_type"))
.set("freeway", element.get("freeway"))
.set("total_flow", element.get("total_flow"))
.set("number_of_records", element.get("number_of_records"))
.set("isFirst", element.get("isFirst"))
.set("isLast", element.get("isLast"))
.set("timing", element.get("timing"))
.set("window", element.get("window"));
c.output(canonicalFormat(row));
}
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform
@Test
public void testToTableRow_array_row() {
TableRow row = toTableRow().apply(ARRAY_ROW_ROW);
assertThat(row.size(), equalTo(1));
row = ((List<TableRow>) row.get("rows")).get(0);
assertThat(row.size(), equalTo(5));
assertThat(row, hasEntry("id", 123L));
assertThat(row, hasEntry("value", 123.456));
assertThat(row, hasEntry("name", "test"));
assertThat(row, hasEntry("valid", false));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform
@Test
public void testToTableRow_row() {
TableRow row = toTableRow().apply(ROW_ROW);
assertThat(row.size(), equalTo(1));
row = (TableRow) row.get("row");
assertThat(row.size(), equalTo(5));
assertThat(row, hasEntry("id", 123L));
assertThat(row, hasEntry("value", 123.456));
assertThat(row, hasEntry("name", "test"));
assertThat(row, hasEntry("valid", false));
}
内容来源于网络,如有侵权,请联系作者删除!