本文整理汇总了C++中Tuple::getField方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::getField方法的具体用法?C++ Tuple::getField怎么用?C++ Tuple::getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::getField方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isJoinTuple
//To check whether the tuple is valid for a Natural Join
bool isJoinTuple(Tuple t1, Tuple t2, vector<string> fields1, vector<string> fields2, vector<string> op)
{
if(op.size() == 0)
return true;
else for(int i=0; i<op.size(); i++)
{
//cout<<"Operator: "<<op[i]<<" "<<fields2[i]<<endl;
if(op[i] == "=")
{
if(t1.getSchema().getFieldType(fields1[i]) == INT && (t1.getField(fields1[i]).integer == t2.getField(fields2[i]).integer))
continue;
else if(t1.getSchema().getFieldType(fields1[i]) == STR20 && (*(t1.getField(fields1[i]).str) == *(t2.getField(fields2[i]).str)))
continue;
else return false;
}
else if(op[i] == ">")
{
if(t1.getSchema().getFieldType(fields1[i]) == INT && (t1.getField(fields1[i]).integer > t2.getField(fields2[i]).integer))
continue;
else return false;
}
else if(op[i] == "<")
{
if(t1.getSchema().getFieldType(fields1[i]) == INT && (t1.getField(fields1[i]).integer < t2.getField(fields2[0]).integer))
continue;
else return false;
}
else return false;
}
return true;
}
示例2: IsEqual
//Compare two tuples
//Return true if equals else returns false
bool IsEqual(Tuple t1, Tuple t2)
{
if(t1.isNull() || t2.isNull()) return false;
Schema st1 = t1.getSchema();
Schema st2 = t2.getSchema();
if(st1!=st2) return false;
vector<string> fieldNames = st1.getFieldNames();
vector<string>::iterator iter;
for(iter = fieldNames.begin(); iter!=fieldNames.end(); iter++)
{
if(st1.getFieldType(*iter) == INT)
{
if(t1.getField(*iter).integer != t2.getField(*iter).integer)
return false;
}
else
{
string val1 = *(t1.getField(*iter).str);
string val2 = *(t2.getField(*iter).str);
if(val1 != val2)
return false;
}
}
return true;
}
示例3: IsEqualTuples
bool IsEqualTuples(Tuple tup1, Tuple tup2)
{
if(tup1.isNull() || tup2.isNull()) return false;
Schema schemat1 = tup1.getSchema();
Schema schemat2 = tup2.getSchema();
if(schemat1!=schemat2) return false;
vector<string> field_names = schemat1.getFieldNames();
vector<string>::iterator myiterator;
for(myiterator = field_names.begin(); myiterator!=field_names.end(); myiterator++)
{
if(schemat1.getFieldType(*myiterator) == INT)
{
if(tup1.getField(*myiterator).integer != tup2.getField(*myiterator).integer)
return false;
}
else
{
string val1 = *(tup1.getField(*myiterator).str);
string val2 = *(tup2.getField(*myiterator).str);
if(val1 != val2)
return false;
}
}
return true;
}
示例4: 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;
}
示例5: 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;
}
示例6: operator
bool Tuple_Comparison::operator()(Tuple& tuple1, Tuple& tuple2)
{
if(tuple1.isNull() && tuple2.isNull())
return false;
if((!tuple1.isNull()) && tuple2.isNull())
return true;
if(tuple1.isNull() && (!tuple2.isNull()))
return false;
vector<string>::iterator start = field_names.begin();
vector<string>::iterator stop = field_names.end();
vector<string>::iterator index;
Schema schema_tuple1 = tuple1.getSchema();
Schema schema_tuple2 = tuple2.getSchema();
// cout<< "comparing "<<tuple1<<" "<<tuple2<<endl;
if(schema_tuple1 != schema_tuple2)
throw string("Error!! Tuple comparison failed - Tuple_Comparison::operator()");
for(index = start; index!=stop; index++)
{
string column_name = *index;
FIELD_TYPE field_type = schema_tuple1.getFieldType(column_name);
if(field_type == INT)
{
int value1, value2;
value1 = tuple1.getField(column_name).integer;
value2 = tuple2.getField(column_name).integer;
if(value1 != value2)
return value1<value2;
}
else //FIELD_TYPE == STR20
{
string value1, value2;
value1 = *(tuple1.getField(column_name).str);
value2 = *(tuple2.getField(column_name).str);
if(value1.compare(value2) < 0) return true;
else if(value1.compare(value2) > 0) return false;
}
}
return false;
}
示例7: getColumnValues
string getColumnValues(string expression, Tuple tuple) {
stringstream ss(expression);
char c;
string internal;
string str;
while(ss.get(c)) {
if(c=='(' || c==')' || c=='*' || c=='/' || c=='+' || c=='-' || isdigit(c) || c==' ') {
if(!str.empty())
internal.append(to_string(tuple.getField(str).integer));
internal.push_back(c);
str = "";
}
else
str.push_back(c);
}
if(!str.empty()) internal.append(to_string(tuple.getField(str).integer));
return internal;
}
示例8: operator
bool CompareTuple::operator()(Tuple& first, Tuple& second)
{
if(first.isNull() && second.isNull())
return false;
if((!first.isNull()) && second.isNull())
return true;
if(first.isNull() && (!second.isNull()))
return false;
vector<string>::iterator beg = fieldNames.begin();
vector<string>::iterator end = fieldNames.end();
vector<string>::iterator i;
Schema tupleSchemaOne = first.getSchema();
Schema tupleSchemaTwo = second.getSchema();
// cout<< "comparing "<<first<<" "<<second<<endl;
if(tupleSchemaOne != tupleSchemaTwo)
throw string("Tuple Schema Comparision Error!!!! - In PUtility::ComapreTuple::Opeartor()");
for(i = beg; i!=end; i++)
{
string colName = *i;
FIELD_TYPE ftype = tupleSchemaOne.getFieldType(colName);
if(ftype == INT)
{
int firstVal, secVal;
firstVal = first.getField(colName).integer;
secVal = second.getField(colName).integer;
if(firstVal != secVal)
return firstVal<secVal;
}
else //FIELD_TYPE == STR20
{
string firstVal, secVal;
firstVal = *(first.getField(colName).str);
secVal = *(second.getField(colName).str);
if(firstVal.compare(secVal) < 0) return true;
else if(firstVal.compare(secVal) > 0) return false;
//else == 0, continue comparing next tuple
}
}
return false;
}
示例9: Mapping_Tuple
void Mapping_Tuple(Tuple map_tuple, string table_name)
{
Schema schema_tuple = map_tuple.getSchema();
vector<string> map_column_names = schema_tuple.getFieldNames();
vector<string>::iterator myiterator;
for(myiterator = map_column_names.begin(); myiterator!=map_column_names.end(); myiterator++)
{
FIELD_TYPE field_typ = schema_tuple.getFieldType(*myiterator);
Field value = map_tuple.getField(*myiterator);
TColPair tcolpair1 = TColPair(table_name, *myiterator);
TColPair tcolpair2 = TColPair(NOT_A_TABLE, *myiterator);
FValue values = FValue(field_typ, value);
Column_Value_Mapping[tcolpair1] = values;
Column_Value_Mapping[tcolpair2] = values;
}
}
示例10: MapTupleValues
void MapTupleValues(Tuple t, string tableName)
{
Schema tupleSchema = t.getSchema();
vector<string> columnNames = tupleSchema.getFieldNames();
vector<string>::iterator iter;
for(iter = columnNames.begin(); iter!=columnNames.end(); iter++)
{
FIELD_TYPE ft = tupleSchema.getFieldType(*iter);
Field value = t.getField(*iter);
TableColumnPair tcpair = TableColumnPair(tableName, *iter);
TableColumnPair tcpair2 = TableColumnPair(NO_TABLE, *iter);
Value val = Value(ft, value);
ColumnValueMap[tcpair] = val;
ColumnValueMap[tcpair2] = val;
}
}
示例11: 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);
}
}
示例12: conditionMatches
int conditionMatches(Tuple tuple, vector<string> tokens, int op) {
Schema schema = tuple.getSchema();
bool flag1=false, flag2=false;
if(ifExists(tokens[1], "\\+|\\/|\\-|\\/|\\(|\\)|\\*") || ifExists(tokens[0], "\\+|\\/|\\-|\\/|\\(|\\)|\\*")) {
return eval(tuple, tokens, op);
}
for(int i=0;i<schema.getNumOfFields();i++) {
if(schema.getFieldName(i) == tokens[0])
flag1=true;
if(schema.getFieldName(i) == tokens[1])
flag2=true;
}
if(flag1 && flag2) {
if(tuple.getSchema().getFieldType(tokens[0]) == INT) {
switch(op) {
case 0:
if(tuple.getField(tokens[0]).integer == tuple.getField(tokens[1]).integer)
return 0;
else return 1;
case 1:
if(tuple.getField(tokens[0]).integer > tuple.getField(tokens[1]).integer)
return 0;
else return 1;
case 2:
if(tuple.getField(tokens[0]).integer < tuple.getField(tokens[1]).integer)
return 0;
else return 1;
}
}
else {
if(*(tuple.getField(tokens[1]).str) == *(tuple.getField(tokens[1]).str)) return 0;
else return 1;
}
}
if(flag1)
{
if(tuple.getSchema().getFieldType(tokens[0]) == INT) {
int fieldValue = tuple.getField(tokens[0]).integer;
if(isNumber(tokens[1])){
switch (op) {
case 0:
if(fieldValue == stoi(tokens[1]))
return 0;
else
return 1;
case 1:
if(fieldValue > stoi(tokens[1]))
return 0;
else
return 1;
case 2:
if(fieldValue < stoi(tokens[1]))
return 0;
else
return 1;
}
}
}
else {
regex exp("\\ *\"(.*)\"");
cmatch match;
if(regex_match(tokens[1].c_str(),match,exp))
{
string* fieldValue = tuple.getField(tokens[0]).str;
if(*fieldValue == match[1])
return 0;
else
return 1;
}
}
}
return 0;
}