开发者

How to store big double array on Java AppEngine

I have arrays of 10,000 开发者_如何学Pythondouble values that I'd like to store in the JAVA appengine data store. I don't need to query by any of the values, just need to store all of them and retrieve all of them. What is the best way to represent this data in the data store. I will always need the entire array or not at all (never a subset of the 10,000 values).

My current thinking is just storing it as a blob data - any other views?


If you don't need to query by the values, serialize it and store it in a text or blob property. It will save you a lot of overhead compared to a ListProperty. I suggest using which ever serialization method works the best with what you're doing, such as JSON if you just return it to a client.

class T(db.Model):
   prop = db.ListProperty(int)

print db.model_to_protobuf(T(prop=[1, 2, 3]))

# result:
key <
  app: "testapp"
  path <
    Element {
      type: "T"
      id: 0
    }
  >
>
entity_group <
>
property <
  name: "prop"
  value <
    int64Value: 1
  >
  multiple: true
>
property <
  name: "prop"
  value <
    int64Value: 2
  >
  multiple: true
>
property <
  name: "prop"
  value <
    int64Value: 3
  >
  multiple: true
>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