Package org.voltdb

Examples of org.voltdb.VoltTable$Row


            writtenFields[i] = statsFields[i].replace("EVICTED", "WRITTEN");
            readFields[i] = statsFields[i].replace("EVICTED", "READ");
        } // FOR
       
        // Evict some data
        VoltTable evictResult = this.evictData();
       
        // Check to make sure that our stats say that something was evicted
        VoltTable origStats[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, origStats.length);
        System.err.println(VoltTableUtil.format(origStats));
        adv = origStats[0].advanceRow();
        assert(adv);
        for (int i = 0; i < statsFields.length; i++) {
            // ACTIVE
            assertTrue(statsFields[i], evictResult.getLong(statsFields[i]) > 0);
            assertEquals(statsFields[i], evictResult.getLong(statsFields[i]), origStats[0].getLong(statsFields[i]));
           
            // GLOBAL WRITTEN
            assertEquals(writtenFields[i], evictResult.getLong(statsFields[i]), origStats[0].getLong(writtenFields[i]));
           
            // GLOBAL READ
            assertEquals(readFields[i], 0, origStats[0].getLong(readFields[i]));
        } // FOR
       
        // TODO: Check that the string data has all been evicted.
       
        // Now execute a query that needs to access data from this block
        long expected = 1;
        Procedure proc = this.getProcedure("GetRecord");
        ClientResponse cresponse = this.client.callProcedure(proc.getName(), expected);
        assertEquals(Status.OK, cresponse.getStatus());
       
        // Check to make sure that our stats were updated
        VoltTable newStats[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, newStats.length);
        System.err.println(VoltTableUtil.format(newStats));
        adv = newStats[0].advanceRow();
        assert(adv);
        for (int i = 0; i < statsFields.length; i++) {
            // ACTIVE
            assertEquals(statsFields[i], 0, newStats[0].getLong(statsFields[i]));
           
            // GLOBAL WRITTEN
            assertEquals(writtenFields[i], origStats[0].getLong(writtenFields[i]), newStats[0].getLong(writtenFields[i]));
           
            // GLOBAL READ
            assertEquals(readFields[i], origStats[0].getLong(writtenFields[i]), newStats[0].getLong(readFields[i]));
        } // FOR
       
        // Check that the global stats for the site matches too
        this.executor.getDebugContext().updateMemory();
        proc = this.getProcedure(VoltSystemProcedure.procCallName(Statistics.class));
        Object params[] = { SysProcSelector.MEMORY.name(), 0 };
        cresponse = this.client.callProcedure(proc.getName(), params);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results = cresponse.getResults()[0];
        adv = results.advanceRow();
        assert(adv);
        for (int i = 0; i < statsFields.length; i++) {
            // XXX: Skip the byte counters since it will be kilobytes
            if (statsFields[i].contains("BYTES")) continue;
           
            // ACTIVE
            assertEquals(statsFields[i], newStats[0].getLong(statsFields[i]), results.getLong(statsFields[i]));
           
            // GLOBAL WRITTEN
            assertEquals(writtenFields[i], newStats[0].getLong(writtenFields[i]), results.getLong(writtenFields[i]));
           
            // GLOBAL READ
            assertEquals(readFields[i], newStats[0].getLong(readFields[i]), results.getLong(readFields[i]));
        } // FOR
       
    }
