in order-book-pipeline/src/main/java/com/google/cloud/dataflow/orderbook/MarketDepthToTableRowConverter.java [32:54]
public TableRow apply(KV<SessionContractKey, MarketDepth> input) {
MarketDepth marketDepth = input.getValue();
TableRow result = new TableRow();
result.set("session_id", input.getKey().getSessionId());
result.set("contract_id", input.getKey().getContractId());
result.set("contract_sequence_id", marketDepth.getContractSeqId());
result.set("bid_count", marketDepth.getBidsCount());
result.set("offer_count", marketDepth.getOffersCount());
result.set("event_ts", Instant.ofEpochMilli(marketDepth.getTimestampMS()));
if (marketDepth.getBidsCount() > 0) {
result.set("bids", getPriceQuantityRepeatedRows(marketDepth.getBidsList()));
}
if (marketDepth.getOffersCount() > 0) {
result.set("offers", getPriceQuantityRepeatedRows(marketDepth.getOffersList()));
}
if(marketDepth.getLastTrade() != null) {
result.set("last_trade", priceQuantityAsTableRow(marketDepth.getLastTrade()));
}
return result;
}