(self, cls, value, callback)
| 327 | } |
| 328 | |
| 329 | function addDocument(self, cls, value, callback) { |
| 330 | |
| 331 | // meta.typeid (1 CLASS, 2 RELATION) |
| 332 | // meta.type (link to type class/relation) |
| 333 | // meta.state |
| 334 | // meta.parentindex |
| 335 | // meta.relationindex |
| 336 | // meta.size |
| 337 | // meta.data |
| 338 | |
| 339 | var meta = {}; |
| 340 | meta.type = cls; |
| 341 | meta.typeid = TYPE_CLASS; |
| 342 | meta.state = 1; |
| 343 | meta.parentindex = 0; |
| 344 | meta.relationindex = 0; |
| 345 | meta.data = U.createBuffer(stringifyData(cls.schema, value)); |
| 346 | meta.size = meta.data.length; |
| 347 | |
| 348 | var limit = self.header.documentsize - DATAOFFSET; |
| 349 | |
| 350 | if (meta.data.length > limit) { |
| 351 | Zlib.deflate(meta.data, ZLIBOPTIONS, function(err, buf) { |
| 352 | if (err || buf.length > limit) |
| 353 | callback(new Error('GraphDB: Data too long'), 0); |
| 354 | else { |
| 355 | meta.state = STATE_COMPRESSED; |
| 356 | meta.data = buf; |
| 357 | meta.size = buf.length; |
| 358 | addNodeFree(self, meta, callback); |
| 359 | } |
| 360 | }); |
| 361 | } else |
| 362 | addNodeFree(self, meta, callback); |
| 363 | } |
| 364 | |
| 365 | function addRelation(self, relation, indexA, indexB, callback) { |
| 366 |
no test coverage detected