TEST_F(TupleSchemaTest, CreateEvictedTupleSchema) { initTable(true); // Create the TupleSchema for our evicted tuple tables // The first columns should be all of the columns of our primary key index TupleSchema *evictedSchema = TupleSchema::createEvictedTupleSchema(); // fprintf(stdout, "\nEVICTED TABLE SCHEMA\n%s\n", evictedSchema->debug().c_str()); ASSERT_EQ(2, evictedSchema->columnCount()); ASSERT_EQ(VALUE_TYPE_SMALLINT, evictedSchema->columnType(0)); ASSERT_EQ(VALUE_TYPE_INTEGER, evictedSchema->columnType(1)); TupleSchema::freeTupleSchema(evictedSchema); }
TEST_F(TupleSchemaTest, CreateEvictedTupleSchema) { initTable(true); // Create the TupleSchema for our evicted tuple tables // The first columns should be all of the columns of our primary key index TupleSchema *evictedSchema = TupleSchema::createEvictedTupleSchema(m_primaryKeyIndexSchema); // fprintf(stdout, "\nEVICTED TABLE SCHEMA\n%s\n", evictedSchema->debug().c_str()); ASSERT_EQ(m_numPrimaryKeyCols+1, evictedSchema->columnCount()); for (int i = 0; i < m_numPrimaryKeyCols; i++) { ASSERT_EQ(m_primaryKeyIndexSchema->columnType(i), evictedSchema->columnType(i)); ASSERT_EQ(m_primaryKeyIndexSchema->columnLength(i), evictedSchema->columnLength(i)); ASSERT_EQ(m_primaryKeyIndexSchema->columnAllowNull(i), evictedSchema->columnAllowNull(i)); } // Then there should only be one more column that contains the 16-bit block ids ASSERT_EQ(VALUE_TYPE_SMALLINT, evictedSchema->columnType(m_numPrimaryKeyCols)); ASSERT_FALSE(evictedSchema->columnAllowNull(m_numPrimaryKeyCols)); TupleSchema::freeTupleSchema(evictedSchema); }
TableIndex *TableIndexFactory::getInstance(const TableIndexScheme &scheme) { int colCount = (int)scheme.columnIndices.size(); TupleSchema *tupleSchema = scheme.tupleSchema; assert(tupleSchema); std::vector<ValueType> keyColumnTypes; std::vector<int32_t> keyColumnLengths; std::vector<bool> keyColumnAllowNull(colCount, true); for (int i = 0; i < colCount; ++i) { keyColumnTypes.push_back(tupleSchema->columnType(scheme.columnIndices[i])); keyColumnLengths.push_back(tupleSchema->columnLength(scheme.columnIndices[i])); } TupleSchema *keySchema = TupleSchema::createTupleSchema(keyColumnTypes, keyColumnLengths, keyColumnAllowNull, true); assert(keySchema); VOLT_TRACE("Creating index for %s.\n%s", scheme.name.c_str(), keySchema->debug().c_str()); TableIndexPicker picker(keySchema, scheme); TableIndex *retval = picker.getInstance(); return retval; }