use of org.apache.hadoop.fs.ContentSummary.Builder in project hadoop by apache.
the class JsonUtilClient method toContentSummary.
/** Convert a Json map to a ContentSummary. */
static ContentSummary toContentSummary(final Map<?, ?> json) {
if (json == null) {
return null;
}
final Map<?, ?> m = (Map<?, ?>) json.get(ContentSummary.class.getSimpleName());
final long length = ((Number) m.get("length")).longValue();
final long fileCount = ((Number) m.get("fileCount")).longValue();
final long directoryCount = ((Number) m.get("directoryCount")).longValue();
final long quota = ((Number) m.get("quota")).longValue();
final long spaceConsumed = ((Number) m.get("spaceConsumed")).longValue();
final long spaceQuota = ((Number) m.get("spaceQuota")).longValue();
final Map<?, ?> typem = (Map<?, ?>) m.get("typeQuota");
Builder contentSummaryBuilder = new ContentSummary.Builder().length(length).fileCount(fileCount).directoryCount(directoryCount).quota(quota).spaceConsumed(spaceConsumed).spaceQuota(spaceQuota);
if (typem != null) {
for (StorageType t : StorageType.getTypesSupportingQuota()) {
Map<?, ?> type = (Map<?, ?>) typem.get(t.toString());
if (type != null) {
contentSummaryBuilder = contentSummaryBuilder.typeQuota(t, ((Number) type.get("quota")).longValue()).typeConsumed(t, ((Number) type.get("consumed")).longValue());
}
}
}
return contentSummaryBuilder.build();
}
use of org.apache.hadoop.fs.ContentSummary.Builder in project hadoop by apache.
the class AdlFileSystem method getContentSummary.
/**
* Return the {@link ContentSummary} of a given {@link Path}.
*
* @param f path to use
*/
@Override
public ContentSummary getContentSummary(Path f) throws IOException {
statistics.incrementReadOps(1);
com.microsoft.azure.datalake.store.ContentSummary msSummary = adlClient.getContentSummary(toRelativeFilePath(f));
return new Builder().length(msSummary.length).directoryCount(msSummary.directoryCount).fileCount(msSummary.fileCount).spaceConsumed(msSummary.spaceConsumed).build();
}
Aggregations