0

This is my java code

     SparkConf sparkConf = new SparkConf().setAppName("Hive");
     JavaSparkContext ctx = new JavaSparkContext(sparkConf);
     HiveContext sqlContext = new HiveContext(ctx.sc());

     Row[] results = sqlContext.sql("Select * from tablename").collect();
     for (int i = 0; i < results.length; i++) {
       System.out.println(results[i]);
       }

This takes long time to run than I expected and I noticed that this is due creating object for each query. So I decided to use Apache common pool but I am stuck in this. Can anyone help me in creating a pool for the object of type HiveContext. But I have tried so far

 private org.apache.commons.pool.ObjectPool<HiveContext> pool;

    public HivePool(org.apache.commons.pool.ObjectPool<HiveContext> pool) {
        this.pool = pool;
    }
wazza
  • 770
  • 5
  • 17
  • 42

1 Answers1

0

Did u use GenericObjectPool to instantiate your HivePool.
Try this example
https://commons.apache.org/proper/commons-pool/examples.html

kswaughs
  • 2,967
  • 1
  • 17
  • 21