在 Oracle 中将浮点数组存储为 BLOB

发布于 2024-07-25 22:36:45 字数 452 浏览 1 评论 0原文

我正在设计一个新的实验室数据库。 对于某些测试,我同时采集了多个波形,其中大约有 10,000 个数据点。 在应用程序(用 C 编写)中,波形存储为浮点数组。

我相信我想将每个波形存储为 BLOB。

问题:

BLOB 中的数据的结构是否可以使 Oracle 仅使用 SQL 或 PL/SQL 来处理数据本身?

  • 确定最大值、最小值、平均值等
  • 当值首次超过 500 时检索索引
  • 检索第 400 个数字
  • 创建 BLOB,它是第一个 BLOB 的派生

注意: 此消息是 在 Oracle 中存储波形

I am designing a new laboratory database. For some tests, I have several waveforms with ~10,000 data points acquired simultaneously. In the application (written in C), the waveforms are stored as an array of floats.

I believe I would like to store each waveform as a BLOB.

Questions:

Can the data in a BLOB be structured in such a way that Oracle can work with the data itself using only SQL or PL/SQL?

  • Determine max, min, average, etc
  • Retrieve index when value first exceeds 500
  • Retrieve 400th number
  • Create BLOB which is a derivative of first BLOB

NOTE: This message is a sub-question of Storing Waveforms in Oracle.

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

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

发布评论

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

评论(3

最美的太阳 2024-08-01 22:36:45
  • 确定最大值、最小值、平均值等
  • 当值首先时检索索引
    超过 500
  • 检索第 400 个数字

关系数据模型是为这种分析而设计的 - 如果您正确地对数据进行建模,Oracle 的 SQL 完全有能力做到这一点。 我建议您专注于将浮点数组转换为数字表 - 我怀疑您会发现在 SQL 中执行此类查询的速度足以弥补所花费的时间。

另一种方法是尝试编写能够在运行时有效执行此转换的 SQL - 每次运行 SQL 时; 这可能会降低效率。

  • Determine max, min, average, etc
  • Retrieve index when value first
    exceeds 500
  • Retrieve 400th number

The relational data model was designed for this kind of analysis - and Oracle's SQL is more than capable of doing this, if you model your data correctly. I recommend you focus on transforming the array of floats into tables of numbers - I suspect you'll find that the time taken will be more than compensated for by the speed of performing these sorts of queries in SQL.

The alternative is to try to write SQL that will effectively do this transformation at runtime anyway - every time the SQL is run; which will probably be much less efficient.

花伊自在美 2024-08-01 22:36:45

您可能还希望考虑 VARRAY 类型。 您确实必须使用整个数组(不检索子集、部分更新等),但您可以定义最大长度,Oracle 将仅存储您使用的内容。 您可以声明几乎任何数据类型的 VARRAY,包括 BINARY_FLOAT 或 NUMBER。 BINARY_FLOAT 将最大限度地减少您的存储空间,但会遇到一些小的精度问题(尽管在金融应用程序中很重要)。 它采用 IEEE 754 格式。

由于您计划使用 PL/SQL 操作数据,因此我可能会放弃 BLOB 设计。 VARRAY 使用起来会更加方便。 BLOB 可以非常方便地存储原始 C 浮点数数组,以便以后在另一个 C 程序中使用。

请参阅PL/SQL 用户指南和参考 了解如何使用它们。

You may also wish to consider the VARRAY type. You do have to work with the entire array (no retreival of subsets, partial updates, etc.) but you can define a max length and Oracle will store only what you use. You can declare VARRAYs of most any datatype, including BINARY_FLOAT or NUMBER. BINARY_FLOAT will minimize your storage, but suffers from some minor precision issues (although important in financial applications). It is in IEEE 754 format.

Since you're planning to manipulate the data with PL/SQL I might back off from the BLOB design. VARRAYs will be more convenient to use. BLOBs would be very convenient to store an array of raw C floats for later use in another C program.

See PL/SQL Users Guide and Reference for how to use them.

原野 2024-08-01 22:36:45

我认为您可以创建 PL/SQL 函数,将 blob 作为参数并返回有关它的信息。

如果您可以使用 XMLType 作为字段,那么您绝对可以在 PL/SQL 中解析并编写您想要的函数。

http: //www.filibeto.org/sun/lib/nonsun/oracle/11.1.0.6.0/B28359_01/appdev.111/b28369/xdb10pls.htm

当然,XML 会慢很多,但是如果您无法解析二进制数据,这是一种替代方案。

I think that you could probably create PL/SQL functions that take the blob as a parameter and return information on it.

If you could use XMLType for the field, then you can definitely parse in PL/SQL and write the functions you want.

http://www.filibeto.org/sun/lib/nonsun/oracle/11.1.0.6.0/B28359_01/appdev.111/b28369/xdb10pls.htm

Of course, XML will be quite a bit slower, but if you can't parse the binary data, it's an alternative.

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