Skip to content

Commit 6f5b350

Browse files
committed
Added substantial functionality for the virtual lists, allowing database
operations to be executed against the database without going through mapping to POJOs
1 parent 1bf97dc commit 6f5b350

File tree

11 files changed

+825
-362
lines changed

11 files changed

+825
-362
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,9 @@ classes:
16021602
- **setter**:
16031603

16041604

1605+
## Virtual Lists
1606+
1607+
When mapping a Java object to Aerospike the most common operations to do are to save the whole object and load the whole object. The AeroMapper is set up primarily for these use cases. However, there are cases where it makes sense to manipulate objects directly in the database, particularly when it comes to manipulating lists and maps. This functionality is provided via virtual lists.
16051608

16061609
----
16071610

@@ -1610,7 +1613,7 @@ classes:
16101613
- maps of embedded objects
16111614
- lists of referenced objects
16121615
- maps of referenced objects
1613-
- Add in a method to add an entry to a collection, get a range from a collection, delete from a collection
1616+
- Document virtual lists
16141617
- Validate some of the limits, eg bin name length, set name length, etc.
16151618
- Make all maps (esp Embedded ones) K_ORDERED
16161619
- Add interface to adaptiveMap, including changing EmbedType

src/main/java/com/aerospike/mapper/tools/AeroMapper.java

Lines changed: 71 additions & 325 deletions
Large diffs are not rendered by default.

src/main/java/com/aerospike/mapper/tools/DeferredOperation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
public interface DeferredOperation {
66
public Operation getOperation(OperationParameters operationParams);
77
public ResultsUnpacker[] getUnpackers(OperationParameters operationParams);
8+
public boolean isGetOperation();
89
}

src/main/java/com/aerospike/mapper/tools/Interactor.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import javax.validation.constraints.NotNull;
44

5-
import com.aerospike.client.AerospikeException;
65
import com.aerospike.client.Operation;
76

87
public class Interactor {
@@ -23,9 +22,9 @@ public Interactor(@NotNull DeferredOperation deferredOperation) {
2322
this.deferredParameters = new OperationParameters();
2423
}
2524

26-
public void setNeedsResult(boolean needsResult) {
25+
public void setNeedsResultOfType(ReturnType returnType) {
2726
if (this.deferredParameters != null) {
28-
this.deferredParameters.setNeedsResult(needsResult);
27+
this.deferredParameters.setNeedsResultOfType(returnType);
2928
}
3029
}
3130
public Operation getOperation() {
@@ -44,19 +43,24 @@ public Object getResult(Object rawResult) {
4443
return result;
4544
}
4645
public boolean isWriteOperation() {
47-
switch (operation.type) {
48-
case ADD:
49-
case APPEND:
50-
case BIT_MODIFY:
51-
case CDT_MODIFY:
52-
case DELETE:
53-
case MAP_MODIFY:
54-
case PREPEND:
55-
case TOUCH:
56-
case WRITE:
57-
return true;
58-
default:
59-
return false;
46+
if (this.operation != null) {
47+
switch (operation.type) {
48+
case ADD:
49+
case APPEND:
50+
case BIT_MODIFY:
51+
case CDT_MODIFY:
52+
case DELETE:
53+
case MAP_MODIFY:
54+
case PREPEND:
55+
case TOUCH:
56+
case WRITE:
57+
return true;
58+
default:
59+
return false;
60+
}
61+
}
62+
else {
63+
return !this.deferredOperation.isGetOperation();
6064
}
6165
}
6266
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.aerospike.mapper.tools;
22

33
public class OperationParameters {
4-
private boolean needsResult;
4+
private ReturnType needsResultOfType = ReturnType.NONE;
55

66
public OperationParameters() {
77
}
8-
public OperationParameters(boolean needsResult) {
8+
public OperationParameters(ReturnType needsResultOfType) {
99
super();
10-
this.needsResult = needsResult;
10+
this.needsResultOfType = needsResultOfType;
1111
}
12-
public boolean needsResult() {
13-
return needsResult;
12+
public ReturnType getNeedsResultOfType() {
13+
return needsResultOfType;
1414
}
15-
public void setNeedsResult(boolean needsResult) {
16-
this.needsResult = needsResult;
15+
public void setNeedsResultOfType(ReturnType needsResultOfType) {
16+
this.needsResultOfType = needsResultOfType;
1717
}
1818
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.aerospike.mapper.tools;
2+
3+
public enum ReturnType {
4+
DEFAULT,
5+
COUNT,
6+
INDEX,
7+
ELEMENTS,
8+
NONE
9+
}

0 commit comments

Comments
 (0)