使用系统间的缓存一次读取整个文件字节? [英] Read entire file bytes at once using intersystems' Cache?

查看:166
本文介绍了使用系统间的缓存一次读取整个文件字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大小为{code> {filebyte} 的1.5GB字节的文件。我想在一个实例实例中读取整个文件,类似于Delphi的

I have a file of bytes 1.5GB in size {filebyte}. I want to read the entire file in one instance instance similar to Delphi's

bytedata:=filebyte.readallbytes(filename);

结果是,在一个实例中,您将拥有一个字节数组,其中元素数量很高(bytedata )-low(bytedata)+1。缓存中是否有等效的代码。是否可以将1.5G大小的文件保存在缓存中。
我不想分块读取文件,因为分析数据的操作要求整个文件一次存储在内存中。
谢谢

The result being that in one instance you will have a bytearray with the number of elements being high(bytedata)-low(bytedata)+1. Is there equivalent code in Cache. Can a file of 1.5G in size be held in memory in cache. I do not want to read the file in blocks as the operation to analyse the data requires that the whole file be in memory at one time. Thanks

推荐答案

您可以从流中读取所需数量的数据。问题出在这里,您可以在本地变量中存储多少。

You can read from the stream as many data as you need. The problem is here, how much you can store in a local variable.

set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="c:\test.txt"
set length=fs.Size
set data=fs.Read(length) \\ if size no more than 3.5Mb

局部变量大小限制 3,641,144字节或32,767字节的长字符串是可行的。每个进程最多2012.1的内存限制为48 MB。并且在2012.2中进行了更改,可以设置为每个进程2 TB,,并且仅针对具有特殊变量 $ zstorage

Local variable size limited by 3,641,144 bytes or 32,767 bytes of long strings diabled. And up to 2012.1 memory per process was limited by 48mbytes. And in 2012.2 it was changed and it is possible to set up to 2 terabytes per process, and in real time programmatically just for a current process with special variable $zstorage.

这篇关于使用系统间的缓存一次读取整个文件字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