TheSwamp

Code Red => .NET => Topic started by: gswang on June 10, 2017, 06:02:36 AM

Title: ResultBuffer's capacity?
Post by: gswang on June 10, 2017, 06:02:36 AM
Xrecord can store ResultBuffer type data, but what is its maximum capacity?
thank you very much!
Title: Re: ResultBuffer's capacity?
Post by: Keith Brown on June 10, 2017, 07:14:48 AM
The size of an xrecord is technically unlimited I believe.  The maximum size of a result buffer is I believe 127 bytes.
Title: Re: ResultBuffer's capacity?
Post by: Keith™ on June 10, 2017, 08:01:50 AM
The size of an xrecord is technically unlimited I believe.  The maximum size of a result buffer is I believe 127 bytes.

I am reading large files into a resultbuffer and storing them as xRecords
Something like this works without issue

Code - C#: [Select]
  1. string Notes = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
  2. ResultBuffer rb = new ResultBuffer(new TypedValue((int)DxfCode.Text, Notes));

Title: Re: ResultBuffer's capacity?
Post by: Keith Brown on June 10, 2017, 08:23:42 AM
Here is a link that has some more info.


https://www.theswamp.org/index.php?topic=52504.msg574801#msg574801 (https://www.theswamp.org/index.php?topic=52504.msg574801#msg574801)


In that thread there is another link that discusses compressing the info before storing in the result buffer.
Title: Re: ResultBuffer's capacity?
Post by: gswang on June 10, 2017, 06:47:32 PM
Thank you, Keith and Keith Brown!
Title: Re: ResultBuffer's capacity?
Post by: dgorsman on June 12, 2017, 10:13:21 AM
Put another way, logical organization should prevent it from reaching any kind of size where this becomes a problem.
Title: Re: ResultBuffer's capacity?
Post by: WILL HATCH on June 19, 2017, 03:08:39 PM
Keith, I'm really surprised this is working properly for you... I can't remember exactly what circumstances (audit?) will expose the underlying error in this usage are however... TypedValue has a limited size, and longer strings must be properly parsed into chunks on their way into the result buffer in order to persist through the (audit?)

Sorry I'm not more specific here, it's been 6 months since I dug into this... I remember this awesome post had led me to some clarity: https://www.theswamp.org/index.php?topic=27010.msg325377#msg325377 (https://www.theswamp.org/index.php?topic=27010.msg325377#msg325377)


The size of an xrecord is technically unlimited I believe.  The maximum size of a result buffer is I believe 127 bytes.

I am reading large files into a resultbuffer and storing them as xRecords
Something like this works without issue

Code - C#: [Select]
  1. string Notes = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
  2. ResultBuffer rb = new ResultBuffer(new TypedValue((int)DxfCode.Text, Notes));
Title: Re: ResultBuffer's capacity?
Post by: Keith Brown on June 19, 2017, 04:15:43 PM
Hi Will,  good to see you back at the swamp.


I believe that I got this mixed up.  The typedvalue has a maximum chunk size of 127 (of a Byte).  The resultbuffer can contain alot of typedvalues.   As I mentioned in another thread, I can take a memory stream that represents a xml file of over a million lines and break and add it to a resultbuffer in a series of typedvalues of size 127.


This works pretty good for me and is currently out in the public domain in a program that takes CADWorx piping objects and sends them into a Stress Analysis program and then takes the analysis results and brings them back into CADWorx.


** Edited to clarify Byte typed values have a max size of 127 

Title: Re: ResultBuffer's capacity?
Post by: Keith™ on June 19, 2017, 10:10:00 PM
I have a notepad clone in my latest project that stores documents in drawings.
It has a RichText container that users can type into, format, edit fonts, etc. They can save the document to the hard drive and/or save it in the drawing.

This works without issue and without breaking down the document into smaller chunks. The theoretical limit for a text blob is 65535 (I think).

There is some code here that you can look at

https://www.theswamp.org/index.php?topic=27010.0

and

https://www.theswamp.org/index.php?topic=26687.0

Daniel has tested it to just over 2MB.
Title: Re: ResultBuffer's capacity?
Post by: huiz on June 20, 2017, 03:32:17 AM
The max size depends on the type (DXF code) you put in. You should read the DXF Reference. If you use DXF code for strings, it might be 255 char, but elsewhere in the documentation it claims a rise to 2049 char. DXF code 300-309 can be used for arbitrary text strings, but DXF code 1000 can only contain 255 char. Unless the documentation is not corrected at this point and then 2049 chars are available.
So it is not always neccessary to break strings in chunks.
Title: Re: ResultBuffer's capacity?
Post by: Keith Brown on June 20, 2017, 08:07:49 AM
I believe for bytes it is 127.  All documentation that I have read states it at that size.  I create an xml text file and then create a memory stream and then store it in a result buffer.


I should have been much more clear on my answer.
Title: Re: ResultBuffer's capacity?
Post by: huiz on June 20, 2017, 08:14:18 AM
Well, if it ain't broke, don't fix it :-)
Title: Re: ResultBuffer's capacity?
Post by: Keith™ on June 20, 2017, 04:11:00 PM
In my particular case, I've tested the storage capacity to about 10k using DXF group code 1.