Azure 表存储实体中的数组(非字节)

发布于 2024-10-04 20:53:33 字数 186 浏览 3 评论 0原文

我希望将数组存储在 Azure 表实体中。目前,原生支持的唯一数组类型是字节数组,长度限制为 64k。大小足够了,但我想在实体中存储长整型、双精度型和时间戳的数组。

显然,我可以自己将多个字节转换为请求的类型,但我想知道是否有任何最佳实践可以实现这一点。

澄清一下,这些是与单个键关联的固定长度数组(例如 1000 个单元)。

I'm looking to store arrays in Azure Table entities. At present, the only type of array supported natively is byte-array, limited to 64k length. The size is enough, but I'd like to store arrays of longs, doubles and timestamps in an entity.

I can obviously cast multiple bytes to the requested type myself, but I was wondering if there's any best-practice to achieve that.

To clarify, these are fixed length arrays (e.g. 1000 cells) associated with a single key.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

给我一枪 2024-10-11 20:53:33

我编写了一个 Azure 表存储客户端,名为 Lucifure Stash,它支持数组、枚举、大数据、序列化、公共和私有属性和字段等。

您可以在 https://github.com/hocho/LucifureStash 获取它

I have written a Azure table storage client, called Lucifure Stash, which supports arrays, enums, large data, serialization, public and private properties and fields and more.

You can get it at https://github.com/hocho/LucifureStash

不必了 2024-10-11 20:53:33

除了您已经提到的方法之外,我一直在尝试想出一种好方法来做到这一点,但我不知所措。我能想到的最简单的解决方案是获取数组,对其进行二进制序列化并存储在二进制数组属性中。

我提出但被驳回的其他选项:

  1. 如果本地存储很重要,您可以将此信息保留在另一个子表中(我知道Azure表在技术上没有关系,但这并不意味着您不能代表这类事情)。这样做的缺点是它会比原来的速度慢得多。
  2. 获取数组,XML 将其序列化并将其存储在字符串属性中。这意味着您在使用第 3 方数据浏览器工具时可以看到数组的内容,并且可以运行(低效)查询来查找数组内容的精确匹配。
  3. 使用 Lokad Cloud 胖实体存储您的数据。这本质上是获取整个对象,对其进行二进制序列化,并将结果拆分为跨表实体属性的 64kb 块。这确实解决了您遇到的问题,但您只能使用支持此框架的工具来访问数据。

I've been trying to think of a nice way to do this other than the method you've already mentioned, and I'm at a loss. The simplest solution I can come up with is to take the array, binary serialize it and store in a binary array property.

Other options I've come up with but dismissed:

  1. If storing it natively is important, you could keep this information in another child table (I know Azure Tables don't technically have relationships, but that doesn't mean you can't represent this type of thing). The downside of this being that it will be considerably slower than your original.
  2. Take the array, XML serialize it and store it in a string property. This would mean that you could see the contents of your array when using 3rd party data explorer tools and you could run (inefficient) queries that look for an exact match on the contents of the array.
  3. Use Lokad Cloud fat entities to store your data. This essentially takes you're whole object, binary serializes it and splits the results into 64kb blocks across the properties of the table entity. This does solve problems like the one you're experiencing, but you will only be able to access your data using tools that support this framework.
小情绪 2024-10-11 20:53:33

如果您只需要存储一个键值集合,那么您还可以查看 Azure BLOB。它们可以相当有效地存储每个 blob 最多 25M 时间值点的数组(在数据集中进行随机访问)。

If you have just a key-value collection to store, then you can also check out Azure BLOBs. They can rather efficiently store arrays of up to 25M time-value points per single blob (with a random access within the dataset).

情绪操控生活 2024-10-11 20:53:33

如果您选择将对象存储在 Blob 存储中,并且需要多个“密钥”来获取它,则只需创建一个或两个或 n 个 Azure 表,在其中存储要查找的密钥以及对确切 Blob 的引用物品。

If you choose to store your object in blob storage and need more than one "key" to get it, you can just create an azure table or two or n where you store the key you want to look up and the reference to the exact blob item.

冷情 2024-10-11 20:53:33

为什么不将值存储为 csv 字符串?

Why don't you store the values as csv strings?

草莓味的萝莉 2024-10-11 20:53:33

您可以使用 .NET JavaScript 序列化器将数组序列化为 JSON 字符串:
http://msdn.microsoft.com/en -us/library/system.web.script.serialization.javascriptserializer.aspx

这个类有一个“MaxJsonLength”属性,您可以使用它来确保数组在序列化时不超过 64K。您可以使用相同的类来反序列化存储的对象。

You could serialize your array as a JSON string using the .NET JavaScript serializer:
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx

This class has a "MaxJsonLength" property you could use to ensure your arrays didn't exceed 64K when you were serializing them. And you can use the same class to deserialize your stored objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文