@ Override public long length ( ) { // If the summary is already in the cache, return it. // It'll have been added by a listDatasets() call on the parent directory. S3ObjectSummary objectSummary = objectSummaryCache . getIfPresent ( s3uri ) ; if ( objectSummary != null ) { return objectSummary . getSize ( ) ; } /* Get the metadata directly from S3. This will be expensive. * We get punished hard if length() and/or lastModified() is called on a bunch of datasets without * listDatasets() first being called on their parent directory. * * So, is the right thing to do here "getParentDataset().listDatasets()" and then query the cache again? * Perhaps, but listDatasets() throws an IOException, and length() and lastModified() do not. * We would have to change their signatures and the upstream client code to make it work. */ ObjectMetadata metadata = threddsS3Client . getObjectMetadata ( s3uri ) ; if ( metadata != null ) { return metadata . getContentLength ( ) ; } else { // "this" may be a collection or non-existent. In both cases, we return 0. return 0 ; } }
Returns the size of the dataset in bytes . Will be zero if this dataset is a collection or non - existent .