12.4.18.2 Recorded database
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Miscellaneous
            • Recorded database
              • PL_record()
              • PL_duplicate_record()
              • PL_recorded()
              • PL_erase()
              • PL_record_external()
              • PL_recorded_external()
              • PL_erase_external()
    • Packages
Availability:C-language interface function
char * PL_record_external(term_t +t, size_t *len)
Similar to PL_record(), but the term is serialized such that it can be reloaded in another Prolog session. This implies that atoms and functors are stored by their content rather than their handle. As a result, PL_record_external() fails (returning NULL if the term contains blobs that cannot be serialized, such as streams.

These functions are used to implement library library(fastrw) as well as for storing Prolog terms in external databases such as BerkeleyDB (library library(bdb)) or RocksDB. The representation is optimized for plain atoms and numbers.

Records that are used only in the same Prolog process should use PL_record() as this can represent any term, is more compact and faster.

The returned string may be copied. Note that the string may contain null bytes and is not null terminated. The length in bytes is returned in len. After copying, the returned string may be discarded using PL_erase_external().

PL_recorded_external() is used to copy the term represented in the data back to the Prolog stack. PL_recorded_external() can be used on the returned string as well as on a copy.