Binary data can be stored in eXtremeDB fields of type
string, blob,binaryandvarbinary. Fields of typeblobcan be used for large data fields (greater than 1 Kb). When a field is not intended to be used in indexes and its data size is less than 64 Kbstringfields can be used.Stringfields in eXtremeDB can contain arbitrary data, not only ASCII characters; i.e. arbitrary binary data can be stored in astringwithout encoding. The only limitation is thatstringfields cannot be used in internal comparisons (needed for indexes) and cannot be passed as parameters in xSQL. If a field of binary data is intended to be indexed, thebinaryorvarbinarydata type can be used. Unlikeblobfields,binaryandvarbinaryfields can be added to both simple and compound indexes.(See page Using Binary Data for further details.)
Blob Support
eXtremeDB provides support for Binary Large Object (
blob)fields through C/C++ interface functions and, for C# and Java applications, theblobfield annotation or attribute. Ablobfield cannot be part of anarrayorstruct. Blob elements are useful when it is necessary to keep streaming data, with no known size limits.C/C++ applications use the generated
classname_fieldname_get()function to copyblobdata to an application’s buffer; it allows specification of a starting offset within theblob.MCO_RET classname_fieldname_get( /*IN*/ classname *handle, /*IN*/ uint4 startOffset, /*OUT*/ char *buf, /*IN*/ uint4 bufsz, /*OUT*/ uint4 *len);The
bufszparameter is the size of the buffer passed by the application in thebufparameter. Thelenoutput parameter is the actual number of bytes copied to the buffer (which will be<= bufsz).The
classname_fieldname_size()function returns the size of ablobfield. This value can be used to allocate sufficient memory to hold theblob, prior to calling theclassname_fieldname_get()function.MCO_RET classname_fieldname_size( /*IN*/ classname *handle, /*OUT*/ uint4 * result);The
classname_fieldname_put()function populates ablobfield, possibly overwriting prior contents. It allocates space and copies data from the application’s buffer; the size of theblobmust be specified.MCO_RET classname_fieldname_put( /*IN*/ classname *handle, /*IN*/ const void *from, /*IN*/ uint4 nbytes);The
classname_fieldname_append()function is used to append data to an existingblob. This method is provided so an application does not have to allocate a single buffer large enough to hold the entireblob, but rather can conserve memory by writing theblobin manageable pieces.MCO_RET classname_fieldname_append(/*IN*/ classname *handle, /*IN*/ const void * from, /*IN*/ uint4 nbytes );To erase (truncate) a
blob, pass a size of 0 to theclassname_fieldname_put()function.