示例#1
0
bool TableCountExecutor::p_execute(const NValueArray &params) {
    TableCountPlanNode* node = dynamic_cast<TableCountPlanNode*>(m_abstractNode);
    assert(node);
    Table* output_table = node->getOutputTable();
    assert(output_table);
    assert ((int)output_table->columnCount() == 1);

    Table* target_table = dynamic_cast<Table*>(node->getTargetTable());
    assert(target_table);
    VOLT_TRACE("Table Count table :\n %s",
               target_table->debug().c_str());
    VOLT_DEBUG("Table Count table : %s which has %d active, %d"
               " allocated",
               target_table->name().c_str(),
               (int)target_table->activeTupleCount(),
               (int)target_table->allocatedTupleCount());

    assert (node->getPredicate() == NULL);

    TableTuple& tmptup = output_table->tempTuple();
    tmptup.setNValue(0, ValueFactory::getBigIntValue( target_table->activeTupleCount() ));
    output_table->insertTuple(tmptup);


    //printf("Table count answer: %d", iterator.getSize());
    //printf("\n%s\n", output_table->debug().c_str());
    VOLT_TRACE("\n%s\n", output_table->debug().c_str());
    VOLT_DEBUG("Finished Table Counting");

    return true;
}
示例#2
0
bool TableCountExecutor::p_execute(const NValueArray &params) {
    TableCountPlanNode* node = dynamic_cast<TableCountPlanNode*>(m_abstractNode);
    assert(node);
    assert(node->getPredicate() == NULL);

    Table* output_table = node->getOutputTable();
    assert(output_table);
    assert ((int)output_table->columnCount() == 1);

    int64_t rowCounts = 0;
    if (node->isSubQuery()) {
        Table* input_table = node->getChildren()[0]->getOutputTable();
        assert(input_table);
        TempTable* temp_table = dynamic_cast<TempTable*>(input_table);
        if ( ! temp_table) {
            throw SerializableEEException(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION,
                                          "May not iterate a streamed table.");
        }
        rowCounts = temp_table->tempTableTupleCount();
    } else {
        PersistentTable* target_table = dynamic_cast<PersistentTable*>(node->getTargetTable());
        VOLT_DEBUG("Table Count table : %s which has %d active, %d visible, %d allocated",
                   target_table->name().c_str(),
                   (int)target_table->activeTupleCount(),
                   (int)target_table->visibleTupleCount(),
                   (int)target_table->allocatedTupleCount());

        rowCounts = target_table->visibleTupleCount();
    }

    TableTuple& tmptup = output_table->tempTuple();
    tmptup.setNValue(0, ValueFactory::getBigIntValue(rowCounts));
    output_table->insertTuple(tmptup);

    VOLT_DEBUG("\n%s\n", output_table->debug().c_str());
    VOLT_DEBUG("Finished Table Counting");

    return true;
}