use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class AdHocNTBase method processExplainPlannedStmtBatch.
static CompletableFuture<ClientResponse> processExplainPlannedStmtBatch(AdHocPlannedStmtBatch planBatch) {
/**
* Take the response from the async ad hoc planning process and put the explain
* plan in a table with the right format.
*/
Database db = VoltDB.instance().getCatalogContext().database;
int size = planBatch.getPlannedStatementCount();
VoltTable[] vt = new VoltTable[size];
for (int i = 0; i < size; ++i) {
vt[i] = new VoltTable(new VoltTable.ColumnInfo("EXECUTION_PLAN", VoltType.STRING));
String str = planBatch.explainStatement(i, db);
vt[i].addRow(str);
}
ClientResponseImpl response = new ClientResponseImpl(ClientResponseImpl.SUCCESS, ClientResponse.UNINITIALIZED_APP_STATUS_CODE, null, vt, null);
CompletableFuture<ClientResponse> fut = new CompletableFuture<>();
fut.complete(response);
return fut;
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class plannerTester method loadPlanFromFile.
public static AbstractPlanNode loadPlanFromFile(String path, ArrayList<String> getsql) {
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(path));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
String message = "ERROR: Plan file " + path + " doesn't exist.\n" + "Use -s (the Compile/Save option) or 'ant plannertestrefresh'" + " ' to generate plans to the baseline directory.\n";
System.err.print(message);
try {
m_reportWriter.write(message);
} catch (IOException e2) {
e2.printStackTrace();
}
return null;
}
try {
String json = "";
try {
String line = reader.readLine();
getsql.add(line);
while ((line = reader.readLine()) != null) {
json += line;
}
} catch (IOException e2) {
e2.printStackTrace();
return null;
}
try {
PlanNodeTree pnt = new PlanNodeTree();
JSONObject jobj = new JSONObject(json);
Database db = s_singleton.getDatabase();
pnt.loadFromJSONPlan(jobj, db);
return pnt.getRootPlanNode();
} catch (JSONException e3) {
e3.printStackTrace();
System.out.println("Failed on input from file: " + path + " with JSON text: \n'" + json + "'");
return null;
}
} finally {
try {
reader.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class GenerateEETests method generatedInlineInsertPlan.
public void generatedInlineInsertPlan() throws Exception {
Database db = getDatabase();
final TableConfig T2Config = new TableConfig("T2", db, new Object[][] { { 100, 100, 100 } });
final TableConfig answerConfig = new TableConfig("IIANSWER", db, new Object[][] { { 1 } });
DBConfig IIDB = new DBConfig(getClass(), GenerateEETests.class.getResource(DDL_FILENAME), getCatalogString(), T2Config, answerConfig);
IIDB.addTest(new TestConfig("test_inline_insert", "INSERT INTO P1 SELECT * FROM T2", false, answerConfig).setPlanFragment(1));
generateTests("executors", "TestInlineInsert", IIDB);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class GenerateEETests method generatedMinPlan.
public void generatedMinPlan() throws Exception {
Database db = getDatabase();
TableConfig TConfig = makeTConfig(db);
TableConfig testOutput = makeTestOutput(db);
DBConfig minDB = new DBConfig(getClass(), GenerateEETests.class.getResource(DDL_FILENAME), getCatalogString(), TConfig, testOutput);
minDB.addTest(new TestConfig("test_min_last_row", "select A, B, min(abs(5-C)) over (partition by A order by B) as R from T ORDER BY A, B, R;", false, testOutput));
minDB.addTest(new TestConfig("test_min_middle_row", "select A, B, min(abs(3-C)) over (partition by A order by B) as R from T ORDER BY A, B, R;", false, testOutput));
minDB.addTest(new TestConfig("test_min_first_row", "select A, B, min(abs(1-C)) over (partition by A order by B) as R from T ORDER BY A, B, R;", false, testOutput));
generateTests("executors", "TestWindowedMin", minDB);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class Site method loadTable.
@Override
public byte[] loadTable(long txnId, long spHandle, long uniqueId, String clusterName, String databaseName, String tableName, VoltTable data, boolean returnUniqueViolations, boolean shouldDRStream, boolean undo) throws VoltAbortException {
Cluster cluster = m_context.cluster;
if (cluster == null) {
throw new VoltAbortException("cluster '" + clusterName + "' does not exist");
}
Database db = cluster.getDatabases().get(databaseName);
if (db == null) {
throw new VoltAbortException("database '" + databaseName + "' does not exist in cluster " + clusterName);
}
Table table = db.getTables().getIgnoreCase(tableName);
if (table == null) {
throw new VoltAbortException("table '" + tableName + "' does not exist in database " + clusterName + "." + databaseName);
}
return loadTable(txnId, spHandle, uniqueId, table.getRelativeIndex(), data, returnUniqueViolations, shouldDRStream, undo);
}
Aggregations