本文整理汇总了C++中TupleSchema::tupleLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TupleSchema::tupleLength方法的具体用法?C++ TupleSchema::tupleLength怎么用?C++ TupleSchema::tupleLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TupleSchema
的用法示例。
在下文中一共展示了TupleSchema::tupleLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: domRoot
/*
* Show that the hash range expression correctly selects (or doesn't) rows in ranges
*/
TEST_F(ExpressionTest, HashRange) {
queue<AE*> e;
const int32_t range1Max = -(numeric_limits<int32_t>::max() / 2);
const int32_t range1Min = numeric_limits<int32_t>::min() - (range1Max / 2);
const int32_t range2Min = 0;
const int32_t range2Max = numeric_limits<int32_t>::max() / 2;
const int32_t range3Min = range2Max + (range2Max / 2);
const int32_t range3Max = numeric_limits<int32_t>::max();
int32_t ranges[][2] = {
{ range1Min, range1Max},
{ range2Min, range2Max},
{ range3Min, range3Max}
};
auto_ptr<AE> ae(new HR(1, ranges, 3));
Json::Value json = ae->serializeValue();
Json::FastWriter writer;
std::string jsonText = writer.write(json);
PlannerDomRoot domRoot(jsonText.c_str());
auto_ptr<AbstractExpression> e1(AbstractExpression::buildExpressionTree(domRoot.rootObject()));
vector<std::string> columnNames;
columnNames.push_back("foo");
columnNames.push_back("bar");
vector<int32_t> columnSizes;
columnSizes.push_back(8);
columnSizes.push_back(4);
vector<bool> allowNull;
allowNull.push_back(true);
allowNull.push_back(false);
vector<voltdb::ValueType> types;
types.push_back(voltdb::VALUE_TYPE_BIGINT);
types.push_back(voltdb::VALUE_TYPE_INTEGER);
TupleSchema *schema = TupleSchema::createTupleSchemaForTest(types,columnSizes,allowNull);
boost::scoped_array<char> tupleStorage(new char[schema->tupleLength() + TUPLE_HEADER_SIZE]);
TableTuple t(tupleStorage.get(), schema);
const time_t seed = time(NULL);
std::cout << "Seed " << seed << std::endl;
srand(static_cast<unsigned int>(seed));
for (int ii = 0; ii < 100000; ii++) {
NValue val = ValueFactory::getIntegerValue(rand());
const int32_t hash = val.murmurHash3();
t.setNValue(1, val);
NValue inrange = e1->eval( &t );
if ((hash >= range1Min && hash <= range1Max) ||
(hash >= range2Min && hash <= range2Max) ||
(hash >= range3Min && hash <= range3Max)) {
//We no longer allow wrapping so this condition isn't true
//(hash >= range3Min || hash < range3Max)) {
ASSERT_TRUE(inrange.isTrue());
} else {
ASSERT_FALSE(inrange.isTrue());
}
}
TupleSchema::freeTupleSchema(schema);
}