Consider storing serialized Java objects as Cassandra as JSON What is catch?

I'm using Cassandra 1.2 2. I find it easy to use Jackson to map my objects and store JSON and Java in the database I'm actually trying to do this for all my data My question is, is that a good idea? What are the disadvantages to my application? My first guess may be more processing overhead, but is the juice worth squeezing? Are there any other shortcomings I need to know?

Solution

One disadvantage is to modify the original data, deserialize, change, serialize, and write out the entire object In Cassandra, writing efficiency is much higher than reading efficiency, so it is beneficial to avoid reading before writing if possible

Another approach is to use separate columns for each field in JSON You can use composite columns for multidimensional data

So if you have data:

{
  name: "fred"
  address: "some town"
  age: 42
}

If you want to change the address, if you use these columns as separate Cassandra columns, you only need to insert a column named address If your JSON is serialized, you have to do more work Not applicable if your data is written once

Even if your data is written at one time, if you only want to read a field from the data, you can read the column by storing it separately, instead of reading the whole thing and deserializing it This applies only to some of the data you want to read

In summary, using separate columns may have significant performance advantages if you have to update data or want to read parts only once

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>