当前位置: 首页>>代码示例>>C++>>正文


C++ Relation::addRow方法代码示例

本文整理汇总了C++中Relation::addRow方法的典型用法代码示例。如果您正苦于以下问题:C++ Relation::addRow方法的具体用法?C++ Relation::addRow怎么用?C++ Relation::addRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Relation的用法示例。


在下文中一共展示了Relation::addRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: naturalJoin


//.........这里部分代码省略.........

		for ( unsigned j = 0; j < attA.size( ); j++ ){
			if ( attB.at( i ) == attA.at( j ) ){
				found = true;
			}
		}

		if ( !found ){
			indexBOnly.push_back( i );
		}

	}

	
	//Set up the result attributes
	vector<Attribute> rA;
	for ( unsigned i = 0; i < indexAOnly.size( ); i++ ){
		rA.push_back( attA.at( indexAOnly.at( i ) ) );
	}

	for ( unsigned i = 0; i < jointAttributes.size( ); i++ ){
		rA.push_back( jointAttributes.at( i ) );
	}

	for ( unsigned i = 0; i < indexBOnly.size( ); i++ ){
		rA.push_back( attB.at( indexBOnly.at( i ) ) );
	}

	myResult.setAttributes( rA );

	//Compose this as three relations side by side
	vector<Relation> aOnly;
	vector<Relation> bOnly;
	vector<Relation> shared;

	
	//Push values into aOnly using our indexes
	for ( unsigned i = 0; i < indexAOnly.size( ); i++ ){
		vector<string> att;
		att.push_back( relationA->getAttributeAt( indexAOnly.at( i ) ).name );

		aOnly.push_back( projection( att, relationA ) );

	}

	//Push values into joint using our indexes
	for ( unsigned i = 0; i < indexInA.size( ); i++ ){
		vector<string> att;
		att.push_back( relationA->getAttributeAt( indexInA.at( i ) ).name );

		shared.push_back( projection( att, relationA ) );

	}

	//Push values into bOnly using our indexes
	for ( unsigned i = 0; i < indexBOnly.size( ); i++ ){
		vector<string> att;
		att.push_back( relationB->getAttributeAt( indexBOnly.at( i ) ).name );

		bOnly.push_back( projection( att, relationB ) );

	}

	int numRows = relationA->getNumTuples( );

	
	//This for loop consturcts a tuple based on the three preceding relatinos. We add
	//a helper function which maps a row in a to a row in b since they may be in a different order
	for ( int i = 0; i < numRows; i++ ){

		vector<Entry*> newRow;

		for ( unsigned j = 0; j < aOnly.size( ); j++ ){

			newRow.push_back( aOnly.at( j ).getEntry( i, 0 ) );

		}

		for ( unsigned j = 0; j < shared.size( ); j++ ){

			newRow.push_back( shared.at( j ).getEntry( i, 0 ) );

		}

		int row = findCorrespondingRow( relationA->getRow( i ), indexInA, relationB, indexInB );

		for ( unsigned j = 0; j < bOnly.size( ); j++ ){

			newRow.push_back( bOnly.at( j ).getEntry( row, 0 ) );

		}

		myResult.addRow( newRow );

	}

	result = myResult;

	return result;
}
开发者ID:njchristian,项目名称:315_RDBMS,代码行数:101,代码来源:Database.cpp


注:本文中的Relation::addRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。