OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavyDBSchema.java
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.mapd.calcite.parser;
18 
21 
22 import org.apache.calcite.linq4j.tree.Expression;
23 import org.apache.calcite.rel.type.RelProtoDataType;
24 import org.apache.calcite.schema.Function;
25 import org.apache.calcite.schema.Schema;
26 import org.apache.calcite.schema.SchemaPlus;
27 import org.apache.calcite.schema.SchemaVersion;
28 import org.apache.calcite.schema.Table;
29 import org.apache.calcite.util.ConversionUtil;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.HashSet;
36 import java.util.Set;
37 
38 public class HeavyDBSchema implements Schema {
39  final static Logger HEAVYDBLOGGER = LoggerFactory.getLogger(HeavyDBSchema.class);
40 
41  final private MetaConnect metaConnect;
43  public HeavyDBSchema(String dataDir,
44  HeavyDBParser dbParser,
45  int dbPort,
46  HeavyDBUser dbUser,
48  String db) {
49  System.setProperty(
50  "saffron.default.charset", ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
51  System.setProperty(
52  "saffron.default.nationalcharset", ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
53  System.setProperty("saffron.default.collation.name",
54  ConversionUtil.NATIVE_UTF16_CHARSET_NAME + "$en_US");
55  metaConnect = new MetaConnect(dbPort, dataDir, dbUser, dbParser, skT, db);
56  }
57 
58  @Override
59  public Table getTable(String string) {
60  Table table = metaConnect.getTable(string);
61  return table;
62  }
63 
64  @Override
65  public Set<String> getTableNames() {
66  Set<String> tableSet = metaConnect.getTables();
67  return tableSet;
68  }
69 
70  @Override
71  public Collection<Function> getFunctions(String string) {
72  Collection<Function> functionCollection = new HashSet<Function>();
73  return functionCollection;
74  }
75 
76  @Override
77  public Set<String> getFunctionNames() {
78  Set<String> functionSet = new HashSet<String>();
79  return functionSet;
80  }
81 
82  @Override
83  public Schema getSubSchema(String string) {
84  return null;
85  }
86 
87  @Override
88  public Set<String> getSubSchemaNames() {
89  Set<String> hs = new HashSet<String>();
90  return hs;
91  }
92 
93  @Override
94  public Expression getExpression(SchemaPlus sp, String string) {
95  throw new UnsupportedOperationException("Not supported yet.");
96  }
97 
98  @Override
99  public boolean isMutable() {
100  throw new UnsupportedOperationException("Not supported yet.");
101  }
102 
103  void updateMetaData(String schema, String table) {
104  metaConnect.updateMetaData(schema, table);
105  }
106 
107  @Override
108  public Schema snapshot(SchemaVersion sv) {
109  throw new UnsupportedOperationException("Not supported yet.");
110  }
111 
112  @Override
113  public RelProtoDataType getType(String arg0) {
114  throw new UnsupportedOperationException("Not supported yet.");
115  }
116 
117  @Override
118  public Set<String> getTypeNames() {
119  throw new UnsupportedOperationException("Not supported yet.");
120  }
121 }
SockTransportProperties sock_transport_properties
Expression getExpression(SchemaPlus sp, String string)
void updateMetaData(String schema, String table)
HeavyDBSchema(String dataDir, HeavyDBParser dbParser, int dbPort, HeavyDBUser dbUser, SockTransportProperties skT, String db)
RelProtoDataType getType(String arg0)
Collection< Function > getFunctions(String string)