3535/**
3636 * A bulk operation whose size has been calculated and content turned to a binary blob (to compute its size).
3737 */
38- class IngesterOperation {
39- private final RetryableBulkOperation repeatableOp ;
38+ class IngesterOperation < Context > {
39+ private final RetryableBulkOperation < Context > repeatableOp ;
4040 private final long size ;
4141
42- IngesterOperation (RetryableBulkOperation repeatableOp , long size ) {
42+ IngesterOperation (RetryableBulkOperation < Context > repeatableOp , long size ) {
4343 this .repeatableOp = repeatableOp ;
4444 this .size = size ;
4545 }
4646
47- public static IngesterOperation of (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
47+ public static < Context > IngesterOperation < Context > of (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
4848 switch (repeatableOp .operation ()._kind ()) {
4949 case Create :
5050 return createOperation (repeatableOp , mapper );
@@ -59,17 +59,33 @@ public static IngesterOperation of(RetryableBulkOperation repeatableOp, JsonpMap
5959 }
6060 }
6161
62- public RetryableBulkOperation repeatableOperation () {
62+ public RetryableBulkOperation < Context > repeatableOperation () {
6363 return this .repeatableOp ;
6464 }
6565
6666 public long size () {
6767 return this .size ;
6868 }
6969
70- private static IngesterOperation createOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
70+ public BulkOperation operation () {
71+ return repeatableOp .operation ();
72+ }
73+
74+ public Context context () {
75+ return repeatableOp .context ();
76+ }
77+
78+ public boolean isSendable () {
79+ return repeatableOp .isSendable ();
80+ }
81+
82+ public boolean canRetry () {
83+ return repeatableOp .canRetry ();
84+ }
85+
86+ private static <Context > IngesterOperation <Context > createOperation (RetryableBulkOperation <Context > repeatableOp , JsonpMapper mapper ) {
7187 CreateOperation <?> create = repeatableOp .operation ().create ();
72- RetryableBulkOperation newOperation ;
88+ RetryableBulkOperation < Context > newOperation ;
7389
7490 long size = basePropertiesSize (create );
7591
@@ -80,18 +96,18 @@ private static IngesterOperation createOperation(RetryableBulkOperation repeatab
8096 } else {
8197 BinaryData binaryDoc = BinaryData .of (create .document (), mapper );
8298 size += binaryDoc .size ();
83- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .create (idx -> {
99+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .create (idx -> {
84100 copyCreateProperties (create , idx );
85101 return idx .document (binaryDoc );
86102 })),repeatableOp .context (),repeatableOp .retries ());
87103 }
88104
89- return new IngesterOperation (newOperation , size );
105+ return new IngesterOperation <> (newOperation , size );
90106 }
91107
92- private static IngesterOperation indexOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
108+ private static < Context > IngesterOperation < Context > indexOperation (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
93109 IndexOperation <?> index = repeatableOp .operation ().index ();
94- RetryableBulkOperation newOperation ;
110+ RetryableBulkOperation < Context > newOperation ;
95111
96112 long size = basePropertiesSize (index );
97113
@@ -102,18 +118,18 @@ private static IngesterOperation indexOperation(RetryableBulkOperation repeatabl
102118 } else {
103119 BinaryData binaryDoc = BinaryData .of (index .document (), mapper );
104120 size += binaryDoc .size ();
105- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .index (idx -> {
121+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .index (idx -> {
106122 copyIndexProperties (index , idx );
107123 return idx .document (binaryDoc );
108124 })),repeatableOp .context (),repeatableOp .retries ());
109125 }
110126
111- return new IngesterOperation (newOperation , size );
127+ return new IngesterOperation <> (newOperation , size );
112128 }
113129
114- private static IngesterOperation updateOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
130+ private static < Context > IngesterOperation < Context > updateOperation (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
115131 UpdateOperation <?, ?> update = repeatableOp .operation ().update ();
116- RetryableBulkOperation newOperation ;
132+ RetryableBulkOperation < Context > newOperation ;
117133
118134 long size = basePropertiesSize (update ) +
119135 size ("retry_on_conflict" , update .retryOnConflict ()) +
@@ -126,7 +142,7 @@ private static IngesterOperation updateOperation(RetryableBulkOperation repeatab
126142 } else {
127143 BinaryData action = BinaryData .of (update .action (), mapper );
128144 size += action .size ();
129- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .update (u -> {
145+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .update (u -> {
130146 copyBaseProperties (update , u );
131147 return u
132148 .binaryAction (action )
@@ -135,12 +151,12 @@ private static IngesterOperation updateOperation(RetryableBulkOperation repeatab
135151 })),repeatableOp .context (),repeatableOp .retries ());
136152 }
137153
138- return new IngesterOperation (newOperation , size );
154+ return new IngesterOperation <> (newOperation , size );
139155 }
140156
141- private static IngesterOperation deleteOperation (RetryableBulkOperation repeatableOp ) {
157+ private static < Context > IngesterOperation < Context > deleteOperation (RetryableBulkOperation < Context > repeatableOp ) {
142158 DeleteOperation delete = repeatableOp .operation ().delete ();
143- return new IngesterOperation (repeatableOp , basePropertiesSize (delete ));
159+ return new IngesterOperation <> (repeatableOp , basePropertiesSize (delete ));
144160 }
145161
146162
0 commit comments