read an SIValue from the data stream and update the index appropriately
| 121 | |
| 122 | // read an SIValue from the data stream and update the index appropriately |
| 123 | static SIValue _BulkInsert_ReadProperty |
| 124 | ( |
| 125 | const char* data, |
| 126 | size_t* data_idx |
| 127 | ) { |
| 128 | // binary property format: |
| 129 | // - property type : 1-byte integer corresponding to TYPE enum |
| 130 | // - Nothing if type is NULL |
| 131 | // - 1-byte true/false if type is boolean |
| 132 | // - 8-byte double if type is double |
| 133 | // - 8-byte integer if type is integer |
| 134 | // - Null-terminated C string if type is string |
| 135 | // - 8-byte array length followed by N values if type is array |
| 136 | |
| 137 | // possible property values |
| 138 | bool b; |
| 139 | double d; |
| 140 | int64_t i; |
| 141 | int64_t len; |
| 142 | const char* s; |
| 143 | |
| 144 | SIValue v = SI_NullVal(); |
| 145 | TYPE t = data[*data_idx]; |
| 146 | *data_idx += 1; |
| 147 | |
| 148 | switch (t) { |
| 149 | case BI_NULL: |
| 150 | v = SI_NullVal(); |
| 151 | break; |
| 152 | |
| 153 | case BI_BOOL: |
| 154 | b = data[*data_idx]; |
| 155 | *data_idx += 1; |
| 156 | v = SI_BoolVal(b); |
| 157 | break; |
| 158 | |
| 159 | case BI_DOUBLE: |
| 160 | d = *(double*)&data[*data_idx]; |
| 161 | *data_idx += sizeof(double); |
| 162 | v = SI_DoubleVal(d); |
| 163 | break; |
| 164 | |
| 165 | case BI_LONG: |
| 166 | i = *(int64_t*)&data[*data_idx]; |
| 167 | *data_idx += sizeof(int64_t); |
| 168 | v = SI_LongVal(i); |
| 169 | break; |
| 170 | |
| 171 | case BI_STRING: |
| 172 | s = data + *data_idx; |
| 173 | *data_idx += strlen(s) + 1; |
| 174 | // The string itself will be cloned when added to the GraphEntity properties. |
| 175 | v = SI_ConstStringVal((char*)s); |
| 176 | break; |
| 177 | |
| 178 | case BI_ARRAY: |
| 179 | // The first 8 bytes of a received array will be the array length. |
| 180 | len = *(int64_t*)&data[*data_idx]; |
no test coverage detected