Search in sources :

Example 1 with HashRangeExpressionBuilder

use of org.voltdb.expressions.HashRangeExpressionBuilder in project voltdb by VoltDB.

the class TestExecutionEngine method testStreamIndex.

public void testStreamIndex() throws Exception {
    sourceEngine.loadCatalog(0, m_catalog.serialize());
    // Each EE needs its own thread for correct initialization.
    final AtomicReference<ExecutionEngine> destinationEngine = new AtomicReference<ExecutionEngine>();
    final byte[] configBytes = LegacyHashinator.getConfigureBytes(1);
    Thread destEEThread = new Thread() {

        @Override
        public void run() {
            destinationEngine.set(new ExecutionEngineJNI(CLUSTER_ID, NODE_ID, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, configBytes, 0, 0), false));
        }
    };
    destEEThread.start();
    destEEThread.join();
    destinationEngine.get().loadCatalog(0, m_catalog.serialize());
    int STOCK_TABLEID = stockTableId(m_catalog);
    loadTestTables(sourceEngine, m_catalog);
    SnapshotPredicates predicates = new SnapshotPredicates(-1);
    predicates.addPredicate(new HashRangeExpressionBuilder().put(0x00000000, 0x7fffffff).build(0), true);
    // Build the index
    sourceEngine.activateTableStream(STOCK_TABLEID, TableStreamType.ELASTIC_INDEX, Long.MAX_VALUE, predicates.toBytes());
    // Humor serializeMore() by providing a buffer, even though it's not used.
    final BBContainer origin = DBBPool.allocateDirect(1024 * 1024 * 2);
    origin.b().clear();
    BBContainer container = new BBContainer(origin.b()) {

        @Override
        public void discard() {
            checkDoubleFree();
            origin.discard();
        }
    };
    try {
        List<BBContainer> output = new ArrayList<BBContainer>();
        output.add(container);
        assertEquals(0, sourceEngine.tableStreamSerializeMore(STOCK_TABLEID, TableStreamType.ELASTIC_INDEX, output).getSecond()[0]);
    } finally {
        container.discard();
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) SnapshotPredicates(org.voltdb.sysprocs.saverestore.SnapshotPredicates) HashRangeExpressionBuilder(org.voltdb.expressions.HashRangeExpressionBuilder) BBContainer(org.voltcore.utils.DBBPool.BBContainer)

Aggregations

ArrayList (java.util.ArrayList)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 BBContainer (org.voltcore.utils.DBBPool.BBContainer)1 HashinatorConfig (org.voltdb.TheHashinator.HashinatorConfig)1 HashRangeExpressionBuilder (org.voltdb.expressions.HashRangeExpressionBuilder)1 SnapshotPredicates (org.voltdb.sysprocs.saverestore.SnapshotPredicates)1