OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.parser.server.test.TestServer Class Reference
+ Collaboration diagram for com.mapd.parser.server.test.TestServer:

Public Member Functions

void testThreadedCall ()
 
void testSimpleCall ()
 
void testRandomCall ()
 

Static Public Member Functions

static void startServer ()
 
static void stopServer ()
 

Private Member Functions

void randomCalciteCall ()
 
void callCalciteCheck (String query, String result)
 

Private Attributes

volatile int threadsRun = 0
 
volatile boolean threadHadFailure = false
 
volatile AssertionError ae
 

Static Private Attributes

static final Logger HEAVYDBLOGGER = LoggerFactory.getLogger(TestServer.class)
 
static final int TEST_THREAD_COUNT = 3
 
static CalciteServerWrapper csw = null
 
static SockTransportProperties client_skT = null
 
static SockTransportProperties server_skT = null
 

Detailed Description

Definition at line 46 of file TestServer.java.

Member Function Documentation

void com.mapd.parser.server.test.TestServer.callCalciteCheck ( String  query,
String  result 
)
inlineprivate

Definition at line 243 of file TestServer.java.

Referenced by com.mapd.parser.server.test.TestServer.randomCalciteCall(), and com.mapd.parser.server.test.TestServer.testSimpleCall().

243  {
244  try {
245  TTransport transport;
246  transport = new TSocket("localhost", 11000);
247  transport.open();
248  TProtocol protocol = new TBinaryProtocol(transport);
249  CalciteServer.Client client = new CalciteServer.Client(protocol);
250 
251  TQueryParsingOption queryParsingOption = new TQueryParsingOption();
252  queryParsingOption.legacy_syntax = false;
253  queryParsingOption.is_explain = false;
254  queryParsingOption.check_privileges = false;
255  queryParsingOption.is_explain_detail = false;
256 
257  TOptimizationOption optimizationOption = new TOptimizationOption();
258  optimizationOption.is_view_optimize = false;
259  optimizationOption.enable_watchdog = false;
260  optimizationOption.filter_push_down_info = new ArrayList<>();
261 
262  TPlanResult algebra = client.process("user",
263  "passwd",
264  "SALES",
265  query,
266  queryParsingOption,
267  optimizationOption,
268  null);
269  transport.close();
270  try {
271  assertEquals(algebra.plan_result, result);
272  } catch (AssertionError s) {
273  HEAVYDBLOGGER.error("error during callCalciteCheck");
274  throw s;
275  }
276  } catch (TException x) {
277  fail(x.toString());
278  }
279  }

+ Here is the caller graph for this function:

void com.mapd.parser.server.test.TestServer.randomCalciteCall ( )
inlineprivate

Definition at line 150 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.callCalciteCheck().

Referenced by com.mapd.parser.server.test.TestServer.testRandomCall(), and com.mapd.parser.server.test.TestServer.testThreadedCall().

150  {
151  Random r = new Random();
152  int aliasID = r.nextInt(100000) + 1000000;
154  String.format(
155  "Select TABALIAS%d.ENAME AS COLALIAS%d from EMP TABALIAS%d LIMIT %d",
156  aliasID,
157  aliasID,
158  aliasID,
159  aliasID),
160  String.format("{\n"
161  + " \"rels\": [\n"
162  + " {\n"
163  + " \"id\": \"0\",\n"
164  + " \"relOp\": \"LogicalTableScan\",\n"
165  + " \"fieldNames\": [\n"
166  + " \"EMPNO\",\n"
167  + " \"ENAME\",\n"
168  + " \"JOB\",\n"
169  + " \"MGR\",\n"
170  + " \"HIREDATE\",\n"
171  + " \"SAL\",\n"
172  + " \"COMM\",\n"
173  + " \"DEPTNO\",\n"
174  + " \"SLACKER\",\n"
175  + " \"SLACKARR1\",\n"
176  + " \"SLACKARR2\"\n"
177  + " ],\n"
178  + " \"table\": [\n"
179  + " \"CATALOG\",\n"
180  + " \"SALES\",\n"
181  + " \"EMP\"\n"
182  + " ],\n"
183  + " \"inputs\": []\n"
184  + " },\n"
185  + " {\n"
186  + " \"id\": \"1\",\n"
187  + " \"relOp\": \"LogicalProject\",\n"
188  + " \"fields\": [\n"
189  + " \"COLALIAS%d\"\n"
190  + " ],\n"
191  + " \"exprs\": [\n"
192  + " {\n"
193  + " \"input\": 1\n"
194  + " }\n"
195  + " ]\n"
196  + " },\n"
197  + " {\n"
198  + " \"id\": \"2\",\n"
199  + " \"relOp\": \"LogicalSort\",\n"
200  + " \"collation\": [],\n"
201  + " \"fetch\": {\n"
202  + " \"literal\": %d,\n"
203  + " \"type\": \"DECIMAL\",\n"
204  + " \"scale\": 0,\n"
205  + " \"precision\": 7,\n"
206  + " \"type_scale\": 0,\n"
207  + " \"type_precision\": 10\n"
208  + " }\n"
209  + " },\n"
210  + " {\n"
211  + " \"id\": \"3\",\n"
212  + " \"relOp\": \"LogicalProject\",\n"
213  + " \"fields\": [\n"
214  + " \"COLALIAS%d\"\n"
215  + " ],\n"
216  + " \"exprs\": [\n"
217  + " {\n"
218  + " \"input\": 0\n"
219  + " }\n"
220  + " ]\n"
221  + " },\n"
222  + " {\n"
223  + " \"id\": \"4\",\n"
224  + " \"relOp\": \"LogicalSort\",\n"
225  + " \"collation\": [],\n"
226  + " \"fetch\": {\n"
227  + " \"literal\": %d,\n"
228  + " \"type\": \"DECIMAL\",\n"
229  + " \"scale\": 0,\n"
230  + " \"precision\": 7,\n"
231  + " \"type_scale\": 0,\n"
232  + " \"type_precision\": 10\n"
233  + " }\n"
234  + " }\n"
235  + " ]\n"
236  + "}",
237  aliasID,
238  aliasID,
239  aliasID,
240  aliasID));
241  }
void callCalciteCheck(String query, String result)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void com.mapd.parser.server.test.TestServer.startServer ( )
inlinestatic

