We have done similar things, but it always depends on the available
tools, your requirements and needs, I will give you a short example, our
main application uses a standard SQL, for historical data we use Riak,
data that is not changing, for example, audit trails, daily chunks from
different sources and so on.
We make sure our data is 100% JSON compatible, and our tools are the
available JSON libraries, it is fair easy to add new "columns" to your
data (I know, columns right?), and keep your fetching still valid by
ignoring deprecated properties and when writing back just overwriting
old data, that way, your schema can change all the time without losing
old data and evolving at the same time.
2i is fine to stamp and migrate if you wish, since it makes your code
tedious if you need to be checking for nulls all the time, so for
migration you can simply use JSON transformers, from this property to
another (from old to new schema) without even coding, but it will be up
to your tools.
In Java for example all that can be aid with Jackson which happens to be
the defacto JSON Riak Java client provider, here is a list of few
annotations to accomplish most of the things are you worried about:
*@JsonIgnoreProperties(ignoreUnknown=true)* (Say an old property just
got deprecated and you want your POJO not to throw exceptions while
converting from JSON to your POJO)
*@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)* (Saves lot of
space)
@Override
*@JsonProperty("ranges")* (Say, a property just changed its type, and
because of that, I need to map it to a new property, in this case, I
don't have a list of integers anymore but a list of ranges, so a
transformation is required...)
public List<Integer[]> getEntries()
{
return intRangeCollection.getRangesAsArray();
}
*@JsonProperty("ranges")*
public void setEntries(final List<Integer[]> entries)
{
this.intRangeCollection=IntRangeCollection.buildIntRangesCollectionFromArrays(entries);
}
Well, there is so much I could show you, but, examples are limitless, so
depending on your use cases, you will figure your own ways to keep your
code kind of clean and your schema changing constantly.
Hope that helps,
Guido.
On 19/09/12 16:08, Pinney Colton wrote:
Wow, that's a pretty big question.
IMO, it depends upon what you're doing with your data. Personally,
I'm storing up to 4 different "versions" of the same data in Riak,
each version is optimized for different types of analytical operations.
That's probably not ideal for everybody. Heck, storing 4 copies of my
data isn't even optimal for me from a storage perspective - but it
does help optimize performance of different queries. I care more
about that than disk or memory.
On Tue, Sep 18, 2012 at 5:55 PM, Allen Johnson <akjohnso...@gmail.com
<mailto:akjohnso...@gmail.com>> wrote:
Hey everyone,
I'm beginning to experiment with Riak and I'm trying to better
understand how to model my data. One question I have at the moment is
how to evolve my data with a data store such as Riak? I know that
it's schema-less and that I can add new fields as needed but I'm
thinking more about the existing documents.
For example, say hypothetically, that I have a fairly successful
riak-based app. As the application code continues to evolve over
several versions I begin to find a "better" way to model my data. By
this time I have already stored many, many documents. What is the
appropriate path here? Do I version my documents with metadata and
rely on my application code to continue to deal with old-style
documents -- or do I perform some sort of bulk transformation on these
existing documents?
Thanks,
Allen
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com <mailto:riak-users@lists.basho.com>
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
--
*Pinney H. Colton*
*Bitwise Data, LLC*
+1.763.220.0793 (o)
+1.651.492.0152 (m)
http://www.bitwisedata.com
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com