Esempio n. 1
0
bool
ClassAdBooleanIndex::FilterAll( KeySet &result )
{
	IndexEntries::iterator	itr;

	for( itr = nope.begin( ); itr != nope.end( ) ; itr++ ) {
		result.Insert( *itr );
	}
	for( itr = yup.begin( ); itr != yup.end( ); itr++ ) {
		result.Insert( *itr );
	}
	return( true );
}
Esempio n. 2
0
bool
ClassAdBooleanIndex::Filter( const Interval &interval, KeySet &result )
{
	bool	ol, l, ou, u;
	bool	qf, qt;

		// figure out which index "entries" to query
	ol = interval.openLower;
	interval.lower.IsBooleanValue( l );
	interval.upper.IsBooleanValue( u );
	ou = interval.openUpper;
	if( !ol && !l ) {
		if( !u && !ou ) {
			qf = true;
		} else if( u && !ou ) {
			qf = qt = true;
		} else if( u && ou ) {
			qf = true;
		} 
	} else if( u && !ou ) {
		if( ol ^ l ) {
			qt = true;
		} 
	}
			
	if( !qt && !qf ) return( true );

		// do the queries
	IndexEntries::iterator	itr;
	if( qf ) {
		for( itr = nope.begin( ); itr != nope.end( ); itr++ ) {
			result.Insert( *itr );
		}
	}
	if( qt ) {
		for( itr = yup.begin( ); itr != yup.end( ); itr++ ) {
			result.Insert( *itr );
		}
	}	

	return( true );
}
Esempio n. 3
0
bool
ClassAdStringIndex::Filter( const Interval &interval, KeySet &result )
{
	string					str;
	StringIndex::iterator	bitr, eitr;
	IndexEntries::iterator	nitr;

		// figure out iterator position for lower end of interval
	if( !interval.lower.IsStringValue( str ) ) {
		bitr = stringIndex.begin( );
	} else if( interval.openLower ) {
		bitr = stringIndex.upper_bound( str );
	} else {
		bitr = stringIndex.lower_bound( str );
	}

		// figure out iterator position for upper end of interval
	if( !interval.upper.IsStringValue( str ) ) {
		eitr = stringIndex.end( );
	} else {
		if( ( eitr = stringIndex.find( str ) ) != stringIndex.end( ) ) {
			if( !interval.openUpper ) {
				eitr++;
			}
		} else {
			eitr = stringIndex.upper_bound( str );
		}
	}

		// sweep from lower position to upper position
	for(; bitr != eitr; bitr++ ) {
			// get all keys stored in the these entries
		for( nitr=bitr->second.begin( ); nitr!=bitr->second.end( ); nitr++ ) {
			result.Insert( *nitr );
		}
	}

	return( true );
}