Definition at line 57 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.client_skT, com.mapd.parser.server.test.TestServer.csw, and com.mapd.parser.server.test.TestServer.server_skT.

57  {
58  csw = new CalciteServerWrapper(11000, 11001, "/data", null, client_skT, server_skT);
59  new Thread(csw).start();
60  }
static CalciteServerWrapper csw
Definition: TestServer.java:52
static SockTransportProperties client_skT
Definition: TestServer.java:53
static SockTransportProperties server_skT
Definition: TestServer.java:54
static void com.mapd.parser.server.test.TestServer.stopServer ( )
inlinestatic

Definition at line 63 of file TestServer.java.

63  {
64  csw.stopServer();
65  }
void com.mapd.parser.server.test.TestServer.testRandomCall ( )
inline

Definition at line 146 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.randomCalciteCall().

146  {
148  }

+ Here is the call graph for this function:

void com.mapd.parser.server.test.TestServer.testSimpleCall ( )
inline

Definition at line 102 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.callCalciteCheck().

102  {
103  callCalciteCheck("Select ENAME from EMP",
104  "{\n"
105  + " \"rels\": [\n"
106  + " {\n"
107  + " \"id\": \"0\",\n"
108  + " \"relOp\": \"LogicalTableScan\",\n"
109  + " \"fieldNames\": [\n"
110  + " \"EMPNO\",\n"
111  + " \"ENAME\",\n"
112  + " \"JOB\",\n"
113  + " \"MGR\",\n"
114  + " \"HIREDATE\",\n"
115  + " \"SAL\",\n"
116  + " \"COMM\",\n"
117  + " \"DEPTNO\",\n"
118  + " \"SLACKER\",\n"
119  + " \"SLACKARR1\",\n"
120  + " \"SLACKARR2\"\n"
121  + " ],\n"
122  + " \"table\": [\n"
123  + " \"CATALOG\",\n"
124  + " \"SALES\",\n"
125  + " \"EMP\"\n"
126  + " ],\n"
127  + " \"inputs\": []\n"
128  + " },\n"
129  + " {\n"
130  + " \"id\": \"1\",\n"
131  + " \"relOp\": \"LogicalProject\",\n"
132  + " \"fields\": [\n"
133  + " \"ENAME\"\n"
134  + " ],\n"
135  + " \"exprs\": [\n"
136  + " {\n"
137  + " \"input\": 1\n"
138  + " }\n"
139  + " ]\n"
140  + " }\n"
141  + " ]\n"
142  + "}");
143  }
void callCalciteCheck(String query, String result)

+ Here is the call graph for this function:

void com.mapd.parser.server.test.TestServer.testThreadedCall ( )
inline

Definition at line 68 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.ae, com.mapd.parser.server.test.TestServer.randomCalciteCall(), run, com.mapd.parser.server.test.TestServer.TEST_THREAD_COUNT, com.mapd.parser.server.test.TestServer.threadHadFailure, and com.mapd.parser.server.test.TestServer.threadsRun.

68  {
69  final ExecutorService pool = Executors.newFixedThreadPool(TEST_THREAD_COUNT);
70 
71  Runnable r = new Runnable() {
72  @Override
73  public void run() {
74  try {
75  for (int i = 1; i <= 5; i++) {
77  }
78  } catch (AssertionError x) {
79  HEAVYDBLOGGER.error("error during Runnable");
80  threadHadFailure = true;
81  ae = x;
82  }
83  threadsRun++;
85  pool.shutdown();
86  }
87  }
88  };
89 
90  for (int i = 0; i < TEST_THREAD_COUNT; i++) {
91  pool.submit(r);
92  }
93  while (!pool.isShutdown()) {
94  // stay alive
95  }
96  if (threadHadFailure) {
97  throw ae;
98  }
99  }
static bool run

+ Here is the call graph for this function:

Member Data Documentation

volatile AssertionError com.mapd.parser.server.test.TestServer.ae
private
SockTransportProperties com.mapd.parser.server.test.TestServer.client_skT = null
staticprivate

Definition at line 53 of file TestServer.java.

Referenced by com.mapd.parser.server.test.TestServer.startServer().

CalciteServerWrapper com.mapd.parser.server.test.TestServer.csw = null
staticprivate

Definition at line 52 of file TestServer.java.

Referenced by com.mapd.parser.server.test.TestServer.startServer().

final Logger com.mapd.parser.server.test.TestServer.HEAVYDBLOGGER = LoggerFactory.getLogger(TestServer.class)
staticprivate

Definition at line 47 of file TestServer.java.

SockTransportProperties com.mapd.parser.server.test.TestServer.server_skT = null
staticprivate

Definition at line 54 of file TestServer.java.

Referenced by com.mapd.parser.server.test.TestServer.startServer().

final int com.mapd.parser.server.test.TestServer.TEST_THREAD_COUNT = 3
staticprivate
volatile boolean com.mapd.parser.server.test.TestServer.threadHadFailure = false
private
volatile int com.mapd.parser.server.test.TestServer.threadsRun = 0
private

The documentation for this class was generated from the following file: