MCPcopy Index your code
hub / github.com/totaljs/framework / addPage

Function addPage

graphdb.js:152–202  ·  view source on GitHub ↗
(self, type, index, parentindex, callback)

Source from the content-addressed store, hash-verified

150
151// Creates new page
152function addPage(self, type, index, parentindex, callback) {
153
154 // @type
155 // 1: classes
156 // 2: relations
157 // 3: relations private
158
159 // @index
160 // index of value
161
162 // Add a new page
163 self.header.pages++;
164
165 var indexer = self.header.pages;
166 var buffer = [];
167 var page = U.createBufferSize(self.header.pagesize);
168
169 // console.log('CREATING PAGE:', TYPES[type], indexer, type, index);
170
171 page.writeUInt8(type, 0); // type (1:class, 2:relation, 3:private)
172 page.writeUInt8(index, 1); // index
173 page.writeUInt16LE(0, 2); // documents
174 page.writeUInt8(0, 4); // freeslots
175 page.writeUInt32LE(parentindex, 5); // parentindex
176
177 buffer.push(page);
178
179 for (var i = 0; i < self.header.pagelimit; i++) {
180 var doc = U.createBufferSize(self.header.documentsize);
181 doc.writeUInt8(type, 0);
182 doc.writeUInt8(index, 1);
183 doc.writeUInt8(STATE_REMOVED, 2);
184 doc.writeUInt32LE(self.header.pages, 3);
185 doc.writeUInt32LE(0, 7); // continuerindex
186 doc.writeUInt32LE(0, 11); // parentindex
187 doc.writeUInt16LE(0, 15); // size/count
188 buffer.push(doc);
189 }
190
191 buffer = Buffer.concat(buffer);
192
193 var offset = offsetPage(self, indexer);
194
195 Fs.write(self.fd, buffer, 0, buffer.length, offset, function(err) {
196 err && self.error(err, 'createPage.write');
197 !err && updMeta(self, type === TYPE_RELATION_DOCUMENT ? META_PAGE_ADD3 : META_PAGE_ADD);
198 callback && callback(err, indexer);
199 });
200
201 return indexer;
202}
203
204function addNodeFree(self, meta, callback) {
205

Callers 2

addNodeFunction · 0.85
graphdb.jsFile · 0.85

Calls 3

offsetPageFunction · 0.85
updMetaFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected