Search in sources :

Example 1 with Builder

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();
}
Also used : StorageType(org.apache.hadoop.fs.StorageType) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) Builder(org.apache.hadoop.fs.ContentSummary.Builder) Map(java.util.Map)

Example 2 with Builder

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();
}
Also used : Builder(org.apache.hadoop.fs.ContentSummary.Builder)

Aggregations

Builder (org.apache.hadoop.fs.ContentSummary.Builder)2 Map (java.util.Map)1 StorageType (org.apache.hadoop.fs.StorageType)1 DatanodeInfoBuilder (org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder)1