Search in sources :

Example 71 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestStatisticsSuiteDatabaseElementStats method testIndexStatistics.

public void testIndexStatistics() throws Exception {
    System.out.println("\n\nTESTING INDEX STATS\n\n\n");
    Client client = getFullyConnectedClient();
    ColumnInfo[] expectedSchema = new ColumnInfo[12];
    expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
    expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
    expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
    expectedSchema[3] = new ColumnInfo("SITE_ID", VoltType.INTEGER);
    expectedSchema[4] = new ColumnInfo("PARTITION_ID", VoltType.BIGINT);
    expectedSchema[5] = new ColumnInfo("INDEX_NAME", VoltType.STRING);
    expectedSchema[6] = new ColumnInfo("TABLE_NAME", VoltType.STRING);
    expectedSchema[7] = new ColumnInfo("INDEX_TYPE", VoltType.STRING);
    expectedSchema[8] = new ColumnInfo("IS_UNIQUE", VoltType.TINYINT);
    expectedSchema[9] = new ColumnInfo("IS_COUNTABLE", VoltType.TINYINT);
    expectedSchema[10] = new ColumnInfo("ENTRY_COUNT", VoltType.BIGINT);
    expectedSchema[11] = new ColumnInfo("MEMORY_ESTIMATE", VoltType.BIGINT);
    VoltTable expectedTable = new VoltTable(expectedSchema);
    VoltTable[] results = null;
    boolean success = false;
    long start = System.currentTimeMillis();
    while (!success) {
        if (System.currentTimeMillis() - start > 60000)
            fail("Took too long");
        success = true;
        results = client.callProcedure("@Statistics", "index", 0).getResults();
        System.out.println("Index results: " + results[0].toString());
        assertEquals(1, results.length);
        validateSchema(results[0], expectedTable);
        if (success) {
            success = validateRowSeenAtAllSites(results[0], "INDEX_NAME", HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + "W_PK_TREE", true);
        }
        if (success) {
            success = validateRowSeenAtAllSites(results[0], "INDEX_NAME", HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + "I_PK_TREE", true);
        }
        if (success)
            break;
    }
}
Also used : ColumnInfo(org.voltdb.VoltTable.ColumnInfo) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 72 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class VarbinaryStringLookup method run.

public VoltTable[] run(long ival, String str1, String str2) {
    voltQueueSQL(sqlSelect, ival, str1);
    VoltTable t1 = voltExecuteSQL()[0];
    assert (t1.getRowCount() == 1);
    voltQueueSQL(sqlSelect, ival, str2);
    VoltTable t2 = voltExecuteSQL()[0];
    assert (t2.getRowCount() == 1);
    return new VoltTable[] { t1, t2 };
}
Also used : VoltTable(org.voltdb.VoltTable)

Example 73 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestCSVLoader method testCustomNULL.

