DonnyZone commented on a change in pull request #1792: [CALCITE-3775] Implicit
lookup methods in SimpleCalciteSchema ignore case sensitivity parameter
URL: https://github.com/apache/calcite/pull/1792#discussion_r377422192
##########
File path: core/src/main/java/org/apache/calcite/jdbc/SimpleCalciteSchema.java
##########
@@ -70,28 +69,29 @@ public CalciteSchema add(String name, Schema schema) {
protected CalciteSchema getImplicitSubSchema(String schemaName,
boolean caseSensitive) {
// Check implicit schemas.
- Schema s = schema.getSubSchema(schemaName);
- if (s != null) {
- return new SimpleCalciteSchema(this, s, schemaName);
+ final NameSet names = NameSet.immutableCopyOf(schema.getSubSchemaNames());
+ for (String schemaName2: names.range(schemaName, caseSensitive)) {
+ return new SimpleCalciteSchema(this,
+ schema.getSubSchema(schemaName2), schemaName);
}
return null;
}
protected TableEntry getImplicitTable(String tableName,
boolean caseSensitive) {
// Check implicit tables.
- Table table = schema.getTable(tableName);
- if (table != null) {
- return tableEntry(tableName, table);
+ final NameSet names = NameSet.immutableCopyOf(schema.getTableNames());
+ for (String tableName2: names.range(tableName, caseSensitive)) {
Review comment:
Thanks, you are right, the performance is not acceptable.
We should not copy them and use `NameSet` as that in `CachingCalciteSchema`.
I implement a `lookup` method and make some performance tests in my local
environment.
```
tables NameSet lookup
100000 224ms 9ms
1000000 1639ms 21ms
10000000 14069ms 117ms
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services