use of org.apache.pig.ResourceStatistics in project hive by apache.
the class HCatLoader method getStatistics.
/**
* Get statistics about the data to be loaded. Only input data size is implemented at this time.
*/
@Override
public ResourceStatistics getStatistics(String location, Job job) throws IOException {
try {
ResourceStatistics stats = new ResourceStatistics();
InputJobInfo inputJobInfo = (InputJobInfo) HCatUtil.deserialize(job.getConfiguration().get(HCatConstants.HCAT_KEY_JOB_INFO));
stats.setmBytes(getSizeInBytes(inputJobInfo) / 1024 / 1024);
return stats;
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.pig.ResourceStatistics in project hive by apache.
the class AbstractHCatLoaderTest method testGetInputBytes.
@Test
public void testGetInputBytes() throws Exception {
File file = new File(TEST_WAREHOUSE_DIR + "/" + SPECIFIC_SIZE_TABLE + "/part-m-00000");
file.deleteOnExit();
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
randomAccessFile.setLength(2L * 1024 * 1024 * 1024);
randomAccessFile.close();
Job job = new Job();
HCatLoader hCatLoader = new HCatLoader();
hCatLoader.setUDFContextSignature("testGetInputBytes");
hCatLoader.setLocation(SPECIFIC_SIZE_TABLE, job);
ResourceStatistics statistics = hCatLoader.getStatistics(file.getAbsolutePath(), job);
assertEquals(2048, (long) statistics.getmBytes());
}
Aggregations