
prerna.reactor.expression.OpMatch Maven / Gradle / Ivy
The newest version!
package prerna.reactor.expression;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.TreeSet;
import java.util.stream.Collectors;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.ReactorKeysEnum;
import prerna.sablecc2.om.nounmeta.NounMetadata;
public class OpMatch extends OpBasic {
public OpMatch() {
this.keysToGet = new String[]{ReactorKeysEnum.VALUE.getKey(), ReactorKeysEnum.ARRAY.getKey(), "matchType"};
}
@Override
protected NounMetadata evaluate(Object[] values) {
int offset = 0;
if (this.curRow.size() == 3) {
offset = 1;
}
boolean comparingNumbers = false;
boolean isString = this.curRow.getNoun(0).getNounType().equals(PixelDataType.CONST_STRING);
// figure out
// if sort needs to do a number sort
// or do a string sort
// if we have 1 string -> assumption is all are string values
// return -1 if match not found
List intGrs = this.curRow.getNounsOfType(PixelDataType.CONST_INT);
if (intGrs != null && intGrs.size() > offset) {
comparingNumbers = true;
}
if (!comparingNumbers) {
List doubleGrs = this.curRow.getNounsOfType(PixelDataType.CONST_DECIMAL);
if (doubleGrs != null && doubleGrs.size() > 0) {
comparingNumbers = true;
}
}
Object objInput = values[0];
int index = 1; // default value of index is 1
if (values.length == 3) {
index = (int) (values[2]);
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy