本文整理汇总了Java中com.google.api.services.bigquery.model.TableRow.set方法的典型用法代码示例。如果您正苦于以下问题:Java TableRow.set方法的具体用法?Java TableRow.set怎么用?Java TableRow.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.bigquery.model.TableRow
的用法示例。
在下文中一共展示了TableRow.set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processElement
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@Override
public void processElement(ProcessContext c) {
Double dollars = c.element();
TableRow r = new TableRow();
r.set("dollar_turnover", dollars);
// the timing can be:
// EARLY: the dollar amount is not yet final
// ON_TIME: dataflow thinks the dollar amount is final but late data are still possible
// LATE: late data has arrived
r.set("dollar_timing", c.pane().getTiming()); // EARLY, ON_TIME or LATE
r.set("dollar_window", ((IntervalWindow) c.window()).start().getMillis() / 1000.0 / 60.0); // timestamp in fractional minutes
LOG.info("Outputting $ value {}} at {} with marker {} for window {}",
dollars.toString(), new Date().getTime(), c.pane().getTiming().toString(), c.window().hashCode());
c.output(r);
}
示例2: convertGenericRecordToTableRow
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
private static TableRow convertGenericRecordToTableRow(
GenericRecord record, List<TableFieldSchema> fields) {
TableRow row = new TableRow();
for (TableFieldSchema subSchema : fields) {
// Per https://cloud.google.com/bigquery/docs/reference/v2/tables#schema, the name field
// is required, so it may not be null.
Field field = record.getSchema().getField(subSchema.getName());
Object convertedValue =
getTypedCellValue(field.schema(), subSchema, record.get(field.name()));
if (convertedValue != null) {
// To match the JSON files exported by BigQuery, do not include null values in the output.
row.set(field.name(), convertedValue);
}
}
return row;
}
示例3: processElement
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
String[] split = c.element().split(",");
TableRow row = new TableRow();
for (int i = 0; i < split.length; i++) {
TableFieldSchema col = getTableSchema().getFields().get(i);
row.set(col.getName(), split[i]);
}
c.output(row);
}
示例4: processElement
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
TableRow row = new TableRow();
row.set("sales_date", (c.element().getSalesDate().getTime()/1000));
row.set("store_code", c.element().getStoreCode());
row.set("register_id", c.element().getRegisterID());
row.set("receipt_number", c.element().getReceiptNumber());
row.set("receipt_branch_number", c.element().getReceiptBranchNumber());
row.set("product_code", c.element().getProductCode());
row.set("quantity", c.element().getQuantity());
row.set("price", c.element().getPrice());
c.output(row);
}
示例5: apply
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@Override
public TableRow apply(KV<LatLon, Long> ridegrp) {
TableRow result = new TableRow();
result.set("latitude", ridegrp.getKey().lat);
result.set("longitude", ridegrp.getKey().lon);
result.set("ntaxis", ridegrp.getValue());
return result;
}
示例6: toTableRow
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
public TableRow toTableRow() {
TableRow result = new TableRow();
result.set("latitude", lat);
result.set("longitude", lon);
result.set("ride_id", rideId);
result.set("timestamp", Instant.ofEpochMilli(timestamp).toString());
result.set("ride_status", status);
return result;
}
示例7: processElement
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c, BoundedWindow window) {
TableRow row = new TableRow();
for (Map.Entry<String, FieldInfo<InputT>> entry : fieldInfo.entrySet()) {
String key = entry.getKey();
FieldInfo<InputT> fcnInfo = entry.getValue();
FieldFn<InputT> fcn = fcnInfo.getFieldFn();
row.set(key, fcn.apply(c, window));
}
c.output(row);
}
示例8: processElement
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c, BoundedWindow window) {
TableRow row = new TableRow();
for (Map.Entry<String, FieldInfo<T>> entry : fieldInfo.entrySet()) {
String key = entry.getKey();
FieldInfo<T> fcnInfo = entry.getValue();
row.set(key, fcnInfo.getFieldFn().apply(c, window));
}
c.output(row);
}
示例9: convertStringsToLong
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
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;
}
示例10: testCoder_nullCell
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
@Test
public void testCoder_nullCell() throws CoderException {
TableRow row = new TableRow();
row.set("temperature", Data.nullOf(Object.class));
row.set("max_temperature", Data.nullOf(Object.class));
byte[] bytes = CoderUtils.encodeToByteArray(TableRowJsonCoder.of(), row);
TableRow newRow = CoderUtils.decodeFromByteArray(TableRowJsonCoder.of(), bytes);
byte[] newBytes = CoderUtils.encodeToByteArray(TableRowJsonCoder.of(), newRow);
Assert.assertArrayEquals(bytes, newBytes);
}
示例11: entityToRow
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
public TableRow entityToRow(List<ColumnSchema> columnSchemas, Entity e) throws Exception {
TableRow row = new TableRow();
Map<String, Value> fields = e.getProperties();
for (ColumnSchema columnSchema : columnSchemas) {
Value v = fields.get(columnSchema.name);
if (v != null) {
Object column = valueToColumn(columnSchema, v);
row.set(columnSchema.name, column);
}
}
return row;
}
示例12: setTableRowFieldIfNotNull
import com.google.api.services.bigquery.model.TableRow; //导入方法依赖的package包/类
public static void setTableRowFieldIfNotNull(TableRow r, String field, Object value) {
if (value != null)
r.set(field, value);
}