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

Method fileSize

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

Returns the length of a file in bytes which exists in the HDFS (accounts for replication). @param filename @return length of the file in bytes @throws IOException

(String filename)

Source from the content-addressed store, hash-verified

1237 * @throws IOException
1238 */
1239 public long fileSize(String filename) throws IOException {
1240 DataStorage dfs = pigContext.getDfs();
1241 ElementDescriptor elem = dfs.asElement(filename);
1242 Map<String, Object> stats = elem.getStatistics();
1243 long length = (Long) stats.get(ElementDescriptor.LENGTH_KEY);
1244 int replication = (Short) stats
1245 .get(ElementDescriptor.BLOCK_REPLICATION_KEY);
1246
1247 return length * replication;
1248 }
1249
1250 /**
1251 * Test whether a file exists.

Callers 1

testPigServerMethod · 0.95

Calls 4

asElementMethod · 0.95
getStatisticsMethod · 0.95
getDfsMethod · 0.80
getMethod · 0.65

Tested by 1

testPigServerMethod · 0.76