Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Custom Part Metadata Decorator to ParallelCompositeUploadConfig #2434

Merged
merged 24 commits into from
Mar 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
set customtime directly instead of via metadata builder
  • Loading branch information
sydney-munro committed Mar 15, 2024
commit fe168d6c3d2afd12716dbaa846943710cdd6adb4
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.google.cloud.storage.MetadataField.PartRange;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartCleanupStrategy;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartCustomTimeStrategy;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartCustomTimeStrategy.CustomTimeSet;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartNamingStrategy;
import com.google.cloud.storage.Storage.ComposeRequest;
import com.google.cloud.storage.UnifiedOpts.Crc32cMatch;
Expand Down Expand Up @@ -85,8 +84,6 @@ final class ParallelCompositeUploadWritableByteChannel implements BufferedWritab
MetadataField.forPartRange("pcu_partIndex");
private static final MetadataField<Long> OBJECT_OFFSET =
MetadataField.forLong("pcu_objectOffset");
private static final MetadataField<String> CUSTOM_TIME =
MetadataField.forString("CustomTime");
private static final Comparator<BlobInfo> comparator =
Comparator.comparing(PART_INDEX::readFrom, PartRange.COMP);
private static final Predicate<ObjectTargetOpt> TO_EXCLUDE_FROM_PARTS;
Expand Down Expand Up @@ -434,12 +431,12 @@ private BlobInfo definePart(BlobInfo ultimateObject, PartRange partRange, long o
FINAL_OBJECT_NAME.appendTo(id.getName(), builder);
PART_INDEX.appendTo(partRange, builder);
OBJECT_OFFSET.appendTo(offset, builder);
b.setMetadata(builder.build());
if(partCustomTimeStrategy.isSetCustomTime()) {
Duration timeInFuture = partCustomTimeStrategy.getTimeInFuture();
OffsetDateTime now = OffsetDateTime.now();
CUSTOM_TIME.appendTo(now.plus(timeInFuture).toString(), builder);
b.setCustomTimeOffsetDateTime(now.plus(timeInFuture));
}
b.setMetadata(builder.build());
return b.build();
}

Expand Down