blob: 4f7c35a661f37bcb1b90b808e26829529c4da67d [file] [log] [blame]
/*
* Copyright 2009-2010 by The Regents of the University of California
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may obtain a copy of the License from
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.uci.ics.hyracks.algebricks.runtime.evaluators;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
import edu.uci.ics.hyracks.data.std.api.IPointable;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public class ConstantEvaluatorFactory implements IScalarEvaluatorFactory {
private static final long serialVersionUID = 1L;
private byte[] value;
public ConstantEvaluatorFactory(byte[] value) {
this.value = value;
}
@Override
public String toString() {
return "Constant";
}
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
return new IScalarEvaluator() {
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
result.set(value, 0, value.length);
}
};
}
}