Example usage for com.amazonaws.services.athena.model ResultSet getRows

List of usage examples for com.amazonaws.services.athena.model ResultSet getRows

Introduction

In this page you can find the example usage for com.amazonaws.services.athena.model ResultSet getRows.

Prototype


public java.util.List<Row> getRows() 

Source Link

Document

The rows in the table.

Usage

From source file:com.nike.cerberus.lambda.waf.IpTranslatorProcessor.java

License:Apache License

private List<Map<String, String>> parseAndTranslateIpAddressToMetadata(String ipAddress, String environment) {

    AthenaQuery athenaQuery = new AthenaQuery();

    List<Map<String, String>> ipMetadataTable = new ArrayList<Map<String, String>>();

    ResultSet result = athenaQuery.processIpAddressInAthena(ipAddress, environment);

    result.getRows().stream().skip(1).forEach(row -> {
        Map<String, String> temp = new HashMap<>();
        Iterator<Datum> iter = row.getData().stream().iterator();

        temp.put("principalName", iter.next().getVarCharValue());
        temp.put("action", iter.next().getVarCharValue());
        temp.put("sdbName", iter.next().getVarCharValue());
        temp.put("clientVersion", iter.next().getVarCharValue());
        temp.put("count", iter.next().getVarCharValue());

        ipMetadataTable.add(temp);//  w w  w .j  a va 2s  .com
    });

    ArrayList<Map<String, String>> sdbMetadata = cerberusMetadataLookup.getCerberusMetadata(environment);
    for (Map<String, String> row : ipMetadataTable) {
        ArrayList<String> owner = cerberusMetadataLookup.searchCerberusMetadata(sdbMetadata, row.get("sdbName"),
                row.get("principalName"));
        row.put("owner", String.join("\n", owner));
    }

    return ipMetadataTable;
}