本文整理汇总了C++中Tuple::getNumOfFields方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::getNumOfFields方法的具体用法?C++ Tuple::getNumOfFields怎么用?C++ Tuple::getNumOfFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::getNumOfFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: join
void join(Tuple tuple1, Tuple tuple2, string tableName1, string tableName2, string whereCondition, bool multi, vector<string> attributes) {
Relation *relation = schemaManager.getRelation(tableName2+"_join");
Tuple tuple =relation->createTuple();
if(!multi) {
for(int i=0;i<tuple1.getNumOfFields();i++) {
if(tuple1.getSchema().getFieldType(i) == INT)
tuple.setField(tableName1+"."+tuple1.getSchema().getFieldName(i), tuple1.getField(i).integer);
else
tuple.setField(tableName1+"."+tuple1.getSchema().getFieldName(i), *(tuple1.getField(i).str) );
}
}
else {
for(int i=0;i<tuple1.getNumOfFields();i++) {
if(tuple1.getSchema().getFieldType(i) == INT)
tuple.setField(tuple1.getSchema().getFieldName(i), tuple1.getField(i).integer);
else
tuple.setField(tuple1.getSchema().getFieldName(i), *(tuple1.getField(i).str) );
}
}
for(int i=0;i<tuple2.getNumOfFields();i++) {
if(tuple2.getSchema().getFieldType(i) == INT)
tuple.setField(tableName2+"."+tuple2.getSchema().getFieldName(i), tuple2.getField(i).integer);
else
tuple.setField(tableName2+"."+tuple2.getSchema().getFieldName(i), *(tuple2.getField(i).str) );
}
if((attributes.size()==1 && attributes[0]=="*") || multi) {
if(whereConditionEvaluator(whereCondition, tuple))
insertTuple(tableName2+"_join", tuple);
}
else {
Relation *relation1 = schemaManager.getRelation(tableName2+"_joinp");
Tuple tuplep = relation1->createTuple();
for(int i=0;i<attributes.size();i++) {
if(tuplep.getSchema().getFieldType(attributes[i]) == INT)
tuplep.setField(attributes[i], tuple.getField(attributes[i]).integer);
else
tuplep.setField(attributes[i], *(tuple.getField(attributes[i]).str));
}
if(whereConditionEvaluator(whereCondition, tuple))
insertTuple(tableName2+"_joinp", tuplep);
}
}
示例2: compare
bool compare(Tuple tuple1, Tuple tuple2) {
Schema tupleSchema = tuple1.getSchema();
for(int i=0;i<tuple1.getNumOfFields();i++) {
if(tupleSchema.getFieldType(i) == INT) {
if(tuple1.getField(i).integer != tuple2.getField(i).integer)
return false;
}
else {
if(*(tuple1.getField(i).str) != *(tuple2.getField(i).str))
return false;
}
}
return true;
}
示例3: printTuple
void printTuple(Tuple tuple){
// Print the information about the tuple
cout << "Created a tuple " << tuple << " through the relation" << endl;
cout << "The tuple is invalid? " << (tuple.isNull()?"TRUE":"FALSE") << endl;
Schema tuple_schema = tuple.getSchema();
cout << "The tuple has schema" << endl;
cout << tuple_schema << endl;
cout << "A block can allow at most " << tuple.getTuplesPerBlock() << " such tuples" << endl;
cout << "The tuple has fields: " << endl;
for (int i=0; i<tuple.getNumOfFields(); i++) {
if (tuple_schema.getFieldType(i)==INT)
cout << tuple.getField(i).integer << "\t";
else
cout << *(tuple.getField(i).str) << "\t";
}
cout << endl << endl;
}