Example usage for com.amazonaws.services.dynamodbv2.model PutRequest setItem

List of usage examples for com.amazonaws.services.dynamodbv2.model PutRequest setItem

Introduction

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

Prototype


public void setItem(java.util.Map<String, AttributeValue> item) 

Source Link

Document

A map of attribute name to attribute values, representing the primary key of an item to be processed by PutItem.

Usage

From source file:dynamok.sink.DynamoDbSinkTask.java

License:Apache License

private void insert(ValueSource valueSource, Schema schema, Object value, PutRequest put) {
    final AttributeValue attributeValue;
    try {/*  ww w. j  a  va 2 s  .  co m*/
        attributeValue = schema == null ? AttributeValueConverter.toAttributeValueSchemaless(value)
                : AttributeValueConverter.toAttributeValue(schema, value);
    } catch (DataException e) {
        log.error("Failed to convert record with schema={} value={}", schema, value, e);
        throw e;
    }

    final String topAttributeName = valueSource.topAttributeName(config);
    if (!topAttributeName.isEmpty()) {
        put.addItemEntry(topAttributeName, attributeValue);
    } else if (attributeValue.getM() != null) {
        put.setItem(attributeValue.getM());
    } else {
        throw new ConnectException("No top attribute name configured for " + valueSource
                + ", and it could not be converted to Map: " + attributeValue);
    }
}