示例#1
0
TEST_F(TableTests, generate_generates_layout) {

  TableGenerator tg;
  hyrise::storage::atable_ptr_t  input = tg.create_empty_table(0, 10);
  ASSERT_EQ(10u, input->partitionCount());

  std::vector<unsigned> l;
  l.push_back(3);
  l.push_back(7);

  input = tg.create_empty_table(0, 10, l);
  ASSERT_EQ(2u, input->partitionCount());

  l.clear();
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);
  l.push_back(1);

  input = tg.create_empty_table(0, 10, l);
  ASSERT_EQ(10u, input->partitionCount());
}
示例#2
0
TEST_F(TableTests, test_modifiable_table) {
  TableGenerator t;
  hyrise::storage::atable_ptr_t a = t.create_empty_table_modifiable(10, 2);
  a->setValue<hyrise_int_t>(0, 0, 100);
  a->setValue<hyrise_int_t>(0, 1, 200);
  ASSERT_EQ(a->getValue<hyrise_int_t>(0, 0), 100);
  ASSERT_EQ(a->getValue<hyrise_int_t>(0, 1), 200);
}
QComposeInputContext::QComposeInputContext()
{
    TableGenerator reader;
    m_tableState = reader.tableState();

    if ((m_tableState & TableGenerator::NoErrors) == TableGenerator::NoErrors) {
        m_composeTable = reader.composeTable();
        clearComposeBuffer();
    }
}
示例#4
0
TEST_F(TableTests, test_table_copy) {
  TableGenerator t;
  hyrise::storage::atable_ptr_t a = t.create_empty_table_modifiable(10, 2);
  a->setValue<hyrise_int_t>(0, 0, 100);
  a->setValue<hyrise_int_t>(0, 1, 200);

  hyrise::storage::atable_ptr_t b = a->copy();
  b->setValue<hyrise_int_t>(0, 0, 50);
  b->setValue<hyrise_int_t>(0, 1, 100);
}
示例#5
0
bool QComposeInputContext::checkComposeTable()
{
    if (!m_compositionTableInitialized) {
        TableGenerator reader;
        m_tableState = reader.tableState();

        m_compositionTableInitialized = true;
        if ((m_tableState & TableGenerator::NoErrors) == TableGenerator::NoErrors) {
            m_composeTable = reader.composeTable();
        } else {
#ifdef DEBUG_COMPOSING
            qDebug( "### FAILED_PARSING ###" );
#endif
            // if we have errors, don' try to look things up anyways.
            reset();
            return false;
        }
    }
    Q_ASSERT(!m_composeTable.isEmpty());
    QVector<QComposeTableElement>::const_iterator it =
            std::lower_bound(m_composeTable.constBegin(), m_composeTable.constEnd(), m_composeBuffer, ByKeys());

    // prevent dereferencing an 'end' iterator, which would result in a crash
    if (it == m_composeTable.constEnd())
        it -= 1;

    QComposeTableElement elem = *it;
    // would be nicer if qLowerBound had API that tells if the item was actually found
    if (m_composeBuffer[0] != elem.keys[0]) {
#ifdef DEBUG_COMPOSING
        qDebug( "### no match ###" );
#endif
        reset();
        return false;
    }
    // check if compose buffer is matched
    for (int i=0; i < QT_KEYSEQUENCE_MAX_LEN; i++) {

        // check if partial match
        if (m_composeBuffer[i] == 0 && elem.keys[i]) {
#ifdef DEBUG_COMPOSING
            qDebug("### partial match ###");
#endif
            return true;
        }

        if (m_composeBuffer[i] != elem.keys[i]) {
#ifdef DEBUG_COMPOSING
            qDebug("### different entry ###");
#endif
            reset();
            return i != 0;
        }
    }
#ifdef DEBUG_COMPOSING
    qDebug("### match exactly ###");
#endif

    // check if the key sequence is overwriten - see the comment in
    // TableGenerator::orderComposeTable()
    int next = 1;
    do {
        // if we are at the end of the table, then we have nothing to do here
        if (it + next != m_composeTable.constEnd()) {
            QComposeTableElement nextElem = *(it + next);
            if (isDuplicate(elem, nextElem)) {
                elem = nextElem;
                next++;
                continue;
            } else {
                break;
            }
        }
        break;
    } while (true);

    commitText(elem.value);
    reset();

    return true;
}