18
18
package org .apache .shardingsphere .infra .metadata .database .schema .model ;
19
19
20
20
import lombok .Getter ;
21
+ import org .apache .shardingsphere .infra .metadata .identifier .ShardingSphereMetaDataIdentifier ;
21
22
22
23
import java .util .Collection ;
23
24
import java .util .Collections ;
24
25
import java .util .List ;
25
26
import java .util .Map ;
26
27
import java .util .concurrent .ConcurrentHashMap ;
28
+ import java .util .stream .Collectors ;
27
29
28
30
/**
29
31
* ShardingSphere schema.
@@ -33,9 +35,9 @@ public final class ShardingSphereSchema {
33
35
@ Getter
34
36
private final String name ;
35
37
36
- private final Map <String , ShardingSphereTable > tables ;
38
+ private final Map <ShardingSphereMetaDataIdentifier , ShardingSphereTable > tables ;
37
39
38
- private final Map <String , ShardingSphereView > views ;
40
+ private final Map <ShardingSphereMetaDataIdentifier , ShardingSphereView > views ;
39
41
40
42
@ SuppressWarnings ("CollectionWithoutInitialCapacity" )
41
43
public ShardingSphereSchema (final String name ) {
@@ -48,8 +50,8 @@ public ShardingSphereSchema(final String name, final Collection<ShardingSphereTa
48
50
this .name = name ;
49
51
this .tables = new ConcurrentHashMap <>(tables .size (), 1F );
50
52
this .views = new ConcurrentHashMap <>(views .size (), 1F );
51
- tables .forEach (each -> this .tables .put (each .getName (). toLowerCase ( ), each ));
52
- views .forEach (each -> this .views .put (each .getName (). toLowerCase ( ), each ));
53
+ tables .forEach (each -> this .tables .put (new ShardingSphereMetaDataIdentifier ( each .getName ()), each ));
54
+ views .forEach (each -> this .views .put (new ShardingSphereMetaDataIdentifier ( each .getName ()), each ));
53
55
}
54
56
55
57
/**
@@ -58,7 +60,7 @@ public ShardingSphereSchema(final String name, final Collection<ShardingSphereTa
58
60
* @return all table names
59
61
*/
60
62
public Collection <String > getAllTableNames () {
61
- return tables .keySet ();
63
+ return tables .keySet (). stream (). map ( ShardingSphereMetaDataIdentifier :: getValue ). collect ( Collectors . toSet ()) ;
62
64
}
63
65
64
66
/**
@@ -77,7 +79,7 @@ public Collection<ShardingSphereTable> getAllTables() {
77
79
* @return contains table or not
78
80
*/
79
81
public boolean containsTable (final String tableName ) {
80
- return tables .containsKey (tableName . toLowerCase ( ));
82
+ return tables .containsKey (new ShardingSphereMetaDataIdentifier ( tableName ));
81
83
}
82
84
83
85
/**
@@ -87,7 +89,7 @@ public boolean containsTable(final String tableName) {
87
89
* @return table
88
90
*/
89
91
public ShardingSphereTable getTable (final String tableName ) {
90
- return tables .get (tableName . toLowerCase ( ));
92
+ return tables .get (new ShardingSphereMetaDataIdentifier ( tableName ));
91
93
}
92
94
93
95
/**
@@ -96,7 +98,7 @@ public ShardingSphereTable getTable(final String tableName) {
96
98
* @param table table
97
99
*/
98
100
public void putTable (final ShardingSphereTable table ) {
99
- tables .put (table .getName (). toLowerCase ( ), table );
101
+ tables .put (new ShardingSphereMetaDataIdentifier ( table .getName ()), table );
100
102
}
101
103
102
104
/**
@@ -105,7 +107,7 @@ public void putTable(final ShardingSphereTable table) {
105
107
* @param tableName table name
106
108
*/
107
109
public void removeTable (final String tableName ) {
108
- tables .remove (tableName . toLowerCase ( ));
110
+ tables .remove (new ShardingSphereMetaDataIdentifier ( tableName ));
109
111
}
110
112
111
113
/**
@@ -124,7 +126,7 @@ public Collection<ShardingSphereView> getAllViews() {
124
126
* @return contains view or not
125
127
*/
126
128
public boolean containsView (final String viewName ) {
127
- return views .containsKey (viewName . toLowerCase ( ));
129
+ return views .containsKey (new ShardingSphereMetaDataIdentifier ( viewName ));
128
130
}
129
131
130
132
/**
@@ -134,7 +136,7 @@ public boolean containsView(final String viewName) {
134
136
* @return view
135
137
*/
136
138
public ShardingSphereView getView (final String viewName ) {
137
- return views .get (viewName . toLowerCase ( ));
139
+ return views .get (new ShardingSphereMetaDataIdentifier ( viewName ));
138
140
}
139
141
140
142
/**
@@ -143,7 +145,7 @@ public ShardingSphereView getView(final String viewName) {
143
145
* @param view view
144
146
*/
145
147
public void putView (final ShardingSphereView view ) {
146
- views .put (view .getName (). toLowerCase ( ), view );
148
+ views .put (new ShardingSphereMetaDataIdentifier ( view .getName ()), view );
147
149
}
148
150
149
151
/**
@@ -152,7 +154,7 @@ public void putView(final ShardingSphereView view) {
152
154
* @param viewName view name
153
155
*/
154
156
public void removeView (final String viewName ) {
155
- views .remove (viewName . toLowerCase ( ));
157
+ views .remove (new ShardingSphereMetaDataIdentifier ( viewName ));
156
158
}
157
159
158
160
/**
@@ -172,7 +174,7 @@ public boolean containsIndex(final String tableName, final String indexName) {
172
174
* @param tableName table name
173
175
* @return column names
174
176
*/
175
- public List <String > getAllColumnNames (final String tableName ) {
177
+ public Collection <String > getAllColumnNames (final String tableName ) {
176
178
return containsTable (tableName ) ? getTable (tableName ).getColumnNames () : Collections .emptyList ();
177
179
}
178
180
0 commit comments