List of usage examples for com.amazonaws.services.dynamodbv2.model DeleteItemRequest DeleteItemRequest
public DeleteItemRequest()
From source file:amazon.dynamodb.model.DeletePointRequest.java
License:Open Source License
public DeletePointRequest(GeoPunto geoPoint, AttributeValue rangeKeyValue) { deleteItemRequest = new DeleteItemRequest(); deleteItemRequest.setKey(new HashMap<String, AttributeValue>()); this.geoPoint = geoPoint; this.rangeKeyValue = rangeKeyValue; }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.AbstractDynamoDbStore.java
License:Open Source License
protected DeleteItemRequest createDeleteItemRequest() { return new DeleteItemRequest().withTableName(tableName) .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.mutation.SingleUpdateWithCleanupWorker.java
License:Open Source License
@Override public Void call() throws BackendException { final UpdateItem updateBackoff = new UpdateItem(updateItemRequest, dynamoDbDelegate); final UpdateItemResult result = updateBackoff.runWithBackoff(); final Map<String, AttributeValue> item = result.getAttributes(); if (item == null) { // bail//from w w w . ja va 2s . c o m return null; } // If the record has no Titan columns left after deletions occur, then just delete the record if (item.containsKey(Constants.JANUSGRAPH_HASH_KEY) && item.size() == ATTRIBUTES_IN_EMPTY_SINGLE_ITEM) { final DeleteItem deleteBackoff = new DeleteItem(new DeleteItemRequest() .withTableName(updateItemRequest.getTableName()).withKey(updateItemRequest.getKey()), dynamoDbDelegate); deleteBackoff.runWithBackoff(); } // void return null; }
From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.AbstractDynamoDbTemplate.java
License:Apache License
protected final <T extends Item> void deleteUniqueConstraintIndexes(final T item, final ItemConfiguration itemConfiguration, final Collection<PropertyDescriptor> constraintPropertyDescriptors) { if (constraintPropertyDescriptors.isEmpty()) { return;/*from w w w.ja v a 2 s. c o m*/ } for (final UniqueConstraint uniqueConstraint : itemConfiguration.uniqueConstraints()) { final String uniqueConstraintPropertyName = uniqueConstraint.propertyName(); final PropertyDescriptor uniqueConstraintPropertyDescriptor = uniqueConstraint.propertyDescriptor(); if (constraintPropertyDescriptors.contains(uniqueConstraintPropertyDescriptor)) { final AttributeValue uniqueConstraintAttributeValue = DynamoDbPropertyMarshaller.getValue(item, uniqueConstraintPropertyDescriptor); if (uniqueConstraintAttributeValue != null) { if (uniqueConstraintAttributeValue.getS() != null) { uniqueConstraintAttributeValue.setS(uniqueConstraintAttributeValue.getS().toUpperCase()); } final Map<String, AttributeValue> key = new HashMap<>(); key.put("property", new AttributeValue(uniqueConstraintPropertyName)); key.put("value", uniqueConstraintAttributeValue); final String indexTableName = databaseSchemaHolder.schemaName() + "-indexes." + itemConfiguration.tableName(); final DeleteItemRequest itemRequest = new DeleteItemRequest().withTableName(indexTableName) .withKey(key); try { amazonDynamoDbClient.deleteItem(itemRequest); } catch (final AmazonServiceException e) { throw new PersistenceResourceFailureException( "Failed while attempting to perform DynamoDb Delete (for unique constraints)", e); } } } } }
From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.DynamoDbTemplate.java
License:Apache License
@Override public void delete(final Item item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers) { final ItemConfiguration itemConfiguration = getItemConfiguration(item.getClass()); final ItemId itemId = itemConfiguration.getItemId(item); final Map<String, AttributeValue> key = new HashMap<>(); final PrimaryKeyDefinition primaryKeyDefinition = itemConfiguration.primaryKeyDefinition(); key.put(primaryKeyDefinition.propertyName(), new AttributeValue(itemId.value())); if (CompoundPrimaryKeyDefinition.class.isAssignableFrom(primaryKeyDefinition.getClass())) { final CompoundPrimaryKeyDefinition compoundPrimaryKeyDefinition = (CompoundPrimaryKeyDefinition) primaryKeyDefinition; key.put(compoundPrimaryKeyDefinition.supportingPropertyName(), new AttributeValue(itemId.supportingValue())); }/*from w w w .j av a 2s . c o m*/ final Map<String, ExpectedAttributeValue> expectedResults = new HashMap<>(); expectedResults.put(VERSION_ATTRIBUTE, new ExpectedAttributeValue(new AttributeValue().withN(String.valueOf(item.getVersion())))); final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName(); final DeleteItemRequest deleteItemRequest = new DeleteItemRequest().withTableName(tableName).withKey(key) .withExpected(expectedResults); try { amazonDynamoDbClient.deleteItem(deleteItemRequest); } catch (final AmazonServiceException e) { throw new PersistenceResourceFailureException("Failure while attempting DynamoDb Delete", e); } deleteUniqueConstraintIndexes(item, itemConfiguration); }
From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.integration.DynamoDbDataGenerator.java
License:Apache License
void deletedCreatedItems() { for (final String id : createdItemIds) { final Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue(id)); final DeleteItemRequest deleteItemRequest = new DeleteItemRequest() .withTableName(unitTestSchemaName + "." + stubItemTableName).withKey(key); try {/* w ww .j a v a 2s .co m*/ amazonDynamoDbClient.deleteItem(deleteItemRequest); } catch (final Exception e) { // Ignore } } }
From source file:com.grublr.geo.model.DeletePointRequest.java
License:Open Source License
public DeletePointRequest(GeoPoint geoPoint, AttributeValue rangeKeyValue) { deleteItemRequest = new DeleteItemRequest(); deleteItemRequest.setKey(new HashMap<String, AttributeValue>()); this.geoPoint = geoPoint; this.rangeKeyValue = rangeKeyValue; }
From source file:com.makariev.dynamodb.preferences.UserPreferenceLowLevelAPIService.java
License:Open Source License
@Override public void delete(UserPreference up) { //Key primaryKey = new Key().withHashKeyElement(up); Map<String, AttributeValue> primaryKey = new HashMap<>(); AttributeValue avKey = new AttributeValue(); avKey.withN(String.valueOf(up.getUserNo())); primaryKey.put("userNo", avKey); DeleteItemRequest request = new DeleteItemRequest().withTableName(UserPreference.TABLE_NAME) .withKey(primaryKey);/*from ww w. j a v a2s . co m*/ dynamoDb.deleteItem(request); }
From source file:com.rapid7.diskstorage.dynamodb.DynamoDBStore.java
License:Open Source License
private final Collection<MutateWorker> createWorkersForDeletions(StaticBuffer hashKey, List<StaticBuffer> deletions, String tableName, DynamoDBStoreTransaction txh) { List<MutateWorker> workers = new LinkedList<>(); for (StaticBuffer rangeKey : deletions) { final Map<String, AttributeValue> keys = new ItemBuilder().hashKey(hashKey).rangeKey(rangeKey).build(); final Expression updateExpression = new MultiUpdateExpressionBuilder().hashKey(hashKey) .rangeKey(rangeKey).transaction(txh).build(); final DeleteItemRequest request = new DeleteItemRequest().withTableName(tableName) .withConditionExpression(updateExpression.getConditionExpression()) .withExpressionAttributeValues(updateExpression.getAttributeValues()) .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withKey(keys); workers.add(new DeleteItemWorker(request, client.delegate())); }// w w w. j a v a 2 s . c o m return workers; }
From source file:com.rapid7.diskstorage.dynamodb.mutation.SingleUpdateWithCleanupWorker.java
License:Open Source License
@Override public Void call() throws BackendException { ExponentialBackoff.UpdateItem updateBackoff = new ExponentialBackoff.UpdateItem(updateItemRequest, dynamoDBDelegate);/*from ww w . j ava2 s .com*/ UpdateItemResult result = updateBackoff.runWithBackoff(); final Map<String, AttributeValue> item = result.getAttributes(); if (item == null) { // bail return null; } // If the record has no Titan columns left after deletions occur, then just delete the record if (item.containsKey(Constants.TITAN_HASH_KEY) && item.size() == ATTRIBUTES_IN_EMPTY_SINGLE_ITEM) { ExponentialBackoff.DeleteItem deleteBackoff = new ExponentialBackoff.DeleteItem(new DeleteItemRequest() .withTableName(updateItemRequest.getTableName()).withKey(updateItemRequest.getKey()), dynamoDBDelegate); deleteBackoff.runWithBackoff(); } // void return null; }