Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Mar 14, 2024
1 parent 7f86b31 commit 06b5c87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ public ParallelCompositeUploadBlobWriteSessionConfig withPartCleanupStrategy(
partMetadataFieldDecorator);
}

/**
* Specify a Part Metadata Field decorator, this will manipulate the metadata associated with part
* files, the ultimate object metadata will remain unchanged.
*
* <p><i>Default: </i> {@link PartMetadataFieldDecorator#noOp()}
*
* @since 2.35.1 This new api is in preview and is subject to breaking changes.
* @param partMetadataFieldDecorator
* @return
*/
@BetaApi
public ParallelCompositeUploadBlobWriteSessionConfig withPartMetadataFieldDecorator(
PartMetadataFieldDecorator partMetadataFieldDecorator) {
Expand Down Expand Up @@ -644,7 +654,10 @@ public NoPrefix(SecureRandom rand) {
}

@Override
protected String fmtFields(String randomKey, String nameDigest, String partRange) {
protected String fmtFields(String randomKey, String ultimateObjectName, String partRange) {
HashCode hashCode =
OBJECT_NAME_HASH_FUNCTION.hashString(ultimateObjectName, StandardCharsets.UTF_8);
String nameDigest = B64.encodeToString(hashCode.asBytes());
return randomKey
+ FIELD_SEPARATOR
// todo: do we want to
Expand All @@ -661,6 +674,9 @@ protected String fmtFields(String randomKey, String nameDigest, String partRange
}

/**
* A Decorator which is used to manipulate metadata fields, specifically on the part files used in
* a Parallel Composite Upload
*
* @see #withPartMetadataFieldDecorator(PartMetadataFieldDecorator)
* @since 2.35.1 This new api is in preview and is subject to breaking changes.
*/
Expand All @@ -671,10 +687,13 @@ public abstract static class PartMetadataFieldDecorator implements Serializable
abstract PartMetadataFieldDecoratorInstance newInstance(Clock clock);

/**
* A strategy which will be used to generate a value for a part or intermediary compose object's
* CustomTime Metadata Field. This will be a time set a duration in the future which will serve
* to aid in part cleanup via OLM Rules.
* A decorator that is used to manipulate the Custom Time Metadata field of part files. {@link
* com.google.storage.v2.Object#customTime_}
*
* <p>When provided with a duration, a time in the future will be calculated for each part file
* upon upload, this new value can be used in OLM rules to cleanup abandoned part files.
*
* @see {@link https://cloud.google.com/storage/docs/lifecycle#dayssincecustomtime}
* @see #withPartMetadataFieldDecorator(PartMetadataFieldDecorator)
* @since 2.35.1 This new api is in preview and is subject to breaking changes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void partNameStrategy_noPrefix() throws Exception {
// random digest to spread over keyspace
() -> assertField(fmt, 0).hasLength(22),
// name digest
() -> assertField(fmt, 1).hasLength(8),
() -> assertField(fmt, 1).hasLength(22),
() -> assertField(fmt, 2).isEqualTo("0001-0032.part"));
}

Expand Down

0 comments on commit 06b5c87

Please sign in to comment.