Skip to content

Commit 455b605

Browse files
nokiaMSgithubgxll
authored andcommitted
[feat][runtime] Pushing down instr function to store.
1 parent 196dbba commit 455b605

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

coding/src/main/java/io/dingodb/expr/coding/FunIndex.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import io.dingodb.expr.runtime.op.mathematical.TanFunFactory;
3535
import io.dingodb.expr.runtime.op.mathematical.TanhFunFactory;
3636
import io.dingodb.expr.runtime.op.string.ConcatFun;
37+
import io.dingodb.expr.runtime.op.string.InstrFun;
3738
import io.dingodb.expr.runtime.op.string.LTrim1FunFactory;
3839
import io.dingodb.expr.runtime.op.string.LeftFunFactory;
3940
import io.dingodb.expr.runtime.op.string.LowerFunFactory;
@@ -142,6 +143,9 @@ static int getBinary(@NonNull BinaryOp op) {
142143
case Mid2FunFactory.NAME:
143144
funIndex = 0x2F;
144145
break;
146+
case InstrFun.NAME:
147+
funIndex = 0x30;
148+
break;
145149
default:
146150
break;
147151
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2021 DataCanvas
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.dingodb.expr.runtime.op.string;
18+
19+
import io.dingodb.expr.runtime.ExprConfig;
20+
import io.dingodb.expr.runtime.op.BinaryOp;
21+
import org.checkerframework.checker.nullness.qual.NonNull;
22+
23+
public class InstrFun extends BinaryOp {
24+
private static final long serialVersionUID = -200033123590846940L;
25+
26+
public static final InstrFun INSTANCE = new InstrFun();
27+
28+
public static final String NAME = "instr";
29+
30+
@Override
31+
public Object evalValue(Object value0, Object value1, ExprConfig config) {
32+
if (value0 == null || value1 == null) {
33+
return null;
34+
}
35+
String str = value0.toString();
36+
String point = value1.toString();
37+
return str.indexOf(point) + 1;
38+
}
39+
40+
@Override
41+
public @NonNull String getName() {
42+
return NAME;
43+
}
44+
}

0 commit comments

Comments
 (0)