Search in sources :

Example 36 with Database

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;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) CompletableFuture(java.util.concurrent.CompletableFuture) Database(org.voltdb.catalog.Database) ClientResponseImpl(org.voltdb.ClientResponseImpl) VoltTable(org.voltdb.VoltTable)

Example 37 with Database

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();
        }
    }
}
Also used : JSONObject(org.json_voltpatches.JSONObject) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) Database(org.voltdb.catalog.Database) JSONException(org.json_voltpatches.JSONException) FileReader(java.io.FileReader) IOException(java.io.IOException) PlanNodeTree(org.voltdb.plannodes.PlanNodeTree)

Example 38 with Database

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);
}
Also used : Database(org.voltdb.catalog.Database)

Example 39 with Database

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);
}
Also used : Database(org.voltdb.catalog.Database)

Example 40 with Database

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);
}
Also used : VoltTable(org.voltdb.VoltTable) Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) Cluster(org.voltdb.catalog.Cluster) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Aggregations

Database (org.voltdb.catalog.Database)62 Table (org.voltdb.catalog.Table)22 Catalog (org.voltdb.catalog.Catalog)12 Cluster (org.voltdb.catalog.Cluster)10 File (java.io.File)9 Column (org.voltdb.catalog.Column)9 Procedure (org.voltdb.catalog.Procedure)9 IOException (java.io.IOException)5 VoltTable (org.voltdb.VoltTable)5 ArrayList (java.util.ArrayList)4 Group (org.voltdb.catalog.Group)4 Connector (org.voltdb.catalog.Connector)3 Constraint (org.voltdb.catalog.Constraint)3 Statement (org.voltdb.catalog.Statement)3 FileNotFoundException (java.io.FileNotFoundException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 JAXBException (javax.xml.bind.JAXBException)2