コード例 #1
0
ファイル: queryProcessor.cpp プロジェクト: AlainRoy/htcondor
void QueryProcessor::
DumpQState( QueryOutcome &qo )
{
	QueryOutcome::iterator	qitr;
	KeySet::iterator		kitr;
	int						elt;

	printf( "\tResult:\n" );
	for( qitr=qo.begin( ); qitr!=qo.end( ); qitr++ ) {
		printf( "\t  %d: " , qitr->first );
		kitr.Initialize(qitr->second);
		while( kitr.Next(elt) ) {
			printf( "%d ", elt );
		}
		printf( "\n" );
	}
}
コード例 #2
0
ファイル: plugin.cpp プロジェクト: strahlex/libelektra
kdb::KeySet Plugin::getNeededConfig()
{
	Key neededConfigKey ("system/elektra/modules", KEY_END);
	neededConfigKey.addName(pluginName);
	neededConfigKey.addName("config/needs");

	KeySet d (info.dup());
	KeySet config = d.cut(neededConfigKey);

	KeySet ret;
	Key oldParent = neededConfigKey;
	Key newParent("system", KEY_END);
	for (KeySet::iterator i = config.begin(); i != config.end(); ++i)
	{
		Key k(i->dup());
		ret.append(kdb::tools::helper::rebaseKey(k, oldParent, newParent));
	}
	return ret;
}
コード例 #3
0
ファイル: testcpp_iter.cpp プロジェクト: tryge/libelektra
TEST(test_iter, const_iterator)
{
	std::cout << "test const iterator" << std::endl;
	const KeySet ks4 (5,
		*Key ("user/key4/1", KEY_END),
		*Key ("user/key4/2", KEY_END),
		*Key ("user/key4/3", KEY_VALUE, "value", KEY_END),
		KS_END);

	KeySet::iterator it = ks4.begin();
	ASSERT_EQ(it->getName() ,  "user/key4/1"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/1"    ) <<  "name wrong";
	it+=1;
	ASSERT_EQ(it->getName() ,  "user/key4/2"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/2"    ) <<  "name wrong";
	it+=1;
	ASSERT_EQ(it->getName() ,  "user/key4/3"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/3"    ) <<  "name wrong";
	it+=1;
	ASSERT_EQ(it ,  ks4.end()    ) <<  "not at end";
	it-=1;
	ASSERT_EQ(it->getName() ,  "user/key4/3"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/3"    ) <<  "name wrong";
	it-=1;
	ASSERT_EQ(it->getName() ,  "user/key4/2"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/2"    ) <<  "name wrong";
	it-=1;
	ASSERT_EQ(it->getName() ,  "user/key4/1"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/1"    ) <<  "name wrong";
	ASSERT_EQ(it ,  ks4.begin()    ) <<  "not at begin";



	ASSERT_EQ(it->getName() ,  "user/key4/1"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/1"    ) <<  "name wrong";
	it++;
	ASSERT_EQ(it->getName() ,  "user/key4/2"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/2"    ) <<  "name wrong";
	it++;
	ASSERT_EQ(it->getName() ,  "user/key4/3"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/3"    ) <<  "name wrong";
	it++;
	ASSERT_EQ(it ,  ks4.end()    ) <<  "not at end";
	it--;
	ASSERT_EQ(it->getName() ,  "user/key4/3"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/3"    ) <<  "name wrong";
	it--;
	ASSERT_EQ(it->getName() ,  "user/key4/2"    ) <<  "name wrong";
	ASSERT_EQ((*it).getName() ,  "user/key4/2"    ) <<  "name wrong";
	it--;
}
コード例 #4
0
ファイル: queryProcessor.cpp プロジェクト: AlainRoy/htcondor
bool QueryProcessor::
DoQuery( Rectangles &window, KeySet &result )
{
	AllDimensions::iterator		aitr;
	OneDimension::iterator		oitr;
	Indexes::iterator			iitr;
	KeySet						deviantExportedSet;
	KeySet						tmpResult;
	QueryOutcome				qo;
	string						demangled;
	DimRectangleMap::iterator	ditr, daxitr;
	KeySet::iterator			ksitr;
	int							tmp;
	Rectangles					*rec = summarize ? &summaries : rectangles;

	numQueries++;

	//printf( "Doing query\n" );
		// Phase 0: Initialize 
	for( int i = 0; i <= window.rId ; i++ ) {
		qo[i].MakeUniversal( );
	}

		// Phase 1:  Process imported intervals
	for( aitr=window.importedBoxes.begin( ); aitr!=window.importedBoxes.end( );
			aitr++ ) {

		demangled.assign( aitr->first, 2, aitr->first.size( ) - 2 );
		ditr = rec->unexported.find( demangled );

		for( oitr=aitr->second.begin( ); oitr!=aitr->second.end( ); oitr++ ) {
			tmpResult.Clear( );
				// include all rectangles whose constraints are satisfied
			if( ( iitr = exported.find( aitr->first ) ) != exported.end( ) ) {
				if( !iitr->second->Filter( oitr->second, tmpResult ) ) {
					printf( "Failed exported index lookup\n" );
					return( false );
				}
			}

				// include deviant exported rectangles and all rectangles
				// which do not constrain this attribute (if any)
			if( ditr == rec->unexported.end( ) ) {
				qo[oitr->first].IntersectWithUnionOf( tmpResult, 
					rec->deviantExported );
			} else {
				qo[oitr->first].IntersectWithUnionOf( tmpResult, ditr->second,
					rec->deviantExported );
			}
		}
	}

		// Phase 2:  Remove candidates which constrain absent attributes
	for(ditr=window.unimported.begin();ditr!=window.unimported.end();ditr++) {
			// find all rectangles which constrain this particular attribute
		daxitr = rec->allExported.find( ditr->first );
		if( daxitr == rec->allExported.end( ) ) continue;
			// remove this set from the solution for each query rectangle
		ksitr.Initialize( ditr->second );
		while( ksitr.Next( tmp ) ) {
			qo[tmp].Subtract( daxitr->second );
		}
	}

		// Phase 3:  Process exported dimensions
	for( aitr=window.exportedBoxes.begin( ); aitr!=window.exportedBoxes.end( );
			aitr++ ) {
			// need to include rectangles which are deviant on this attribute
		demangled.assign( aitr->first, 2, aitr->first.size( ) - 2 );
		ditr = rec->deviantImported.find( demangled );

		for( oitr=aitr->second.begin( ); oitr!=aitr->second.end( ); oitr++ ) {
			tmpResult.Clear( );
				// include all rectangles which satisfy this constraint
			if( ( iitr = imported.find( aitr->first ) ) != imported.end( ) ) {
				if( !iitr->second->Filter( oitr->second, tmpResult ) ) {
					printf( "Failed imported index lookup\n" );
					return( false );
				}
			}
				// check if there are relevant deviant imported rectangles
			if( ditr == rec->deviantImported.end( ) ) {
					// ... if not, just intersect with filtered results
				qo[oitr->first].Intersect( tmpResult );
			} else {
					// ... otherwise, include deviant imported rectangles
				qo[oitr->first].IntersectWithUnionOf(ditr->second,tmpResult);
			}
		}
	}

		// Phase 4:  Aggregate results for all query rectangles
	result.Clear( );
	for( int i = 0 ; i <= window.rId ; i++ ) {
		result.Unify( qo[i] );
	}

		// done
	return( true );
}
コード例 #5
0
ファイル: backend.cpp プロジェクト: fberlakovich/libelektra
/**
 * @pre name and mountpoint set
 * Add plugin serialization into keyset ret.
 *
 * Only can be done once!
 * (see firstRef in Plugin)
 * */
void Backend::serialize (kdb::KeySet & ret)
{
	assert (!mp.empty ());
	Key backendRootKey (Backends::mountpointsPath, KEY_END);
	backendRootKey.addBaseName (mp);
	backendRootKey.setString ("This is a configuration for a backend, see subkeys for more information");
	ret.append (backendRootKey);


	if (mp == "/")
	{
		ret.append (*Key (backendRootKey.getName () + "/mountpoint", KEY_VALUE, "/", KEY_COMMENT,
				  "The mountpoint says the location where the backend should be mounted.\n"
				  "This is the root mountpoint.\n",
				  KEY_END));
	}
	else if (mp.at (0) == '/')
	{
		Key k ("system" + mp, KEY_END);
		Key restrictedPath ("system/elektra", KEY_END);
		if (!k) throw MountpointInvalidException ();
		if (restrictedPath.isBelow (k)) throw MountpointInvalidException ();
		ret.append (*Key (backendRootKey.getName () + "/mountpoint", KEY_VALUE, mp.c_str (), KEY_COMMENT,
				  "The mountpoint says the location where the backend should be mounted.\n"
				  "This is a cascading mountpoint.\n"
				  "That means it is both mounted to dir, user and system.",
				  KEY_END));
	}
	else
	{
		Key k (mp, KEY_END);
		Key restrictedPath ("system/elektra", KEY_END);
		if (!k) throw MountpointInvalidException ();
		if (restrictedPath.isBelow (k)) throw MountpointInvalidException ();
		ret.append (*Key (backendRootKey.getName () + "/mountpoint", KEY_VALUE, mp.c_str (), KEY_COMMENT,
				  "The mountpoint says the location where the backend should be mounted.\n"
				  "This is a normal mountpoint.\n",
				  KEY_END));
	}

	const string configBasePath = Backends::getBasePath (mp) + "/config";
	ret.append (Key (configBasePath, KEY_END));

	config.rewind ();
	Key common = config.next ();
	Key oldParent ("system", KEY_END);
	Key newParent (configBasePath, KEY_END);

	for (KeySet::iterator i = config.begin (); i != config.end (); ++i)
	{
		Key k (i->dup ());
		ret.append (kdb::tools::helper::rebaseKey (k, oldParent, newParent));
	}


	errorplugins.serialise (backendRootKey, ret);
	getplugins.serialise (backendRootKey, ret);
	setplugins.serialise (backendRootKey, ret);

	ret.append (*Key (backendRootKey.getName () + "/config/path", KEY_VALUE, configFile.c_str (), KEY_COMMENT,
			  "The path for this backend. Note that plugins can override that with more specific configuration.", KEY_END));
}