OmniSciDB  4201147b46
 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  public HeavyDBSchema(String dataDir,
59  HeavyDBParser dbParser,
60  int dbPort,
61  HeavyDBUser dbUser,
63  this(dataDir, dbParser, dbPort, dbUser, skT, null);
64  }
65 
66  @Override
67  public Table getTable(String string) {
68  Table table = metaConnect.getTable(string);
69  return table;
70  }
71 
72  @Override
73  public Set<String> getTableNames() {
74  Set<String> tableSet = metaConnect.getTables();
75  return tableSet;
76  }
77 
78  @Override
79  public Collection<Function> getFunctions(String string) {
80  Collection<Function> functionCollection = new HashSet<Function>();
81  return functionCollection;
82  }
83 
84  @Override
85  public Set<String> getFunctionNames() {
86  Set<String> functionSet = new HashSet<String>();
87  return functionSet;
88  }
89 
90  @Override
91  public Schema getSubSchema(String string) {
92  return null;
93  }
94 
95  @Override
96  public Set<String> getSubSchemaNames() {
97  Set<String> hs = new HashSet<String>();
98  return hs;
99  }
100 
101  @Override
102  public Expression getExpression(SchemaPlus sp, String string) {
103  throw new UnsupportedOperationException("Not supported yet.");
104  }
105 
106  @Override
107  public boolean isMutable() {
108  throw new UnsupportedOperationException("Not supported yet.");
109  }
110 
111  void updateMetaData(String schema, String table) {
112  metaConnect.updateMetaData(schema, table);
113  }
114 
115  @Override
116  public Schema snapshot(SchemaVersion sv) {
117  throw new UnsupportedOperationException("Not supported yet.");
118  }
119 
120  @Override
121  public RelProtoDataType getType(String arg0) {
122  throw new UnsupportedOperationException("Not supported yet.");
123  }
124 
125  @Override
126  public Set<String> getTypeNames() {
127  throw new UnsupportedOperationException("Not supported yet.");
128  }
129 }
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)
HeavyDBSchema(String dataDir, HeavyDBParser dbParser, int dbPort, HeavyDBUser dbUser, SockTransportProperties skT, String db)
RelProtoDataType getType(String arg0)
Collection< Function > getFunctions(String string)