Skip to content

Instantly share code, notes, and snippets.

@hernanliendo
Created August 26, 2014 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hernanliendo/493df50964edcf956f07 to your computer and use it in GitHub Desktop.
Save hernanliendo/493df50964edcf956f07 to your computer and use it in GitHub Desktop.
Hackademy - BigQuery client example
final List<Map<String, Object>> rowValues = new ArrayList<>(logsSharedObject.getItems().size());
for (final ObjectVar itemOV : logsSharedObject.getItems()) {
final Map<String, Object> item = new HashMap<>();
rowValues.add(item);
item.put("User", clientUserId);
item.put("Timestamp", time);
item.put("Device", device);
item.put("Type", itemOV.getString("t"));
item.put("Context", clientContext);
item.put("Log", itemOV.getString("l"));
item.put("Stack", itemOV.getString("s"));
item.put("RemoteAddress", remoteAddress);
}
if (!rowValues.isEmpty()) {
try {
BigQueryServerFactory.instance().getBigQueryClientFactory().insertRows("Audit", "ClientLog", rowValues);
} catch (final Throwable _throwable) {
log.log(Level.WARNING, "Problems sending logs to BigQuery: " + _throwable.getMessage(), _throwable);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment