This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 22c272905cc Remove useless CursorDefinition (#32097)
22c272905cc is described below
commit 22c272905cc32507c5b770a988e67691282c14d5
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 14 13:55:41 2024 +0800
Remove useless CursorDefinition (#32097)
---
.../binder/context/aware/CursorDefinition.java | 24 ----------------------
.../statement/ddl/CursorStatementContext.java | 5 ++---
.../connection/cursor/CursorConnectionContext.java | 8 ++++----
.../proxy/backend/connector/DatabaseConnector.java | 4 ++--
.../handler/distsql/rul/PreviewExecutor.java | 2 +-
5 files changed, 9 insertions(+), 34 deletions(-)
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/aware/CursorDefinition.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/aware/CursorDefinition.java
deleted file mode 100644
index 5469451d09a..00000000000
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/aware/CursorDefinition.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 at
- *
- * 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 org.apache.shardingsphere.infra.binder.context.aware;
-
-/**
- * Cursor definition.
- */
-public interface CursorDefinition {
-}
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
index 5d6c0c59ec4..ab7dc60a0f8 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.infra.binder.context.statement.ddl;
import lombok.Getter;
-import org.apache.shardingsphere.infra.binder.context.aware.CursorDefinition;
import
org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import
org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
@@ -26,13 +25,13 @@ import
org.apache.shardingsphere.infra.binder.context.type.CursorAvailable;
import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
import org.apache.shardingsphere.infra.binder.context.type.WhereAvailable;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.sql.parser.statement.core.util.TableExtractor;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.cursor.CursorNameSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CursorStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.util.TableExtractor;
import java.util.Collection;
import java.util.Collections;
@@ -44,7 +43,7 @@ import java.util.Optional;
* Cursor statement context.
*/
@Getter
-public final class CursorStatementContext extends CommonSQLStatementContext
implements CursorAvailable, TableAvailable, WhereAvailable, CursorDefinition {
+public final class CursorStatementContext extends CommonSQLStatementContext
implements CursorAvailable, TableAvailable, WhereAvailable {
private final Collection<WhereSegment> whereSegments = new LinkedList<>();
diff --git
a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/cursor/CursorConnectionContext.java
b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/cursor/CursorConnectionContext.java
index 1b31cdaa87f..3f37792dbdf 100644
---
a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/cursor/CursorConnectionContext.java
+++
b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/cursor/CursorConnectionContext.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.infra.session.connection.cursor;
import lombok.Getter;
-import org.apache.shardingsphere.infra.binder.context.aware.CursorDefinition;
+import
org.apache.shardingsphere.infra.binder.context.statement.ddl.CursorStatementContext;
import java.util.List;
import java.util.Map;
@@ -34,7 +34,7 @@ public final class CursorConnectionContext implements
AutoCloseable {
private final Map<String, Long> minGroupRowCounts = new
ConcurrentHashMap<>();
- private final Map<String, CursorDefinition> cursorDefinitions = new
ConcurrentHashMap<>();
+ private final Map<String, CursorStatementContext> cursorStatementContexts
= new ConcurrentHashMap<>();
private final Map<String, Boolean> executedAllDirections = new
ConcurrentHashMap<>();
@@ -46,7 +46,7 @@ public final class CursorConnectionContext implements
AutoCloseable {
public void removeCursor(final String cursorName) {
orderByValueGroups.remove(cursorName);
minGroupRowCounts.remove(cursorName);
- cursorDefinitions.remove(cursorName);
+ cursorStatementContexts.remove(cursorName);
executedAllDirections.remove(cursorName);
}
@@ -54,7 +54,7 @@ public final class CursorConnectionContext implements
AutoCloseable {
public void close() {
orderByValueGroups.clear();
minGroupRowCounts.clear();
- cursorDefinitions.clear();
+ cursorStatementContexts.clear();
executedAllDirections.clear();
}
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
index 9519f808315..fd89923b5fe 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
@@ -267,10 +267,10 @@ public final class DatabaseConnector implements
DatabaseBackendHandler {
private void prepareCursorStatementContext(final CursorAvailable
statementContext, final ConnectionSession connectionSession, final String
cursorName) {
if (statementContext instanceof CursorStatementContext) {
-
connectionSession.getConnectionContext().getCursorContext().getCursorDefinitions().put(cursorName,
(CursorStatementContext) statementContext);
+
connectionSession.getConnectionContext().getCursorContext().getCursorStatementContexts().put(cursorName,
(CursorStatementContext) statementContext);
}
if (statementContext instanceof CursorDefinitionAware) {
- CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionSession.getConnectionContext().getCursorContext().getCursorDefinitions().get(cursorName);
+ CursorStatementContext cursorStatementContext =
connectionSession.getConnectionContext().getCursorContext().getCursorStatementContexts().get(cursorName);
Preconditions.checkArgument(null != cursorStatementContext,
"Cursor %s does not exist.", cursorName);
((CursorDefinitionAware)
statementContext).setUpCursorDefinition(cursorStatementContext);
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
index 4b71d01285b..a34630354ce 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
@@ -125,7 +125,7 @@ public final class PreviewExecutor implements
DistSQLQueryExecutor<PreviewStatem
return;
}
String cursorName = ((CursorAvailable)
toBePreviewedStatementContext).getCursorName().get().getIdentifier().getValue().toLowerCase();
- CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionContext.getConnectionContext().getCursorContext().getCursorDefinitions().get(cursorName);
+ CursorStatementContext cursorStatementContext =
connectionContext.getConnectionContext().getCursorContext().getCursorStatementContexts().get(cursorName);
Preconditions.checkNotNull(cursorStatementContext, "Cursor %s does not
exist.", cursorName);
((CursorDefinitionAware)
toBePreviewedStatementContext).setUpCursorDefinition(cursorStatementContext);
}