All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nflabs.zeppelin.zengine.ZPlan Maven / Gradle / Ivy

Go to download

Zengine is java framework for data analysis on Hadoop. see http://nflabs.github.io/zeppelin/#/zengine

The newest version!
package com.nflabs.zeppelin.zengine;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.nflabs.zeppelin.driver.LazyConnection;
import com.nflabs.zeppelin.driver.ZeppelinConnection;
import com.nflabs.zeppelin.driver.ZeppelinDriverFactory;
import com.nflabs.zeppelin.result.Result;
import com.nflabs.zeppelin.zengine.stmt.Z;

public class ZPlan extends LinkedList{
	
	public ZPlan(){
		
	}
	public LinkedList execute(Zengine zengine) throws Exception{
		return execute(zengine, null);
	}
	
	public LinkedList execute(Zengine zengine, List> params) throws Exception{
		LinkedList results = new LinkedList();
		
		ZeppelinDriverFactory driverFactory = zengine.getDriverFactory();

		
		for (int i=0; i p = new HashMap();
			if(params!=null && params.size()>=i+1){
				p = params.get(i);
			}
			
			try {
				zz.withParams(p);
				
				ZeppelinConnection conn = zz.getConnection();
				if (conn instanceof LazyConnection) {
					((LazyConnection)conn).initialize(driverFactory);
				}
				zz.execute(conn);
				results.add(zz.result());
				zz.release();
			} catch (Exception e) {
				closeAllConnections();
				throw e;
			}
		}
		closeAllConnections();
		return results;
	}
	
	private void closeAllConnections(){
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy