Examples of VoltTable


Examples of org.voltdb.VoltTable

       
        Map<Integer, Long> expectedValues = new HashMap<Integer, Long>();
        for (int i = 0; i < 5; i++) {
            int fragmentId = baseFragmentId + i;
            long expected = baseValue + i;
            VoltTable result = new VoltTable(TARGET_RESULT);
            result.addRow(expected);
            expectedValues.put(fragmentId, expected);
       
            // First store it in the cache
            this.cache.addResult(txnId, fragmentId, partitionId, params, result);
        } // FOR
//        System.err.println(StringUtil.formatMaps(expectedValues));
//        System.err.println("---------------");
//        System.err.println(this.cache.toString());
       
        // Then ask for them back in a shuffled order
        List<Integer> fragmentIds = new ArrayList<Integer>(expectedValues.keySet());
        Collections.shuffle(fragmentIds);
        for (Integer fragmentId : fragmentIds) {
            long expected = expectedValues.get(fragmentId);
            VoltTable cacheResult = this.cache.getResult(txnId, fragmentId, partitionId, params);
            assertNotNull(fragmentId.toString(), cacheResult);
            assertEquals(1, cacheResult.getRowCount());
            assertEquals(expected, cacheResult.asScalarLong());
        } // FOR
       
        // If we change the params, we should never get back our results
        params = new ParameterSet("WuTang!", 1981);
        for (Integer fragmentId : fragmentIds) {
            VoltTable cacheResult = this.cache.getResult(txnId, fragmentId, partitionId, params);
            assertNull(fragmentId.toString(), cacheResult);
        } // FOR
       
        // Now create a new ParameteSet with the same values and make
        // sure get back the same results.
        params = new ParameterSet("Squi" + "rrels", 1981);
        for (Integer fragmentId : fragmentIds) {
            long expected = expectedValues.get(fragmentId);
            VoltTable cacheResult = this.cache.getResult(txnId, fragmentId, partitionId, params);
            assertNotNull(fragmentId.toString(), cacheResult);
            assertEquals(1, cacheResult.getRowCount());
            assertEquals(expected, cacheResult.asScalarLong());
        } // FOR
    }
View Full Code Here

Examples of org.voltdb.VoltTable

            SendDataRequest.Builder builder = SendDataRequest.newBuilder()
                                                .setTransactionId(txn_id.longValue())
                                                .setSenderSite(local_site_id);
            // Loop through and get all the data for this site
            for (Partition catalog_part : remote_site.getPartitions()) {
                VoltTable vt = data.get(catalog_part.getId());
                if (vt == null) {
                    LOG.warn("No data in " + ts + " for partition " + catalog_part.getId());
                    continue;
                }
                ByteString bs = null;
                byte bytes[] = null;
                try {
                    bytes = ByteBuffer.wrap(FastSerializer.serialize(vt)).array();
                    bs = ByteString.copyFrom(bytes);
                    if (debug.val)
                        LOG.debug(String.format("%s - Outbound data for partition #%d " +
                              "[RowCount=%d / MD5=%s / Length=%d]",
                                  ts, catalog_part.getId(),
                                  vt.getRowCount(), StringUtil.md5sum(bytes), bytes.length));
                } catch (Exception ex) {
                    String msg = String.format("Unexpected error when serializing %s data for partition %d",
                                               ts, catalog_part.getId());
                    throw new ServerFaultException(msg, ex, ts.getTransactionId());
                }
                if (trace.val)
                    LOG.trace("Constructing Dependency for " + catalog_part);
                builder.addDepId(catalog_part.getId())
                       .addData(bs);
            } // FOR n partitions in remote_site
           
            if (builder.getDataCount() > 0) {
                if (debug.val)
                    LOG.debug(String.format("%s - Sending data to %d partitions at %s for %s",
                              ts, builder.getDataCount(), remote_site, ts));
                this.channels[dest_site_id].sendData(new ProtoRpcController(), builder.build(), callback);
            }
        } // FOR n sites in this catalog
               
        for (int partition : hstore_site.getLocalPartitionIds().values()) {
            VoltTable vt = data.get(Integer.valueOf(partition));
            if (vt == null) {
                LOG.warn("No data in " + ts + " for partition " + partition);
                continue;
            }
            if (debug.val) LOG.debug(String.format("Storing VoltTable directly at local partition %d for %s", partition, ts));
View Full Code Here

Examples of org.voltdb.VoltTable

    // UTILITY METHODS
    // --------------------------------------------------------------------------------------------
   
    private void loadData() throws Exception {
        // Load in a bunch of dummy data for this table
        VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
        assertNotNull(vt);
        for (int i = 0; i < NUM_TUPLES; i++) {
            Object row[] = VoltTableUtil.getRandomRow(catalog_tbl);
            row[0] = i;
            vt.addRow(row);
            if (i == 1) readBackTracker = row[1].toString();
        } // FOR
        this.executor.loadTable(1000l, catalog_tbl, vt, false);
       
        VoltTable stats[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, stats.length);
        System.err.println(VoltTableUtil.format(stats));
    }
View Full Code Here

Examples of org.voltdb.VoltTable

        assertEquals(1, stats.length);
        System.err.println(VoltTableUtil.format(stats));
    }
   
    private VoltTable evictData() throws Exception {
        VoltTable results[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
        assertEquals(1, results.length);
        // System.err.println(VoltTableUtil.format(results));
        for (String col : statsFields) {
      results[0].advanceRow();
            int idx = results[0].getColumnIndex(col);
            assertEquals(0, results[0].getLong(idx));   
        } // FOR

        // Now force the EE to evict our boys out
        // We'll tell it to remove 1MB, which is guaranteed to include all of our tuples
        VoltTable evictResult = this.ee.antiCacheEvictBlock(catalog_tbl, 1024 * 500, 1);

        System.err.println("-------------------------------");
        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);
          return (evictResult);
    }
View Full Code Here

Examples of org.voltdb.VoltTable

            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

Examples of org.voltdb.VoltTable

    @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

Examples of org.voltdb.VoltTable

    @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

Examples of org.voltdb.VoltTable

    }
   
    @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

Examples of org.voltdb.VoltTable

    @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

Examples of org.voltdb.VoltTable

            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
TOP
Copyright © 2018 www.massapi.com. 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.