forked from aws/aws-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamoDBScanExpression.java
More file actions
147 lines (131 loc) · 5.24 KB
/
DynamoDBScanExpression.java
File metadata and controls
147 lines (131 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Copyright 2011-2013 Amazon Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://aws.amazon.com/apache2.0
*
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and
* limitations under the License.
*/
package com.amazonaws.services.dynamodb.datamodeling;
import java.util.HashMap;
import java.util.Map;
import com.amazonaws.services.dynamodb.model.ComparisonOperator;
import com.amazonaws.services.dynamodb.model.Condition;
import com.amazonaws.services.dynamodb.model.Key;
/**
* Options for filtering results from a scan operation. For example, callers can
* specify filter conditions so that only objects whose attributes match
* different conditions are returned (see {@link ComparisonOperator} for more
* information on the available comparison types).
*
* @see DynamoDBMapper#scan(Class, DynamoDBScanExpression)
*/
@Deprecated
public class DynamoDBScanExpression {
/** Optional filter to limit the results of the scan. */
private Map<String, Condition> scanFilter;
private Key exclusiveStartKey;
private Integer limit;
/**
* Sets the scan filter to the map of attribute names to conditions.
*
* @param scanFilter
* The map of attribute names to conditions to use when filtering
* scan results.
*/
public void setScanFilter(Map<String, Condition> scanFilter) {
this.scanFilter = scanFilter;
}
/**
* Returns the scan filter as a map of attribute names to conditions.
*
* @return The scan filter as a map of attribute names to conditions.
*/
public Map<String, Condition> getScanFilter() {
return scanFilter;
}
/**
* Adds a new filter condition to the current scan filter.
*
* @param attributeName
* The name of the attribute on which the specified condition
* operates.
* @param condition
* The condition which describes how the specified attribute is
* compared and if a row of data is included in the results
* returned by the scan operation.
*/
public void addFilterCondition(String attributeName, Condition condition) {
if ( scanFilter == null )
scanFilter = new HashMap<String, Condition>();
scanFilter.put(attributeName, condition);
}
/**
* Returns the exclusive start key for this scan.
*/
public Key getExclusiveStartKey() {
return exclusiveStartKey;
}
/**
* Sets the exclusive start key for this scan.
*/
public void setExclusiveStartKey(Key exclusiveStartKey) {
this.exclusiveStartKey = exclusiveStartKey;
}
/**
* Sets the exclusive start key for this scan and returns a pointer to this
* object for method-chaining.
*/
public DynamoDBScanExpression withExclusiveStartKey(Key exclusiveStartKey) {
this.exclusiveStartKey = exclusiveStartKey;
return this;
}
/**
* Returns the limit of items to scan during this scan.
* <p>
* Use with caution. Please note that this is <b>not</b> the same as the
* number of items to return from the scan operation -- the operation will
* cease and return as soon as this many items are scanned, even if no
* matching results are found. Furthermore, {@link PaginatedScanList} will
* execute as many scan operations as necessary until it either reaches the
* end of the result set as indicated by DynamoDB or enough elements are
* available to fulfill the list operation (e.g. iteration). Therefore,
* except when scanning without a scan filter, it's usually bad practice to
* set a low limit, since doing so will often generate the same amount of
* traffic to DynamoDB but with a greater number of round trips and
* therefore more overall latency.
*/
public Integer getLimit() {
return limit;
}
/**
* Sets the limit of items to scan during this scan. Please note that this
* is <b>not</b> the same as the number of items to return from the scan
* operation -- the operation will cease and return as soon as this many
* items are scanned, even if no matching results are found.
*
* @see DynamoDBScanExpression#getLimit()
*/
public void setLimit(Integer limit) {
this.limit = limit;
}
/**
* Sets the limit of items to scan and returns a pointer to this object for
* method-chaining. Please note that this is <b>not</b> the same as the
* number of items to return from the scan operation -- the operation will
* cease and return as soon as this many items are scanned, even if no
* matching results are found.
*
* @see DynamoDBScanExpression#getLimit()
*/
public DynamoDBScanExpression withLimit(Integer limit) {
this.limit = limit;
return this;
}
}