OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavyDBSerializer.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 
19 import com.google.gson.Gson;
20 import com.google.gson.GsonBuilder;
23 
24 import org.apache.calcite.rel.RelNode;
26 
27 public class HeavyDBSerializer {
28  private static final Gson gson;
29 
30  static {
31  gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
32  }
33 
34  public static String toString(final RelNode rel) {
35  if (rel == null) {
36  return null;
37  }
38  final HeavyDBRelJsonWriter planWriter = new HeavyDBRelJsonWriter();
39  rel.explain(planWriter);
40  return planWriter.asString();
41  }
42 
43  public static String toJsonString(final JsonSerializableDdl jsonSerializableDdl) {
44  final DdlResponse ddlResponse = new DdlResponse();
45  ddlResponse.setPayload(jsonSerializableDdl);
46  return gson.toJson(ddlResponse);
47  }
48 }
std::pair< FILE *, std::string > create(const std::string &basePath, const int fileId, const size_t pageSize, const size_t numPages)
Definition: File.cpp:55
static String toJsonString(final JsonSerializableDdl jsonSerializableDdl)
static String toString(final RelNode rel)