private void init() { literalSourceStr = maybeExtractLiteralString(getChildren().get(0)); literalSearchStr = maybeExtractLiteralString(getChildren().get(1)); }
public InstrFunction(List<Expression> children) { super(children); init(); }
String sourceStr = literalSourceStr; if (sourceStr == null) { Expression child = getChildren().get(0); Expression child = getChildren().get(1);
private static Object evaluateExpression(String value, PDataType<?> dataType, String strToSearch, SortOrder order) throws SQLException { Expression inputArg = LiteralExpression.newConstant(value,dataType,order); Expression strToSearchExp = LiteralExpression.newConstant(strToSearch,dataType); List<Expression> expressions = Arrays.<Expression>asList(inputArg,strToSearchExp); Expression instrFunction = new InstrFunction(expressions); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); instrFunction.evaluate(null,ptr); return instrFunction.getDataType().toObject(ptr); }
private void init() { Expression strToSearchExpression = getChildren().get(1); if (strToSearchExpression instanceof LiteralExpression) { Object strToSearchValue = ((LiteralExpression) strToSearchExpression).getValue(); if (strToSearchValue != null) { this.strToSearch = strToSearchValue.toString(); } } }
private void init() { literalSourceStr = maybeExtractLiteralString(getChildren().get(0)); literalSearchStr = maybeExtractLiteralString(getChildren().get(1)); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); init(); } }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression child = getChildren().get(0); if (!child.evaluate(tuple, ptr)) { return false; } if (ptr.getLength() == 0) { ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); return true; } int position; //Logic for Empty string search if (strToSearch == null){ position = 0; ptr.set(PInteger.INSTANCE.toBytes(position)); return true; } String sourceStr = (String) PVarchar.INSTANCE.toObject(ptr, getChildren().get(0).getSortOrder()); position = sourceStr.indexOf(strToSearch) + 1; ptr.set(PInteger.INSTANCE.toBytes(position)); return true; }
public InstrFunction(List<Expression> children) { super(children); init(); }
String sourceStr = literalSourceStr; if (sourceStr == null) { Expression child = getChildren().get(0); Expression child = getChildren().get(1);
public InstrFunction(List<Expression> children) { super(children); init(); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); init(); } }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); init(); } }