Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename PureListInlineExpressionParser to LiteralInlineExpressionParser #28562

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/document/content/dev-manual/sharding.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ chapter = true

### 已知实现

| *配置标识* | *详细说明* | *全限定类名* |
|----------|-------------------|--------------------------------------------------------------------------------|
| GROOVY | 使用 Groovy 语法的行表达式 | `org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser` |
| PURELIST | 使用标准列表的行表达式 | `org.apache.shardingsphere.infra.expr.purelist.PureListInlineExpressionParser` |
| *配置标识* | *详细说明* | *全限定类名* |
|---------|-------------------|------------------------------------------------------------------------------|
| GROOVY | 使用 Groovy 语法的行表达式 | `org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser` |
| LITERAL | 使用标准列表的行表达式 | `org.apache.shardingsphere.infra.expr.literal.LiteralInlineExpressionParser` |
8 changes: 4 additions & 4 deletions docs/document/content/dev-manual/sharding.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Row Value Expressions definition

### Implementation classes

| *Configuration Type* | *Description* | *Fully-qualified class name* |
|----------------------|---------------------------------------------------|--------------------------------------------------------------------------------|
| GROOVY | Row Value Expressions that uses the Groovy syntax | `org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser` |
| PURELIST | Row Value Expressions that uses a standard list | `org.apache.shardingsphere.infra.expr.purelist.PureListInlineExpressionParser` |
| *Configuration Type* | *Description* | *Fully-qualified class name* |
|----------------------|---------------------------------------------------|------------------------------------------------------------------------------|
| GROOVY | Row Value Expressions that uses the Groovy syntax | `org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser` |
| LITERAL | Row Value Expressions that uses a standard list | `org.apache.shardingsphere.infra.expr.literal.LiteralInlineExpressionParser` |
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ weight = 7

## 使用标准列表的行表达式

类型:PURELIST
类型:LITERAL

可配置属性:

Expand All @@ -32,7 +32,7 @@ rules:
- !SHARDING
tables:
t_order:
actualDataNodes: <PURELIST>ds_0.t_order_0, ds_0.t_order_1, ds_1.t_order_0, ds_1.t_order_1
actualDataNodes: <LITERAL>ds_0.t_order_0, ds_0.t_order_1, ds_1.t_order_0, ds_1.t_order_1
tableStrategy:
standard:
shardingColumn: order_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ None

## Row Value Expressions that uses a standard list

Type: PURELIST
Type: LITERAL

Attributes:

Expand All @@ -34,7 +34,7 @@ rules:
- !SHARDING
tables:
t_order:
actualDataNodes: <PURELIST>ds_0.t_order_0, ds_0.t_order_1, ds_1.t_order_0, ds_1.t_order_1
actualDataNodes: <LITERAL>ds_0.t_order_0, ds_0.t_order_1, ds_1.t_order_0, ds_1.t_order_1
tableStrategy:
standard:
shardingColumn: order_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ services:

- 当前阶段,GraalVM Native Image 形态的 ShardingSphere Proxy 不支持使用 `InlineExpressionParser` SPI 的默认实现的 `行表达式`,
这首先导致 `数据分片` 功能的`actualDataNodes` 属性只能使用其他 `InlineExpressionParser` SPI 的实现来配置, 例如使用
`InlineExpressionParser` SPI 实现为 `PURELIST` 的 `行表达式`, 即 `<PURELIST>ds_0.t_order_0, ds_0.t_order_1`
或 `<PURELIST>ds_0.t_user_0, ds_15.t_user_1023`。
`InlineExpressionParser` SPI 实现为 `LITERAL` 的 `行表达式`, 即 `<LITERAL>ds_0.t_order_0, ds_0.t_order_1`
或 `<LITERAL>ds_0.t_user_0, ds_15.t_user_1023`。

- 本节假定处于 Linux(amd64,aarch64), MacOS(amd64)或 Windows(amd64)环境。
如果你位于 MacOS(aarch64/M1) 环境,你需要关注尚未关闭的 https://github.com/oracle/graal/issues/2666 。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ services:
- At this stage, ShardingSphere Proxy in the form of GraalVM Native Image does not support `row expressions` using the
default implementation of the `InlineExpressionParser` SPI.
This first results in the `actualDataNodes` property of the `data sharding` feature that can only be configured using
other implementations of the `InlineExpressionParser` SPI, for example using `PURELIST` implemented
`InlineExpressionParser` SPI for `row expression`, i.e. `<PURELIST>ds_0.t_order_0, ds_0.t_order_1`
or `<PURELIST>ds_0.t_user_0, ds_15.t_user_1023`.
other implementations of the `InlineExpressionParser` SPI, for example using `LITERAL` implemented
`InlineExpressionParser` SPI for `row expression`, i.e. `<LITERAL>ds_0.t_order_0, ds_0.t_order_1`
or `<LITERAL>ds_0.t_user_0, ds_15.t_user_1023`.

