talis/tripod-php — pull request #9 by robotrobot (2014-06-20 07:46:43+00:00)
Title: Adding count and regex to tablespec - 30%

Views can contain a `count` with `filter`. When they do, they must also have a `ttl` (time to live) property which tells tripod the maximum age of the view before it is regenerated. Such views do not rely on the `impactIndex` to detect changes because due to the join-y nature of the filter it is possible to change data conditions referenced by a filter downstream of the view which will affect the count.

Time to live invalidation is fine for views because they only span one document, it is easy to regenerate a single view in the foreground on read if it is found to exceed it's time to live.

We also want the count functionality for tables. However, we must be more careful. Table rows can span 1000's or more documents. A `ttl` here is not a good strategy - tables are read out in pages and we cannot know without reading the whole set whether there is stale data. This would also make it impossible to output a page header in the result set that contains a total count.

So we must implement `count` function for tables that does not require a `ttl`. This means the `filter` conditions for tables must be more restrictive and cannot possibly filter data that cannot be detected by the `impactIndex`.