2727import java .io .InputStream ;
2828import java .util .List ;
2929import java .util .Map ;
30+ import java .util .Objects ;
3031
3132public interface StorageRpc {
3233
@@ -132,6 +133,89 @@ public BatchResponse(Map<StorageObject, Tuple<Boolean, StorageException>> delete
132133 }
133134 }
134135
136+ class RewriteRequest {
137+
138+ public final StorageObject source ;
139+ public final Map <StorageRpc .Option , ?> sourceOptions ;
140+ public final StorageObject target ;
141+ public final Map <StorageRpc .Option , ?> targetOptions ;
142+ public final Long megabytesRewrittenPerCall ;
143+
144+ public RewriteRequest (StorageObject source , Map <StorageRpc .Option , ?> sourceOptions ,
145+ StorageObject target , Map <StorageRpc .Option , ?> targetOptions ,
146+ Long megabytesRewrittenPerCall ) {
147+ this .source = source ;
148+ this .sourceOptions = sourceOptions ;
149+ this .target = target ;
150+ this .targetOptions = targetOptions ;
151+ this .megabytesRewrittenPerCall = megabytesRewrittenPerCall ;
152+ }
153+
154+ @ Override
155+ public boolean equals (Object obj ) {
156+ if (obj == null ) {
157+ return false ;
158+ }
159+ if (!(obj instanceof RewriteRequest )) {
160+ return false ;
161+ }
162+ final RewriteRequest other = (RewriteRequest ) obj ;
163+ return Objects .equals (this .source , other .source )
164+ && Objects .equals (this .sourceOptions , other .sourceOptions )
165+ && Objects .equals (this .target , other .target )
166+ && Objects .equals (this .targetOptions , other .targetOptions )
167+ && Objects .equals (this .megabytesRewrittenPerCall , other .megabytesRewrittenPerCall );
168+ }
169+
170+ @ Override
171+ public int hashCode () {
172+ return Objects .hash (source , sourceOptions , target , targetOptions , megabytesRewrittenPerCall );
173+ }
174+ }
175+
176+ class RewriteResponse {
177+
178+ public final RewriteRequest rewriteRequest ;
179+ public final StorageObject result ;
180+ public final long blobSize ;
181+ public final boolean isDone ;
182+ public final String rewriteToken ;
183+ public final long totalBytesRewritten ;
184+
185+ public RewriteResponse (RewriteRequest rewriteRequest , StorageObject result , long blobSize ,
186+ boolean isDone , String rewriteToken , long totalBytesRewritten ) {
187+ this .rewriteRequest = rewriteRequest ;
188+ this .result = result ;
189+ this .blobSize = blobSize ;
190+ this .isDone = isDone ;
191+ this .rewriteToken = rewriteToken ;
192+ this .totalBytesRewritten = totalBytesRewritten ;
193+ }
194+
195+ @ Override
196+ public boolean equals (Object obj ) {
197+ if (obj == null ) {
198+ return false ;
199+ }
200+ if (!(obj instanceof RewriteResponse )) {
201+ return false ;
202+ }
203+ final RewriteResponse other = (RewriteResponse ) obj ;
204+ return Objects .equals (this .rewriteRequest , other .rewriteRequest )
205+ && Objects .equals (this .result , other .result )
206+ && Objects .equals (this .rewriteToken , other .rewriteToken )
207+ && this .blobSize == other .blobSize
208+ && Objects .equals (this .isDone , other .isDone )
209+ && this .totalBytesRewritten == other .totalBytesRewritten ;
210+ }
211+
212+ @ Override
213+ public int hashCode () {
214+ return Objects .hash (rewriteRequest , result , blobSize , isDone , rewriteToken ,
215+ totalBytesRewritten );
216+ }
217+ }
218+
135219 Bucket create (Bucket bucket , Map <Option , ?> options ) throws StorageException ;
136220
137221 StorageObject create (StorageObject object , InputStream content , Map <Option , ?> options )
@@ -161,9 +245,6 @@ StorageObject patch(StorageObject storageObject, Map<Option, ?> options)
161245 StorageObject compose (Iterable <StorageObject > sources , StorageObject target ,
162246 Map <Option , ?> targetOptions ) throws StorageException ;
163247
164- StorageObject copy (StorageObject source , Map <Option , ?> sourceOptions ,
165- StorageObject target , Map <Option , ?> targetOptions ) throws StorageException ;
166-
167248 byte [] load (StorageObject storageObject , Map <Option , ?> options )
168249 throws StorageException ;
169250
@@ -174,4 +255,8 @@ byte[] read(StorageObject from, Map<Option, ?> options, long position, int bytes
174255
175256 void write (String uploadId , byte [] toWrite , int toWriteOffset , StorageObject dest ,
176257 long destOffset , int length , boolean last ) throws StorageException ;
258+
259+ RewriteResponse openRewrite (RewriteRequest rewriteRequest ) throws StorageException ;
260+
261+ RewriteResponse continueRewrite (RewriteResponse previousResponse ) throws StorageException ;
177262}
0 commit comments