@Test
public void testCustomNULL() throws Exception {
    String[] myOptions = { "-f" + path_csv, "--reportdir=" + reportDir, "--maxerrors=50", "--user=", "--password=", "--port=", "--separator=,", "--quotechar=\"", "--escape=\\", "--skip=0", "--customNullString=test", "BLAH" };
    //Both \N and \\N as csv input are treated as NULL
    String[] myData = { "1,1,1,11111111,test,1.10,1.11,,,", "2,2,1,11111111,\"test\",1.10,1.11,,,", "3,3,1,11111111,testme,1.10,1.11,,,", "4,4,1,11111111,iamtest,1.10,1.11,,,", "5,5,5,5,\\N,1.10,1.11,7777-12-25 14:35:26,POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"" };
    int invalidLineCnt = 0;
    int validLineCnt = myData.length - invalidLineCnt;
    test_Interface(myOptions, myData, invalidLineCnt, validLineCnt);
    VoltTable ts_table = client.callProcedure("@AdHoc", "SELECT * FROM BLAH ORDER BY clm_integer;").getResults()[0];
    int i = 0;
    int nulls = 0;
    while (ts_table.advanceRow()) {
        String value = ts_table.getString(4);
        if (i < 2) {
            assertEquals(value, null);
            nulls++;
        } else if (i == 4) {
            // this test case should fail once we stop replacing the \N as NULL
            assertEquals(value, null);
            nulls++;
        } else {
            assertNotNull(value);
        }
        i++;
    }
    assertEquals(nulls, 3);
}
Also used : VoltTable(org.voltdb.VoltTable) Test(org.junit.Test)

Example 74 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class DeletesClient method performSnapshot.

public static void performSnapshot(Client client) {
    checkSnapshotComplete(client);
    if (m_snapshotInProgress) {
        System.out.println("Snapshot still in progress, bailing");
        return;
    }
    try {
        VoltTable[] results = client.callProcedure("@SnapshotDelete", new String[] { m_snapshotDir }, new String[] { m_snapshotId }).getResults();
    } catch (NoConnectionsException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (ProcCallException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    // m_totalRows should be accurate at this point
    m_snapshotSizes.add(m_totalRows);
    System.out.println("Performing Snapshot with total rows: " + m_totalRows);
    try {
        if (m_blockingSnapshots) {
            ClientResponse response = client.callProcedure("@SnapshotSave", m_snapshotDir, m_snapshotId, 1);
            if (response.getStatus() != ClientResponse.SUCCESS) {
                System.out.println("failed snapshot");
                System.out.println(response.getStatusString());
            }
        } else {
            client.callProcedure(new ProcedureCallback() {

                @Override
                public void clientCallback(ClientResponse response) {
                    if (response.getStatus() != ClientResponse.SUCCESS) {
                        System.out.println("failed snapshot");
                        System.out.println(response.getStatusString());
                    }
                }
            }, "@SnapshotSave", m_snapshotDir, m_snapshotId, 0);
        }
    } catch (NoConnectionsException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ProcCallException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) ProcedureCallback(org.voltdb.client.ProcedureCallback) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 75 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class UpdateKey method run.

@SuppressWarnings("deprecation")
public long run(long rowid, long rowid_group, byte[] payload) {
    DB db = m_site.getLevelDBInstance();
    voltQueueSQL(check, rowid_group, rowid);
    VoltTable[] r1 = voltExecuteSQL();
    if (r1[0].asScalarLong() == 0) {
        // System.out.println("Not found: " + rowid_group + "_" + rowid);
        // evict a key if necessary
        voltQueueSQL(residentGroups);
        VoltTable[] r2 = voltExecuteSQL();
        if (r2[0].asScalarLong() >= MAX_GROUPS) {
            // System.out.printf("\tCurrent group count (%d) exceeds max (%d) - evicting!\n",
            //                r2[0].asScalarLong(), MAX_GROUPS);
            voltQueueSQL(minAtimeGroupId);
            VoltTable[] r3 = voltExecuteSQL();
            long groupId = r3[0].asScalarLong();
            voltQueueSQL(evictedGroup, groupId);
            VoltTable evictions = voltExecuteSQL()[0];
            long evictedCount = 0;
            while (evictions.advanceRow()) {
                ++evictedCount;
                // System.out.printf("\tEvicting (%d) groupId (%d_%d)\n", evictedCount,  groupId, evictions.getLong(0));
                byte[] key = makeKey(groupId, evictions.getLong(0));
                db.put(key, evictions.getVarbinary(1));
            }
            voltQueueSQL(deleteEvicted, EXPECT_SCALAR_MATCH(evictedCount), groupId);
            VoltTable[] r4 = voltExecuteSQL();
        // System.out.println("Evicted " + r4[0].asScalarLong() + " rows. Expected: " + evictedCount);
        }
        // TODO: this needs to iterate for all rowid keys
        byte[] oldpayload = db.get(makeKey(rowid_group, rowid));
        if (oldpayload == null) {
            VoltDB.crashLocalVoltDB("Could not find payload from expected key: " + rowid_group + "_" + rowid, false, null);
        }
        // System.out.println("\tMigrating key: " + rowid_group + "_" + rowid);
        voltQueueSQL(insert, EXPECT_SCALAR_MATCH(1), rowid_group, rowid, DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this), oldpayload);
        voltExecuteSQL();
    }
    // perform in the in-memory update
    // System.out.println("Updating atime on key: " + rowid_group + "_" + rowid);
    voltQueueSQL(update, EXPECT_SCALAR_MATCH(1), DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this), payload, rowid_group, rowid);
    return 0;
}
Also used : VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB)

Aggregations

VoltTable (org.voltdb.VoltTable)887 Client (org.voltdb.client.Client)497 ClientResponse (org.voltdb.client.ClientResponse)193 ProcCallException (org.voltdb.client.ProcCallException)144 IOException (java.io.IOException)100 VoltTableRow (org.voltdb.VoltTableRow)57 NoConnectionsException (org.voltdb.client.NoConnectionsException)52 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)42 TimestampType (org.voltdb.types.TimestampType)37 BigDecimal (java.math.BigDecimal)30 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)26 File (java.io.File)25 HashMap (java.util.HashMap)21 ClientResponseImpl (org.voltdb.ClientResponseImpl)20 Timestamp (java.sql.Timestamp)15 Date (java.util.Date)15 VoltDB (org.voltdb.VoltDB)15 DependencyPair (org.voltdb.DependencyPair)14 Configuration (org.voltdb.VoltDB.Configuration)14