datajoint / mym

MySQL API for MATLAB with support for BLOB objects
Other
8 stars 17 forks source link

add support for logical arrays in blobs #3

Closed dimitri-yatsenko closed 11 years ago

dimitri-yatsenko commented 11 years ago

Currently, mym does not accept logical arrays in blobs. DataJoint works around this issue by converting logical arrays into uint8, but it does not know to convert them back into logical when fetching.

ahoenselaar commented 11 years ago

mym handles logical arrays in blobs just fine. I don't know why we perform the uint8 conversion in dj.BaseRelvar.insert().

dimitri-yatsenko commented 11 years ago

i cannot recall now why I added the special logic to handle boolean arrays. I think it was in response to something Mani did. I will take it out and test it.

ahoenselaar commented 11 years ago

The change happened in March 2011 but there is no commit comment in the SVN repo to explain it.

dimitri-yatsenko commented 11 years ago

Just tested it. When I try to insert a boolean array, I get the following error:

Error using mym
Matlab placeholder only support array, structure, or cell

Here is the code in mym.cpp that appears to exclude logical arrays

 if (*pt==PH_MATLAB) {
    // this placeholder results in a serialized version of array, cell or structure 
    rpec = true;
    if (mxIsNumeric(rparg)||mxIsChar(rparg))
      rpf = &serializeArray;
    else if (mxIsCell(rparg))
      rpf = &serializeCell;
    else if (mxIsStruct(rparg))
      rpf = &serializeStruct;
    else
      mexErrMsgTxt("Matlab placeholder only support array, structure, or cell");
  }
ahoenselaar commented 11 years ago

Ah yes, you are right. I was running a different branch. Logical arrays are correctly treated in mym at n-1 out of n locations, e.g. you can have them in your structs or cell arrays and everything works fine. It is only if they are the top-level object being serialized that you get this error, as shown in the code fragment above. It's a one-line fix; I'll push it later.