Support for secondary indexes & Meta Data#17
Merged
kevburnsjr merged 3 commits intobasho:masterfrom Nov 25, 2011
Merged
Conversation
kevburnsjr
added a commit
that referenced
this pull request
Nov 25, 2011
Support for secondary indexes & Meta Data
Contributor
|
Wicked awesome. Testing looks very thorough. Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch includes support for the following:
Auto Indexes
The notion of 'auto indexes' in this patch may be controversial. We have many hands in various pots here, and several different applications and application layers touching the same objects. A concern for us is that two applications which work against the same data store might not adequately keep each other's indexes up to date. The majority of the time our indexes are a convenient way to search out a piece of data found inside the object, and the two ought to be bound together.
That's not to say that loosely coupled indexes are without value - they certainly are. So this patch includes support for traditional indexes, plus an alternate API for auto indexes.
As an example, imagine we have a CRM system, an eCommerce system, and a customer-accessible API. All three read and modify customer records. The customer may change their shipping address from the website, or an employee might do so through CRM, or the customer's own management system might do so through the API. Let's say CRM decides they want a secondary index on ZIP code, so they add this. With a traditional index, the website and API now also need to be updated to keep this index fresh, while with an auto index, the website will notice this is an auto index and keep it fresh without a code change.
Documentation
Meta Data
You can provide meta data on objects using RiakObject::getMeta() and RiakObject::setMeta()
Remove existing metadata
Adding Secondary Indexes
Secondary indexes can be added using the RiakObject::addIndex() and RiakObject::addAutoIndex() methods.
Auto indexes are kept fresh with the associated field automatically, so if you read an object, modify its data, and write it back, the auto index will reflect the new value from the object. Traditional indexes are fixed and must be manually managed. NOTE that auto indexes are a function of the Riak PHP client, and are not part of native Riak functionality. Other clients writing the same object must manage the index manually.
You can remove a specific value from an index, all values from an index, or all indexes:
Likewise you can remove auto indexes:
Mass load indexes, or just replace an existing index:
Querying Secondary Indexes
Secondary indexes can be queried using the RiakBucket::indexSearch() method. This returns an array of RiakLink objects.
Duplicate entries may be found in a ranged index search if a given index has multiple values that fall within the range. You can request that these duplicates be eliminated in the result.