Search in sources :

Example 1 with ResourceStatistics

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);
    }
}
Also used : ResourceStatistics(org.apache.pig.ResourceStatistics) IOException(java.io.IOException) InputJobInfo(org.apache.hive.hcatalog.mapreduce.InputJobInfo) HCatException(org.apache.hive.hcatalog.common.HCatException) PigException(org.apache.pig.PigException) IOException(java.io.IOException)

Example 2 with ResourceStatistics

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());
}
Also used : RandomAccessFile(java.io.RandomAccessFile) ResourceStatistics(org.apache.pig.ResourceStatistics) Job(org.apache.hadoop.mapreduce.Job) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) HCatBaseTest(org.apache.hive.hcatalog.mapreduce.HCatBaseTest) Test(org.junit.Test)

Aggregations

ResourceStatistics (org.apache.pig.ResourceStatistics)2 File (java.io.File)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 Job (org.apache.hadoop.mapreduce.Job)1 HCatException (org.apache.hive.hcatalog.common.HCatException)1 HCatBaseTest (org.apache.hive.hcatalog.mapreduce.HCatBaseTest)1 InputJobInfo (org.apache.hive.hcatalog.mapreduce.InputJobInfo)1 PigException (org.apache.pig.PigException)1 Test (org.junit.Test)1