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

com.scudata.expression.fn.Create Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20240823
Show newest version
package com.scudata.expression.fn;

import java.util.ArrayList;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.Table;
import com.scudata.expression.Expression;
import com.scudata.expression.Function;
import com.scudata.expression.Node;
import com.scudata.resources.EngineMessage;
 
/**
 * create(Fi,...)??????Fi,??Ϊ?ֶεĿ????
 * @author runqian
 *
 */
public class Create extends Function {
	public Node optimize(Context ctx) {
		return this;
	}

	public Object calculate(Context ctx) {
		if (param == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("create" + mm.getMessage("function.missingParam"));
		}

		Expression []exps = getParamExpressions("create", true);
		int size = exps.length;

		String []names = new String[size];
		ArrayList pkList = null;
		for (int i = 0; i < size; ++i) {
			if (exps[i] != null) {
				String name = exps[i].getIdentifierName();
				if (name != null && name.length() > 0 && name.charAt(0) == '#') {
					name = name.substring(1);
					if (pkList == null) {
						pkList = new ArrayList();
					}
					
					pkList.add(name);
				}
				
				names[i] = name;
			}
		}

		Table table = new Table(names);
		if (pkList != null) {
			int count = pkList.size();
			String []pkNames = new String[count];
			pkList.toArray(pkNames);
			table.setPrimary(pkNames);
		}
		
		return table;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy