Skip to content

Commit 7265c86

Browse files
committed
---
yaml --- r: 1947 b: refs/heads/pubsub-alpha c: f0ce897 h: refs/heads/master i: 1945: c2373a7 1943: 2affb64
1 parent 07c10fc commit 7265c86

6 files changed

Lines changed: 19 additions & 56 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ refs/heads/master: 689bbb466df4b2d5d2483d6edb8ac5c7c7f7c6fa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
6-
refs/heads/pubsub-alpha: 2ffac2db4744375d2c5cbd8e1f84475ffcca4347
6+
refs/heads/pubsub-alpha: f0ce8972e1a414a620de6d9c83f82cbce7520264
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
88
refs/heads/update-datastore: 482954f2c5055231e5b3122ea91d2ba00ce8187c
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

branches/pubsub-alpha/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BatchRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Builder delete(String bucket, String blob, BlobSourceOption... options) {
5858
* Delete the given blob.
5959
*/
6060
public Builder delete(BlobId blob, BlobSourceOption... options) {
61-
toDelete.put(blob, Lists.newArrayList(BlobSourceOption.setGeneration(blob, options)));
61+
toDelete.put(blob, Lists.newArrayList(options));
6262
return this;
6363
}
6464

@@ -82,7 +82,7 @@ public Builder get(String bucket, String blob, BlobGetOption... options) {
8282
* Retrieve metadata for the given blob.
8383
*/
8484
public Builder get(BlobId blob, BlobGetOption... options) {
85-
toGet.put(blob, Lists.newArrayList(BlobGetOption.setGeneration(blob, options)));
85+
toGet.put(blob, Lists.newArrayList(options));
8686
return this;
8787
}
8888

branches/pubsub-alpha/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -526,26 +526,6 @@ public static BlobSourceOption metagenerationMatch(long metageneration) {
526526
public static BlobSourceOption metagenerationNotMatch(long metageneration) {
527527
return new BlobSourceOption(StorageRpc.Option.IF_METAGENERATION_NOT_MATCH, metageneration);
528528
}
529-
530-
static BlobSourceOption[] setGeneration(BlobId blobId, Iterable<BlobSourceOption> options) {
531-
return setGeneration(blobId, Iterables.toArray(options, BlobSourceOption.class));
532-
}
533-
534-
static BlobSourceOption[] setGeneration(BlobId blobId, BlobSourceOption... options) {
535-
BlobSourceOption[] updatedOptions = new BlobSourceOption[options.length];
536-
int index = 0;
537-
for (BlobSourceOption option : options) {
538-
if ((option.rpcOption() == StorageRpc.Option.IF_GENERATION_MATCH
539-
|| option.rpcOption() == StorageRpc.Option.IF_GENERATION_NOT_MATCH)
540-
&& option.value() == null) {
541-
updatedOptions[index] = new BlobSourceOption(option.rpcOption(), blobId.generation());
542-
} else {
543-
updatedOptions[index] = option;
544-
}
545-
index++;
546-
}
547-
return updatedOptions;
548-
}
549529
}
550530

551531
/**
@@ -622,22 +602,6 @@ public static BlobGetOption metagenerationNotMatch(long metageneration) {
622602
public static BlobGetOption fields(BlobField... fields) {
623603
return new BlobGetOption(StorageRpc.Option.FIELDS, BlobField.selector(fields));
624604
}
625-
626-
static BlobGetOption[] setGeneration(BlobId blobId, BlobGetOption... options) {
627-
BlobGetOption[] updatedOptions = new BlobGetOption[options.length];
628-
int index = 0;
629-
for (BlobGetOption option : options) {
630-
if ((option.rpcOption() == StorageRpc.Option.IF_GENERATION_MATCH
631-
|| option.rpcOption() == StorageRpc.Option.IF_GENERATION_NOT_MATCH)
632-
&& option.value() == null) {
633-
updatedOptions[index] = new BlobGetOption(option.rpcOption(), blobId.generation());
634-
} else {
635-
updatedOptions[index] = option;
636-
}
637-
index++;
638-
}
639-
return updatedOptions;
640-
}
641605
}
642606

643607
/**
@@ -1091,8 +1055,7 @@ public CopyRequest build() {
10911055

10921056
private CopyRequest(Builder builder) {
10931057
source = checkNotNull(builder.source);
1094-
sourceOptions = ImmutableList.copyOf(
1095-
BlobSourceOption.setGeneration(source, builder.sourceOptions));
1058+
sourceOptions = ImmutableList.copyOf(builder.sourceOptions);
10961059
target = checkNotNull(builder.target);
10971060
targetOptions = ImmutableList.copyOf(builder.targetOptions);
10981061
megabytesCopiedPerChunk = builder.megabytesCopiedPerChunk;

branches/pubsub-alpha/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ public BlobInfo get(String bucket, String blob, BlobGetOption... options) {
199199
@Override
200200
public BlobInfo get(BlobId blob, BlobGetOption... options) {
201201
final StorageObject storedObject = blob.toPb();
202-
final Map<StorageRpc.Option, ?> optionsMap =
203-
optionMap(BlobGetOption.setGeneration(blob, options));
202+
final Map<StorageRpc.Option, ?> optionsMap = optionMap(blob, options);
204203
try {
205204
StorageObject storageObject = runWithRetries(new Callable<StorageObject>() {
206205
@Override
@@ -406,8 +405,7 @@ public boolean delete(String bucket, String blob, BlobSourceOption... options) {
406405
@Override
407406
public boolean delete(BlobId blob, BlobSourceOption... options) {
408407
final StorageObject storageObject = blob.toPb();
409-
final Map<StorageRpc.Option, ?> optionsMap =
410-
optionMap(BlobSourceOption.setGeneration(blob, options));
408+
final Map<StorageRpc.Option, ?> optionsMap = optionMap(blob, options);
411409
try {
412410
return runWithRetries(new Callable<Boolean>() {
413411
@Override
@@ -453,7 +451,7 @@ public StorageObject call() {
453451
public CopyWriter copy(final CopyRequest copyRequest) {
454452
final StorageObject source = copyRequest.source().toPb();
455453
final Map<StorageRpc.Option, ?> sourceOptions =
456-
optionMap(null, null, copyRequest.sourceOptions(), true);
454+
optionMap(copyRequest.source().generation(), null, copyRequest.sourceOptions(), true);
457455
final StorageObject target = copyRequest.target().toPb();
458456
final Map<StorageRpc.Option, ?> targetOptions = optionMap(copyRequest.target().generation(),
459457
copyRequest.target().metageneration(), copyRequest.targetOptions());
@@ -479,8 +477,7 @@ public byte[] readAllBytes(String bucket, String blob, BlobSourceOption... optio
479477
@Override
480478
public byte[] readAllBytes(BlobId blob, BlobSourceOption... options) {
481479
final StorageObject storageObject = blob.toPb();
482-
final Map<StorageRpc.Option, ?> optionsMap =
483-
optionMap(BlobSourceOption.setGeneration(blob, options));
480+
final Map<StorageRpc.Option, ?> optionsMap = optionMap(blob, options);
484481
try {
485482
return runWithRetries(new Callable<byte[]>() {
486483
@Override
@@ -499,7 +496,7 @@ public BatchResponse apply(BatchRequest batchRequest) {
499496
Lists.newArrayListWithCapacity(batchRequest.toDelete().size());
500497
for (Map.Entry<BlobId, Iterable<BlobSourceOption>> entry : batchRequest.toDelete().entrySet()) {
501498
BlobId blob = entry.getKey();
502-
Map<StorageRpc.Option, ?> optionsMap = optionMap(null, null, entry.getValue());
499+
Map<StorageRpc.Option, ?> optionsMap = optionMap(blob.generation(), null, entry.getValue());
503500
StorageObject storageObject = blob.toPb();
504501
toDelete.add(Tuple.<StorageObject, Map<StorageRpc.Option, ?>>of(storageObject, optionsMap));
505502
}
@@ -516,7 +513,7 @@ public BatchResponse apply(BatchRequest batchRequest) {
516513
Lists.newArrayListWithCapacity(batchRequest.toGet().size());
517514
for (Map.Entry<BlobId, Iterable<BlobGetOption>> entry : batchRequest.toGet().entrySet()) {
518515
BlobId blob = entry.getKey();
519-
Map<StorageRpc.Option, ?> optionsMap = optionMap(null, null, entry.getValue());
516+
Map<StorageRpc.Option, ?> optionsMap = optionMap(blob.generation(), null, entry.getValue());
520517
toGet.add(Tuple.<StorageObject, Map<StorageRpc.Option, ?>>of(blob.toPb(), optionsMap));
521518
}
522519
StorageRpc.BatchResponse response =
@@ -561,8 +558,7 @@ public BlobReadChannel reader(String bucket, String blob, BlobSourceOption... op
561558

562559
@Override
563560
public BlobReadChannel reader(BlobId blob, BlobSourceOption... options) {
564-
Map<StorageRpc.Option, ?> optionsMap =
565-
optionMap(BlobSourceOption.setGeneration(blob, options));
561+
Map<StorageRpc.Option, ?> optionsMap = optionMap(blob, options);
566562
return new BlobReadChannelImpl(options(), blob, optionsMap);
567563
}
568564

@@ -746,4 +742,8 @@ private static <T> void addToOptionMap(StorageRpc.Option getOption, StorageRpc.O
746742
private Map<StorageRpc.Option, ?> optionMap(BlobInfo blobInfo, Option... options) {
747743
return optionMap(blobInfo.generation(), blobInfo.metageneration(), options);
748744
}
745+
746+
private Map<StorageRpc.Option, ?> optionMap(BlobId blobId, Option... options) {
747+
return optionMap(blobId.generation(), null, options);
748+
}
749749
}

branches/pubsub-alpha/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BatchRequestTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testBatchRequest() {
5252
Entry<BlobId, Iterable<BlobSourceOption>> delete = deletes.next();
5353
assertEquals(BlobId.of("b1", "o1", 1L), delete.getKey());
5454
assertEquals(1, Iterables.size(delete.getValue()));
55-
assertEquals(BlobSourceOption.generationMatch(1L), Iterables.getFirst(delete.getValue(), null));
55+
assertEquals(BlobSourceOption.generationMatch(), Iterables.getFirst(delete.getValue(), null));
5656
delete = deletes.next();
5757
assertEquals(BlobId.of("b1", "o2"), delete.getKey());
5858
assertEquals(2, Iterables.size(delete.getValue()));
@@ -77,7 +77,7 @@ public void testBatchRequest() {
7777
Entry<BlobId, Iterable<BlobGetOption>> get = gets.next();
7878
assertEquals(BlobId.of("b3", "o1", 1L), get.getKey());
7979
assertEquals(1, Iterables.size(get.getValue()));
80-
assertEquals(BlobGetOption.generationMatch(1), Iterables.getFirst(get.getValue(), null));
80+
assertEquals(BlobGetOption.generationMatch(), Iterables.getFirst(get.getValue(), null));
8181
get = gets.next();
8282
assertEquals(BlobId.of("b3", "o2"), get.getKey());
8383
assertEquals(1, Iterables.size(get.getValue()));

branches/pubsub-alpha/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,8 @@ public void testCopyWithOptionsFromBlobId() {
867867
.build();
868868
StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(),
869869
BLOB_SOURCE_OPTIONS_COPY, request.target().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null);
870-
StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L,
871-
false, "token", 21L);
870+
StorageRpc.RewriteResponse rpcResponse =
871+
new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L);
872872
EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse);
873873
EasyMock.replay(storageRpcMock);
874874
storage = options.service();

0 commit comments

Comments
 (0)