Example usage for com.amazonaws.services.dynamodbv2.model StreamRecord getNewImage

List of usage examples for com.amazonaws.services.dynamodbv2.model StreamRecord getNewImage

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model StreamRecord getNewImage.

Prototype


public java.util.Map<String, AttributeValue> getNewImage() 

Source Link

Document

The item in the DynamoDB table as it appeared after it was modified.

Usage

From source file:com.aws.sampleImage.url.LambdaFunctionImageURLCrawlerHandler.java

private void handleEachRecord(String eventName, StreamRecord streamRecord) {
    try {/*from   w w w .j a v  a2s.  c  o m*/

        //Only if Insert then start processing
        if (INSERT_EVENT.equalsIgnoreCase(eventName)) {

            Map<String, AttributeValue> newImageMap = streamRecord.getNewImage();

            AttributeValue keywordsAttrVal = newImageMap.get("keywords");
            AttributeValue synsetCodeAttrVal = newImageMap.get("synset_code");

            String keywords = keywordsAttrVal.getS();
            String synsetCode = synsetCodeAttrVal.getS();

            /*System.out.println("Keywords : " + keywords);
            System.out.println("SynsetCode : " + synsetCode);*/

            String[] keywordFragments = keywords.split(",");

            for (int i = 0; i < keywordFragments.length; i++) {

                //System.out.println("Calling Flickr API for getting Image URL :: " + keywordFragments[i]);
                callFlickrAPIForEachKeyword(keywordFragments[i], synsetCode);

            }

        }

    } catch (AmazonServiceException ase) {
        System.out.println(ase.getMessage());
        //ace.printStackTrace();

    } catch (AmazonClientException ace) {
        System.out.println(ace.getMessage());
        //ace.printStackTrace();

    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        //ex.printStackTrace();
    }
}

From source file:dynamok.source.DynamoDbSourceTask.java

License:Apache License

private SourceRecord toSourceRecord(Map<String, String> sourcePartition, String topic,
        StreamRecord dynamoRecord) {
    return new SourceRecord(sourcePartition,
            Collections.singletonMap(Keys.SEQNUM, dynamoRecord.getSequenceNumber()), topic, null,
            RecordMapper.attributesSchema(), RecordMapper.toConnect(dynamoRecord.getKeys()),
            RecordMapper.attributesSchema(), RecordMapper.toConnect(dynamoRecord.getNewImage()),
            dynamoRecord.getApproximateCreationDateTime().getTime());
}