You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/04/22 09:34:03 UTC

[shardingsphere] branch master updated: Remove useless SQLStats (#25273)

This is an automated email from the ASF dual-hosted git repository.

panjuan 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 b28948c2f56 Remove useless SQLStats (#25273)
b28948c2f56 is described below

commit b28948c2f56a02e01ae32d27a770a2762ddf9202
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Apr 22 17:33:48 2023 +0800

    Remove useless SQLStats (#25273)
---
 .../sql/parser/sql/common/SQLStats.java            | 59 ----------------------
 .../sql/parser/sql/common/SQLStatsTest.java        | 53 -------------------
 2 files changed, 112 deletions(-)

diff --git a/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStats.java b/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStats.java
deleted file mode 100644
index b9dfd185328..00000000000
--- a/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStats.java
+++ /dev/null
@@ -1,59 +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.sql.parser.sql.common;
-
-import lombok.Getter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * SQL stats.
- */
-@Getter
-public final class SQLStats {
-    
-    private final Map<String, SimpleTableSegment> tables = new LinkedHashMap<>();
-    
-    private final Map<Integer, ColumnSegment> columns = new LinkedHashMap<>();
-    
-    /**
-     * Add table to tables.
-     * 
-     * @param tableSegment table segment
-     */
-    public void addTable(final SimpleTableSegment tableSegment) {
-        if (!tables.containsKey(tableSegment.getTableName().getIdentifier().getValue())) {
-            tables.put(tableSegment.getTableName().getIdentifier().getValue(), tableSegment);
-        }
-    }
-    
-    /**
-     * Add column to columns.
-     * 
-     * @param columnSegment column segment
-     */
-    public void addColumn(final ColumnSegment columnSegment) {
-        int columnHashcode = columnSegment.hashCode();
-        if (!columns.containsKey(columnHashcode)) {
-            columns.put(columnHashcode, columnSegment);
-        }
-    }
-}
diff --git a/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java b/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java
deleted file mode 100644
index 9c0309d9af1..00000000000
--- a/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java
+++ /dev/null
@@ -1,53 +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.sql.parser.sql.common;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.junit.jupiter.api.Test;
-
-class SQLStatsTest {
-    
-    @Test
-    void assertAddTable() {
-        SQLStats sqlStats = new SQLStats();
-        assertNull(sqlStats.getTables().get("foo"));
-        SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 5, new IdentifierValue("foo")));
-        sqlStats.addTable(tableSegment);
-        assertThat(sqlStats.getTables().get("foo"), is(tableSegment));
-        sqlStats.addTable(tableSegment);
-        assertThat(sqlStats.getTables().get("foo"), is(tableSegment));
-    }
-    
-    @Test
-    void assertAddColumn() {
-        SQLStats sqlStats = new SQLStats();
-        ColumnSegment columnSegment = new ColumnSegment(0, 5, new IdentifierValue("foo"));
-        assertNull(sqlStats.getColumns().get(columnSegment.hashCode()));
-        sqlStats.addColumn(columnSegment);
-        assertThat(sqlStats.getColumns().get(columnSegment.hashCode()), is(columnSegment));
-        sqlStats.addColumn(columnSegment);
-        assertThat(sqlStats.getColumns().get(columnSegment.hashCode()), is(columnSegment));
-    }
-}