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;
}