Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • bufio() limits or bug?

    Mata read/writes via bufio seem to be limited to under 2^31 bytes at a time (largest signed integer). Is this a bug or a limitation of reading/writing matrices? Apologies if I missed the docs for the latter. Simple example:

    Code:
    mata
    C  = bufio()
    fn = st_tempfilename()
    fh = fopen(fn, "w")
    fbufput(C, fh, "%8z", runiform(((2^31)/8)-1, 1))
    fbufput(C, fh, "%8z", runiform(((2^31)/8),   1))
    fclose(fh)
    unlink(fn)
    end
    The second fbufput gives

    Code:
                    bufput():  3300  argument out of range
                   fbufput():     -  function returned error
                     <istmt>:     -  function returned error
    r(3300);

  • #2
    Originally posted by Mauricio Caceres View Post
    Mata read/writes via bufio seem to be limited to under 2^31 bytes at a time . . . Is this a bug or a limitation . . . ? Apologies if I missed the docs for the latter.
    It's the latter, and the documentation is in the Limits and memory utilization help file.

    fbufput() is a convenience wrapper for bufput() for ease-of-use when writing to files.

    The documentation for bufput() states, "bufput(C, B, offset, bfmt, X) aborts with error if B is too short to receive the result . . ."

    B (the buffer) is string scalar, and in the limits help file linked to above, "string elements" (string scalars) in Mata are limited to 2,147,483,647 (i.e., 2^31-1) bytes.

    Comment


    • #3
      Joseph Coveney Ah, I had seen the note you quote here on the limits for strings, but I figured those were strings, not numbers (which Stata suggests can be up to 2^48-1 in size).

      What I hadn't clocked was the mechanic you pointed out that mata writes to B, and B is limited to 2^31-1 bytes. Thanks!

      Comment

      Working...
      X