- This section assumes a Linux (amd64, aarch64), MacOS (amd64) or Windows (amd64) environment.
If you are on MacOS (aarch64/M1) environment, you need to follow https://github.com/oracle/graal/issues/2666 which is
Expand Down
2 changes: 1 addition & 1 deletion infra/expr/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-expr-purelist</artifactId>
<artifactId>shardingsphere-infra-expr-literal</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void assertNewInstance() {
assertThat(InlineExpressionParserFactory.newInstance("t_order_0, t_order_1").handlePlaceHolder(), is("t_order_0, t_order_1"));
assertThat(InlineExpressionParserFactory.newInstance("<GROOVY>t_order_0, t_order_1").getType(), is("GROOVY"));
assertThat(InlineExpressionParserFactory.newInstance("<GROOVY>t_order_0, t_order_1").handlePlaceHolder(), is("t_order_0, t_order_1"));
assertThat(InlineExpressionParserFactory.newInstance("<PURELIST>t_order_0, t_order_1").getType(), is("PURELIST"));
assertThat(InlineExpressionParserFactory.newInstance("<PURELIST>t_order_0, t_order_1").handlePlaceHolder(), is("t_order_0, t_order_1"));
assertThat(InlineExpressionParserFactory.newInstance("<LITERAL>t_order_0, t_order_1").getType(), is("LITERAL"));
assertThat(InlineExpressionParserFactory.newInstance("<LITERAL>t_order_0, t_order_1").handlePlaceHolder(), is("t_order_0, t_order_1"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<artifactId>shardingsphere-infra-expr-type</artifactId>
<version>5.4.1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-expr-purelist</artifactId>
<artifactId>shardingsphere-infra-expr-literal</artifactId>
<name>${project.artifactId}</name>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.expr.purelist;
package org.apache.shardingsphere.infra.expr.literal;

import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
Expand All @@ -26,9 +26,9 @@
import java.util.Properties;

/**
* Pure List inline expression parser.
* literal inline expression parser.
*/
public final class PureListInlineExpressionParser implements InlineExpressionParser {
public final class LiteralInlineExpressionParser implements InlineExpressionParser {

private static final char SPLITTER = ',';

Expand Down Expand Up @@ -69,6 +69,6 @@ private List<String> split(final String inlineExpression) {

@Override
public String getType() {
return "PURELIST";
return "LITERAL";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.infra.expr.purelist.PureListInlineExpressionParser
org.apache.shardingsphere.infra.expr.literal.LiteralInlineExpressionParser
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.expr.purelist;
package org.apache.shardingsphere.infra.expr.literal;

import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
Expand All @@ -31,18 +31,18 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

class PureListInlineExpressionParserTest {
class LiteralInlineExpressionParserTest {

@Test
void assertEvaluateForExpressionIsNull() {
InlineExpressionParser parser = TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", new Properties());
InlineExpressionParser parser = TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", new Properties());
List<String> expected = parser.splitAndEvaluate();
assertThat(expected, is(Collections.<String>emptyList()));
}

@Test
void assertEvaluateForSimpleString() {
List<String> expected = TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", PropertiesBuilder.build(
List<String> expected = TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", PropertiesBuilder.build(
new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, " t_order_0, t_order_1 "))).splitAndEvaluate();
assertThat(expected.size(), is(2));
assertThat(expected, hasItems("t_order_0", "t_order_1"));
Expand All @@ -60,23 +60,23 @@ void assertEvaluateForLong() {
expression.append(",");
}
}
List<String> expected = TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", PropertiesBuilder.build(
List<String> expected = TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", PropertiesBuilder.build(
new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, expression.toString()))).splitAndEvaluate();
assertThat(expected.size(), is(1024));
assertThat(expected, hasItems("ds_0.t_user_0", "ds_15.t_user_1023"));
}

@Test
void assertHandlePlaceHolder() {
assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", PropertiesBuilder.build(
assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", PropertiesBuilder.build(
new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_$->{[\"new$->{1+2}\"]}"))).handlePlaceHolder(), is("t_$->{[\"new$->{1+2}\"]}"));
assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", PropertiesBuilder.build(
assertThat(TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", PropertiesBuilder.build(
new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "t_${[\"new$->{1+2}\"]}"))).handlePlaceHolder(), is("t_${[\"new$->{1+2}\"]}"));
}

@Test
void assertEvaluateClosure() {
assertThrows(UnsupportedOperationException.class, () -> TypedSPILoader.getService(InlineExpressionParser.class, "PURELIST", PropertiesBuilder.build(
assertThrows(UnsupportedOperationException.class, () -> TypedSPILoader.getService(InlineExpressionParser.class, "LITERAL", PropertiesBuilder.build(
new PropertiesBuilder.Property(InlineExpressionParser.INLINE_EXPRESSION_KEY, "${1+2}"))).evaluateClosure().call().toString());
}
}
2 changes: 1 addition & 1 deletion infra/expr/type/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<modules>
<module>groovy</module>
<module>purelist</module>
<module>literal</module>
<module>espresso</module>
</modules>
</project>