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

com.nflabs.zeppelin.result.Result Maven / Gradle / Ivy

Go to download

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

There is a newer version: 0.3.3
Show newest version
package com.nflabs.zeppelin.result;

import java.io.IOException;
import java.io.OutputStream;
import java.sql.ResultSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;


public class Result extends AbstractResult{
	public List rows;

	public Result(ResultSet res, int max) throws ResultDataException {
		super(res, max);
	}
	
	public Result(ResultSet res) throws ResultDataException {
		super(res);
	}
	
	public Result(Exception e1) throws ResultDataException {
		super(e1);
	}
	
	public Result(int code, String [] message) throws ResultDataException{
		super(code, message);
	}
	
	public Result() {
		super();
	}
	
    public Result(ColumnDef[] columnDef) {
        super(columnDef);
    }
    
    public void addRow(Object[] row){
        if(rows==null) rows = new LinkedList();
        rows.add(row);
    }

	@Override
	protected void process(ColumnDef[] columnDef, Object[] row, long n) {
	        addRow(row);
	}
	
	public List getRows(){
		if(rows==null) rows = new LinkedList(); 
		return rows;
	}
	
	public void write(OutputStream out) throws IOException{
		write(out, "\t", "\n");
	}
	public void write(OutputStream out, String columnSep, String rowSep) throws IOException{
		Iterator it = getRows().iterator();
		while(it.hasNext()){
			Object[] row = it.next();
			
			for(int i=0; i