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

com.scudata.expression.mfn.record.Key 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.mfn.record;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.Sequence;
import com.scudata.expression.IParam;
import com.scudata.expression.RecordFunction;
import com.scudata.resources.EngineMessage;

/**
 * ȡ??¼?ļ?ֵ?????ֵ???س?????
 * r.key() r.key(Fi,??)
 * @author RunQian
 *
 */
public class Key extends RecordFunction {
	public Object calculate(Context ctx) {
		if (param == null) {
			return srcRecord.key();
		} else if (param.isLeaf()) {
			String col = param.getLeafExpression().getIdentifierName();
			return srcRecord.getFieldValue(col);
		} else {
			int count = param.getSubSize();
			Sequence seq = new Sequence(count);
			for (int i = 0; i < count; ++i) {
				IParam sub = param.getSub(i);
				if (sub == null) {
					MessageManager mm = EngineMessage.get();
					throw new RQException("key" + mm.getMessage("function.invalidParam"));
				}
				
				String col = sub.getLeafExpression().getIdentifierName();
				seq.add(srcRecord.getFieldValue(col));
			}
			
			return seq;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy