MCPcopy Create free account
hub / github.com/apache/pig / capacity

Method capacity

src/org/apache/pig/PigServer.java:1210–1231  ·  view source on GitHub ↗

Returns the unused byte capacity of an HDFS filesystem. This value does not take into account a replication factor, as that can vary from file to file. Thus if you are using this to determine if you data set will fit in the HDFS, you need to divide the result of this call by your specific replicatio

()

Source from the content-addressed store, hash-verified

1208 * @throws IOException
1209 */
1210 public long capacity() throws IOException {
1211 if (pigContext.getExecType().isLocal()) {
1212 throw new IOException("capacity only supported for non-local execution");
1213 }
1214 else {
1215 DataStorage dds = pigContext.getDfs();
1216
1217 Map<String, Object> stats = dds.getStatistics();
1218
1219 String rawCapacityStr = (String) stats.get(DataStorage.RAW_CAPACITY_KEY);
1220 String rawUsedStr = (String) stats.get(DataStorage.RAW_USED_KEY);
1221
1222 if ((rawCapacityStr == null) || (rawUsedStr == null)) {
1223 throw new IOException("Failed to retrieve capacity stats");
1224 }
1225
1226 long rawCapacityBytes = new Long(rawCapacityStr).longValue();
1227 long rawUsedBytes = new Long(rawUsedStr).longValue();
1228
1229 return rawCapacityBytes - rawUsedBytes;
1230 }
1231 }
1232
1233 /**
1234 * Returns the length of a file in bytes which exists in the HDFS (accounts for replication).

Callers 1

testPigServerMethod · 0.95

Calls 5

getStatisticsMethod · 0.95
getDfsMethod · 0.80
isLocalMethod · 0.65
getMethod · 0.65
getExecTypeMethod · 0.45

Tested by 1

testPigServerMethod · 0.76