3434/**
3535 * A bulk operation whose size has been calculated and content turned to a binary blob (to compute its size).
3636 */
37- class IngesterOperation {
38- private final RetryableBulkOperation repeatableOp ;
37+ class IngesterOperation < Context > {
38+ private final RetryableBulkOperation < Context > repeatableOp ;
3939 private final long size ;
4040
41- IngesterOperation (RetryableBulkOperation repeatableOp , long size ) {
41+ IngesterOperation (RetryableBulkOperation < Context > repeatableOp , long size ) {
4242 this .repeatableOp = repeatableOp ;
4343 this .size = size ;
4444 }
4545
46- public static IngesterOperation of (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
46+ public static < Context > IngesterOperation < Context > of (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
4747 switch (repeatableOp .operation ()._kind ()) {
4848 case Create :
4949 return createOperation (repeatableOp , mapper );
@@ -58,17 +58,33 @@ public static IngesterOperation of(RetryableBulkOperation repeatableOp, JsonpMap
5858 }
5959 }
6060
61- public RetryableBulkOperation repeatableOperation () {
61+ public RetryableBulkOperation < Context > repeatableOperation () {
6262 return this .repeatableOp ;
6363 }
6464
6565 public long size () {
6666 return this .size ;
6767 }
6868
69- private static IngesterOperation createOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
69+ public BulkOperation operation () {
70+ return repeatableOp .operation ();
71+ }
72+
73+ public Context context () {
74+ return repeatableOp .context ();
75+ }
76+
77+ public boolean isSendable () {
78+ return repeatableOp .isSendable ();
79+ }
80+
81+ public boolean canRetry () {
82+ return repeatableOp .canRetry ();
83+ }
84+
85+ private static <Context > IngesterOperation <Context > createOperation (RetryableBulkOperation <Context > repeatableOp , JsonpMapper mapper ) {
7086 CreateOperation <?> create = repeatableOp .operation ().create ();
71- RetryableBulkOperation newOperation ;
87+ RetryableBulkOperation < Context > newOperation ;
7288
7389 long size = basePropertiesSize (create );
7490
@@ -79,18 +95,18 @@ private static IngesterOperation createOperation(RetryableBulkOperation repeatab
7995 } else {
8096 BinaryData binaryDoc = BinaryData .of (create .document (), mapper );
8197 size += binaryDoc .size ();
82- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .create (idx -> {
98+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .create (idx -> {
8399 copyCreateProperties (create , idx );
84100 return idx .document (binaryDoc );
85101 })),repeatableOp .context (),repeatableOp .retries ());
86102 }
87103
88- return new IngesterOperation (newOperation , size );
104+ return new IngesterOperation <> (newOperation , size );
89105 }
90106
91- private static IngesterOperation indexOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
107+ private static < Context > IngesterOperation < Context > indexOperation (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
92108 IndexOperation <?> index = repeatableOp .operation ().index ();
93- RetryableBulkOperation newOperation ;
109+ RetryableBulkOperation < Context > newOperation ;
94110
95111 long size = basePropertiesSize (index );
96112
@@ -101,18 +117,18 @@ private static IngesterOperation indexOperation(RetryableBulkOperation repeatabl
101117 } else {
102118 BinaryData binaryDoc = BinaryData .of (index .document (), mapper );
103119 size += binaryDoc .size ();
104- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .index (idx -> {
120+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .index (idx -> {
105121 copyIndexProperties (index , idx );
106122 return idx .document (binaryDoc );
107123 })),repeatableOp .context (),repeatableOp .retries ());
108124 }
109125
110- return new IngesterOperation (newOperation , size );
126+ return new IngesterOperation <> (newOperation , size );
111127 }
112128
113- private static IngesterOperation updateOperation (RetryableBulkOperation repeatableOp , JsonpMapper mapper ) {
129+ private static < Context > IngesterOperation < Context > updateOperation (RetryableBulkOperation < Context > repeatableOp , JsonpMapper mapper ) {
114130 UpdateOperation <?, ?> update = repeatableOp .operation ().update ();
115- RetryableBulkOperation newOperation ;
131+ RetryableBulkOperation < Context > newOperation ;
116132
117133 long size = basePropertiesSize (update ) +
118134 size ("retry_on_conflict" , update .retryOnConflict ()) +
@@ -125,7 +141,7 @@ private static IngesterOperation updateOperation(RetryableBulkOperation repeatab
125141 } else {
126142 BinaryData action = BinaryData .of (update .action (), mapper );
127143 size += action .size ();
128- newOperation = new RetryableBulkOperation (BulkOperation .of (bo -> bo .update (u -> {
144+ newOperation = new RetryableBulkOperation <> (BulkOperation .of (bo -> bo .update (u -> {
129145 copyBaseProperties (update , u );
130146 return u
131147 .binaryAction (action )
@@ -134,12 +150,12 @@ private static IngesterOperation updateOperation(RetryableBulkOperation repeatab
134150 })),repeatableOp .context (),repeatableOp .retries ());
135151 }
136152
137- return new IngesterOperation (newOperation , size );
153+ return new IngesterOperation <> (newOperation , size );
138154 }
139155
140- private static IngesterOperation deleteOperation (RetryableBulkOperation repeatableOp ) {
156+ private static < Context > IngesterOperation < Context > deleteOperation (RetryableBulkOperation < Context > repeatableOp ) {
141157 DeleteOperation delete = repeatableOp .operation ().delete ();
142- return new IngesterOperation (repeatableOp , basePropertiesSize (delete ));
158+ return new IngesterOperation <> (repeatableOp , basePropertiesSize (delete ));
143159 }
144160
145161
0 commit comments