Delphi TClientDataSet,每个索引的最大字段数
我有一个简单的 Delphi (2007) 过程,给定一个 TDataSet 和一个字段(子)列表,返回一个新的 TClientDataSet,其中包含给定 TDataSet 的不同值。
这非常有效。
在我的过程中,我使用 TClientDataSet 索引来填充不同的值。 过程又快又简单。
问题在于 TClientDataSet 索引支持最大 16 字段。 如果您添加更多它们,它们将被默默地忽略。
我需要数据集中(以及索引中)超过 16 个字段。
有什么解决办法吗?一些黑客? 也许可以使用一些开源库作为解决方法?
我正在离线工作,所以我必须在内存中完成它。数据集的大小并不是很大
I have a simple Delphi (2007) procedure that given a TDataSet and a (sub)list of fields returns a new TClientDataSet with the distinct values from the given TDataSet.
This works quite well.
In my proc I used the TClientDataSet index to populate the distinct values.
It was fast and easy.
The problem is that TClientDataSet index support at maximum 16 fields.
If you add more of them they will be silently ignored.
I need more than 16 fields in the dataset (and thus in the index).
Is there any solution? Some hack?
Maybe some open source library to use as workaround?
I'm working offline so I must do it in memory. The size of the dataset is not huge
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您需要在超过 16 个字段中获取不同出现的记录,并且希望使用索引来保持快速,则需要考虑连接其中一些字段。例如:
测试字段 字段 1 字段 2 字段 3 字段 4
Apple~Banana~Carrot~Donut Apple Banana Carrot Donut
在测试字段上创建索引。
如果其他字段的总长度超过文本字段的最大长度,您可能需要创建多个测试字段。
If you're needing to get distinct occurrences of records across more than 16 fields and you want to use an index to keep things fast you'll need to consider concatenating some of those fields. For example:
Test Field Field 1 Field 2 Field 3 Field 4
Apple~Banana~Carrot~Donut Apple Banana Carrot Donut
Create you index on the Test Field.
You might need to create multiple test fields if the total length of your other fields exceeds the maximum length of a text field.
您可以将 TClientDataSet 替换为 JVCL 中的 TjvCsvDataset。它可以用作客户端数据集的纯“内存数据集”替代品,无需在磁盘上读取或写入任何 CSV 文件。
它在设计上不太像客户端数据集。我不确定客户端数据集中的所有这些“索引”会给您带来什么好处,除了您不能拥有没有索引定义的字段,但如果这就是您所需要的,您可以设置 TJvCsvDataSet .FieldDef property = 'Field1,Field2,.....FieldN',然后打开数据集并向数据集中添加任意数量的行。它实际上受限于 32 位进程中可以寻址的内存量。
You could swap out the TClientDataSet for a TjvCsvDataset from JVCL. It can be used as a pure "in memory dataset" replacement for Client Data Sets, without any need to read or write any CSV files on disk.
It is not quite like Client Data Set in design. I am not sure what benefit all these "Indexes" in a client data set offer you, other than that you can't have a field without an index definition, but in the case that this is all you need, you can set the TJvCsvDataSet.FieldDef property = 'Field1,Field2,.....FieldN' and then open the dataset and add as many rows as you like to the dataset. It is practically limited to the amount of memory you can address in a 32 bit process.