View Full Code Here


    @Test
    public void testReadEvictedTuples() throws Exception {
        this.loadData();
       
        // We should have all of our tuples evicted
        VoltTable evictResult = this.evictData();
        long evicted = evictResult.getLong("ANTICACHE_TUPLES_EVICTED");
        assertTrue("No tuples were evicted!"+evictResult, evicted > 0);
       
        // Now execute a query that needs to access data from this block
        long expected = 1;
        Procedure proc = this.getProcedure("GetRecord"); // Special Single-Stmt Proc
        ClientResponse cresponse = this.client.callProcedure(proc.getName(), expected);
        assertEquals(Status.OK, cresponse.getStatus());
       
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        boolean adv = results[0].advanceRow();
        assertTrue(adv);
        assertEquals(expected, results[0].getLong(0));
View Full Code Here

    @Test
    public void testMultipleReadEvictedTuples() throws Exception {
        this.loadData();
       
        // We should have all of our tuples evicted
        VoltTable evictResult = this.evictData();
        long evicted = evictResult.getLong("ANTICACHE_TUPLES_EVICTED");
        assertTrue("No tuples were evicted!"+evictResult, evicted > 0);
       
        // Execute multiple queries that try to access tuples the same block
        // Only one should get an evicted access exception
        Procedure proc = this.getProcedure("GetRecord"); // Special Single-Stmt Proc
        for (int i = 1; i < 10; i++) {
            long expected = i;
            ClientResponse cresponse = this.client.callProcedure(proc.getName(), expected);
            assertEquals(Status.OK, cresponse.getStatus());
           
            VoltTable results[] = cresponse.getResults();
            assertEquals(1, results.length);
            boolean adv = results[0].advanceRow();
            assertTrue(adv);
            assertEquals(expected, results[0].getLong(0));
        } // FOR
View Full Code Here

    }
   
    @Test
    public void testEvictTuples() throws Exception {
        this.loadData();
        VoltTable evictResult = this.evictData();
    evictResult.advanceRow();

        // Our stats should now come back with at least one block evicted
        VoltTable results[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, results.length);
        System.err.println("-------------------------------");
        System.err.println(VoltTableUtil.format(results));

    results[0].advanceRow();
View Full Code Here

    @Test
    public void testEvictTuplesMultiple() throws Exception {
        // Just checks whether we can call evictBlock multiple times
        this.loadData();

        VoltTable results[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, results.length);
        System.err.println(VoltTableUtil.format(results));

    results[0].advanceRow();
        for (String col : statsFields) {
            int idx = results[0].getColumnIndex(col);
            assertEquals(0, results[0].getLong(idx));   
        } // FOR
        System.err.println(StringUtil.repeat("=", 100));
       
        // Now force the EE to evict our boys out in multiple rounds
        VoltTable evictResult = null;
        for (int i = 0; i < 5; i++) {
            if (i > 0) {
                System.err.println(StringUtil.repeat("-", 100));
                ThreadUtil.sleep(1000);
            }
            System.err.println("Eviction #" + i);
            evictResult = this.ee.antiCacheEvictBlock(catalog_tbl, 512, 1);
            System.err.println(VoltTableUtil.format(evictResult));
            assertNotNull(evictResult);
            assertEquals(1, evictResult.getRowCount());
            assertNotSame(results[0].getColumnCount(), evictResult.getColumnCount());
            evictResult.resetRowPosition();
            boolean adv = evictResult.advanceRow();
            assertTrue(adv);
        } // FOR
    }
View Full Code Here

            partitionedTables.put(partition, CatalogUtil.getVoltTable(ts.getMapEmit()));
        } // FOR
        if (debug.val)
            LOG.debug(String.format("Created %d VoltTables for SHUFFLE phase of %s", partitionedTables.size(), ts));

        VoltTable table = null;
        int rp = -1;
        for (int partition : this.hstore_site.getLocalPartitionIds()) {

            table = ts.getMapOutputByPartition(partition);

            assert (table != null) : String.format("Missing MapOutput table for txn #%d", ts.getTransactionId());

            while (table.advanceRow()) {
                int rowPartition = -1;
                try {
                    rowPartition = p_estimator.getTableRowPartition(ts.getMapEmit(), table);
                } catch (Exception e) {
                    LOG.fatal("Failed to split input table into partitions", e);
                    throw new RuntimeException(e.getMessage());
                }
                if (trace.val)
                    LOG.trace(Arrays.toString(table.getRowArray()) + " => " + rowPartition);
                assert (rowPartition >= 0);
                // this adds the active row from table
                partitionedTables.get(rowPartition).add(table);
                rp = rowPartition;
            } // WHILE
View Full Code Here

    }
   
    /** Load 1 1's, 2 2's, 3 3's .. 10 10's and 1 11 */
    private int loaderNxN(Client client, int pkey) throws ProcCallException,
    IOException, NoConnectionsException {
        VoltTable vt;
        //String qs;
        // Insert some known data. Insert {1, 2, 2, 3, 3, 3, ... }
        for (int i = 1; i <= 10; i++) {
            for (int j = 0; j < i; j++) {
                //qs = "INSERT INTO T1 VALUES (" + pkey++ + ", " + i + ");";
                vt = client.callProcedure("T1Insert", pkey++, i).getResults()[0];
                assertTrue(vt.getRowCount() == 1);
                // assertTrue(vt.asScalarLong() == 1);
            }
        }
        // also add a single "11" to make verification a bit saner
        // (so that the table results of "count" and "group by" can be
        // distinguished)
        vt = client.callProcedure("@AdHoc", "insert into t1 values (" + pkey++
                + ",11);").getResults()[0];
        assertTrue(vt.getRowCount() == 1);
        // assertTrue(vt.asScalarLong() == 1);
        return pkey;
    }
View Full Code Here

    /** load known data to F without loading the Dimension tables
     * @throws InterruptedException */
    private int loadF(Client client, int pkey) throws NoConnectionsException,
    ProcCallException, IOException, InterruptedException {
        VoltTable vt;

        // if you want to test synchronous latency, this
        //  is a good variable to change
        boolean async = true;

        // val1 = constant value 2
        // val2 = i * 10
        // val3 = 0 for even i, 1 for odd i

        for (int i = 0; i < 1000; i++) {

            int f_d1 = i % 10; // 10 unique dim1s
            int f_d2 = i % 50; // 50 unique dim2s
            int f_d3 = i % 100; // 100 unique dim3s

            boolean done;
            SyncCallback cb = new SyncCallback();
            do {
                done = client.callProcedure(cb, "InsertF", pkey++, f_d1, f_d2, f_d3,
                                            2, (i * 10), (i % 2));
                if (!done) {
                    client.backpressureBarrier();
                }
            } while (!done);


            if (!async) {
                cb.waitForResponse();
                vt = cb.getResponse().getResults()[0];
                assertTrue(vt.getRowCount() == 1);
                // assertTrue(vt.asScalarLong() == 1);
            }
        }

        client.drain();
View Full Code Here

    }

    /** select A1 from T1 group by A1 */
    public void testSelectAGroubyA() throws IOException, ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc", "Select * from T1").getResults()[0];
        System.out.println("T1-*:" + vt);

        // execute the query
        vt = client.callProcedure("@AdHoc", "SELECT A1 from T1 group by A1").getResults()[0];

        // one row per unique value of A1
        System.out.println("testSelectAGroubyA: " + vt);
        assertTrue(vt.getRowCount() == 11);

        // Selecting A1 - should get values 1 through 11
        // once each. These results aren't necessarily ordered.
        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertTrue(A1 <= 11);
            assertTrue(A1 > 0);
            found[A1.intValue()] += 1;
        }
        assertEquals(0, found[0]);
View Full Code Here

    /** select count(A1) from T1 group by A1 */
    public void testSelectCountAGroupbyA() throws IOException,
    ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc",
        "select count(A1) from T1 group by A1").getResults()[0];
        System.out.println("testSelectCountAGroupbyA result: " + vt);
        assertTrue(vt.getRowCount() == 11);

        // Selecting count(A1) - should get two counts of 1 and one count each
        // of 2-10: (1, 1, 2, 3, 4, .. 10).
        // These results aren't necessarily ordered
        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertTrue(A1 <= 10);
            assertTrue(A1 > 0);
            found[A1.intValue()] += 1;
        }
        assertEquals(0, found[0]);
View Full Code Here

TOP

Related Classes of org.voltdb.VoltTable$Row

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.