views:

65

answers:

4

I overheard this at a coffee table conversation and i wasnt able to fathom what this was about. A bit of googling didnt throwup anything useful...

Clarification: Thanks guys for the initial take on it... but it appeared that the conversation was about "searching" through databses / internet, etc....

+1  A: 

If they were talking about .NET then they were referring to the Predicate type required by many extension methods of collections.

It is a delegate which represents the method that defines a set of criteria and determines whether the specified object meets those criteria.

I'm not sure if other platforms use this terminology.

//selects items in list where the `ID` property matches `id`
List.Select(x => x.ID == id); 
David Neale
+1  A: 

I don't know if the term as a whole has any particular meaning, but in a broader sense a "predicate" is a function that takes an entity (i.e. some kind of candidate object) as input, and returns a boolean indicating whether the predicate condition was met.

Expanding from this, one might conclude that a predicate-based search is one that searches based on predicates - what one might call a filter. For example, you could build a search by ANDing two simple predicates together, say IsUppercaseString and StringStartsWith("S")* to search for uppercase strings starting with S.

  • Note that this is pseudocode not any specific syntax as I'm keeping this language-agnostic
Andrzej Doyle
+5  A: 

In general, a predicate is a function that takes one or more arguments, and returns a boolean value, indicating whether some statement about the arguments is true or false.

Examples of natural-language predicates might be "is blue", "is longer than two metres", "is owned by MC Hammer", "is underground".

When executing a search on some system - eg a file system, a database table, a graph - it might be that the system itself provides certain built-in searches (a file system might have a built-in search by filename; a graph might have a built-in search by distance from a given node); or, for more flexibility, there might be a way to search by providing a custom predicate function.

Depending on details, this custom predicate function could be passed as an expression tree, or a pointer to some actual executable code, or a query expression to be parsed. All that is required is that the system has some way to invoke the predicate on each candidate item; and that the predicate returns true or false for each candidate item.

The results of the search are then precisely those items for which the custom predicate returns true.

AakashM
Thanks AakashM for your detailed answer - it was quite explanatory, but i dont think it "fit" in with what i was trying to understand... nevertheless, thanks again!
Dave
+1  A: 

In the cqse of widely distributed databases with shards all over the place, the traditional searching patterns using indexes and so on breaks down. For these databases often a map-reduce operation is performed. The mapping is implicitely determined by the sharding and the predicate you pass which maps the records matching the predicate to whatever is needed at the result. In the reduce step the necessary aggregation et al are done.

Maybe this fits with the context of the coffee table discussion?

Peter Tillemans
Hi Peter! That does seem to make sense - there were discussion about database/searches etc! Thanks for your help - I feel a lot less dumber now! ;)
Dave