noob-se7en commented on code in PR #18360:
URL: https://github.com/apache/pinot/pull/18360#discussion_r3190664283


##########
pinot-plugins/pinot-file-system/pinot-gcs/src/main/java/org/apache/pinot/plugin/filesystem/GcsPinotFS.java:
##########
@@ -353,9 +362,18 @@ public boolean touch(URI uri)
       LOGGER.info("touch {}", uri);
       GcsUri gcsUri = new GcsUri(uri);
       Blob blob = getBlob(gcsUri);
-      long updateTime = blob.getUpdateTime();
+      if (blob == null) {
+        // PinotFS contract: if the file does not exist, create an empty file
+        BlobInfo blobInfo = 
BlobInfo.newBuilder(BlobId.of(gcsUri.getBucketName(), 
gcsUri.getPath())).build();
+        _storage.create(blobInfo, new byte[0]);
+        return true;
+      }
+      OffsetDateTime offsetUpdateTime = blob.getUpdateTimeOffsetDateTime();
+      long updateTime = offsetUpdateTime != null ? 
offsetUpdateTime.toInstant().toEpochMilli() : 0L;
       
_storage.update(blob.toBuilder().setMetadata(blob.getMetadata()).build());
-      long newUpdateTime = getBlob(gcsUri).getUpdateTime();
+      Blob updatedBlob = getBlob(gcsUri);
+      OffsetDateTime newOffsetUpdateTime = updatedBlob != null ? 
updatedBlob.getUpdateTimeOffsetDateTime() : null;
+      long newUpdateTime = newOffsetUpdateTime != null ? 
newOffsetUpdateTime.toInstant().toEpochMilli() : 0L;
       return newUpdateTime > updateTime;

Review Comment:
   This condition will now keep returning false if original file has null 
updateTime or post-update, getUpdateTime() is null.
   
   will suggest to just return true if `_storage.update` succeeds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to