This commit is contained in:
Kevin Jahns 2016-01-27 17:05:28 +01:00
parent 4b6352b11a
commit 89a6ec374e
5 changed files with 55 additions and 54 deletions

2
dist

@ -1 +1 @@
Subproject commit 5e295b80d793748515957c5d309d2f8e8e83af29 Subproject commit 8ba1e4ce27a75bb025a5478723ea57f7f437ccf0

View File

@ -365,7 +365,7 @@ module.exports = function (Y /* :any */) {
yield* Y.Struct['Delete'].execute.call(transaction, delop) yield* Y.Struct['Delete'].execute.call(transaction, delop)
} }
// notify parent, if it has been initialized as a custom type // notify parent, if it was instanciated as a custom type
if (t != null) { if (t != null) {
yield* t._changed(transaction, Y.utils.copyObject(op)) yield* t._changed(transaction, Y.utils.copyObject(op))
} }

View File

@ -23,7 +23,7 @@ for (let database of databases) {
}) })
it('Deleted operation is deleted', async(function * (done) { it('Deleted operation is deleted', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['u1', 10]) yield* this.markDeleted(['u1', 10], 1)
expect(yield* this.isDeleted(['u1', 10])).toBeTruthy() expect(yield* this.isDeleted(['u1', 10])).toBeTruthy()
expect(yield* this.getDeleteSet()).toEqual({'u1': [[10, 1, false]]}) expect(yield* this.getDeleteSet()).toEqual({'u1': [[10, 1, false]]})
done() done()
@ -31,8 +31,8 @@ for (let database of databases) {
})) }))
it('Deleted operation extends other deleted operation', async(function * (done) { it('Deleted operation extends other deleted operation', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['u1', 10]) yield* this.markDeleted(['u1', 10], 1)
yield* this.markDeleted(['u1', 11]) yield* this.markDeleted(['u1', 11], 1)
expect(yield* this.isDeleted(['u1', 10])).toBeTruthy() expect(yield* this.isDeleted(['u1', 10])).toBeTruthy()
expect(yield* this.isDeleted(['u1', 11])).toBeTruthy() expect(yield* this.isDeleted(['u1', 11])).toBeTruthy()
expect(yield* this.getDeleteSet()).toEqual({'u1': [[10, 2, false]]}) expect(yield* this.getDeleteSet()).toEqual({'u1': [[10, 2, false]]})
@ -41,35 +41,35 @@ for (let database of databases) {
})) }))
it('Deleted operation extends other deleted operation', async(function * (done) { it('Deleted operation extends other deleted operation', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['0', 3]) yield* this.markDeleted(['0', 3], 1)
yield* this.markDeleted(['0', 4]) yield* this.markDeleted(['0', 4], 1)
yield* this.markDeleted(['0', 2]) yield* this.markDeleted(['0', 2], 1)
expect(yield* this.getDeleteSet()).toEqual({'0': [[2, 3, false]]}) expect(yield* this.getDeleteSet()).toEqual({'0': [[2, 3, false]]})
done() done()
}) })
})) }))
it('Debug #1', async(function * (done) { it('Debug #1', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['166', 0]) yield* this.markDeleted(['166', 0], 1)
yield* this.markDeleted(['166', 2]) yield* this.markDeleted(['166', 2], 1)
yield* this.markDeleted(['166', 0]) yield* this.markDeleted(['166', 0], 1)
yield* this.markDeleted(['166', 2]) yield* this.markDeleted(['166', 2], 1)
yield* this.markGarbageCollected(['166', 2], 1) yield* this.markGarbageCollected(['166', 2], 1)
yield* this.markDeleted(['166', 1]) yield* this.markDeleted(['166', 1], 1)
yield* this.markDeleted(['166', 3]) yield* this.markDeleted(['166', 3], 1)
yield* this.markGarbageCollected(['166', 3], 1) yield* this.markGarbageCollected(['166', 3], 1)
yield* this.markDeleted(['166', 0]) yield* this.markDeleted(['166', 0], 1)
expect(yield* this.getDeleteSet()).toEqual({'166': [[0, 2, false], [2, 2, true]]}) expect(yield* this.getDeleteSet()).toEqual({'166': [[0, 2, false], [2, 2, true]]})
done() done()
}) })
})) }))
it('Debug #2', async(function * (done) { it('Debug #2', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['293', 0]) yield* this.markDeleted(['293', 0], 1)
yield* this.markDeleted(['291', 2]) yield* this.markDeleted(['291', 2], 1)
yield* this.markDeleted(['291', 2]) yield* this.markDeleted(['291', 2], 1)
yield* this.markGarbageCollected(['293', 0], 1) yield* this.markGarbageCollected(['293', 0], 1)
yield* this.markDeleted(['293', 1]) yield* this.markDeleted(['293', 1], 1)
yield* this.markGarbageCollected(['291', 2], 1) yield* this.markGarbageCollected(['291', 2], 1)
expect(yield* this.getDeleteSet()).toEqual({'291': [[2, 1, true]], '293': [[0, 1, true], [1, 1, false]]}) expect(yield* this.getDeleteSet()).toEqual({'291': [[2, 1, true]], '293': [[0, 1, true], [1, 1, false]]})
done() done()
@ -77,16 +77,16 @@ for (let database of databases) {
})) }))
it('Debug #3', async(function * (done) { it('Debug #3', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['581', 0]) yield* this.markDeleted(['581', 0], 1)
yield* this.markDeleted(['581', 1]) yield* this.markDeleted(['581', 1], 1)
yield* this.markDeleted(['580', 0]) yield* this.markDeleted(['580', 0], 1)
yield* this.markDeleted(['580', 0]) yield* this.markDeleted(['580', 0], 1)
yield* this.markGarbageCollected(['581', 0], 1) yield* this.markGarbageCollected(['581', 0], 1)
yield* this.markDeleted(['581', 2]) yield* this.markDeleted(['581', 2], 1)
yield* this.markDeleted(['580', 1]) yield* this.markDeleted(['580', 1], 1)
yield* this.markDeleted(['580', 2]) yield* this.markDeleted(['580', 2], 1)
yield* this.markDeleted(['580', 1]) yield* this.markDeleted(['580', 1], 1)
yield* this.markDeleted(['580', 2]) yield* this.markDeleted(['580', 2], 1)
yield* this.markGarbageCollected(['581', 2], 1) yield* this.markGarbageCollected(['581', 2], 1)
yield* this.markGarbageCollected(['581', 1], 1) yield* this.markGarbageCollected(['581', 1], 1)
yield* this.markGarbageCollected(['580', 1], 1) yield* this.markGarbageCollected(['580', 1], 1)
@ -96,18 +96,18 @@ for (let database of databases) {
})) }))
it('Debug #4', async(function * (done) { it('Debug #4', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['544', 0]) yield* this.markDeleted(['544', 0], 1)
yield* this.markDeleted(['543', 2]) yield* this.markDeleted(['543', 2], 1)
yield* this.markDeleted(['544', 0]) yield* this.markDeleted(['544', 0], 1)
yield* this.markDeleted(['543', 2]) yield* this.markDeleted(['543', 2], 1)
yield* this.markGarbageCollected(['544', 0], 1) yield* this.markGarbageCollected(['544', 0], 1)
yield* this.markDeleted(['545', 1]) yield* this.markDeleted(['545', 1], 1)
yield* this.markDeleted(['543', 4]) yield* this.markDeleted(['543', 4], 1)
yield* this.markDeleted(['543', 3]) yield* this.markDeleted(['543', 3], 1)
yield* this.markDeleted(['544', 1]) yield* this.markDeleted(['544', 1], 1)
yield* this.markDeleted(['544', 2]) yield* this.markDeleted(['544', 2], 1)
yield* this.markDeleted(['544', 1]) yield* this.markDeleted(['544', 1], 1)
yield* this.markDeleted(['544', 2]) yield* this.markDeleted(['544', 2], 1)
yield* this.markGarbageCollected(['543', 2], 1) yield* this.markGarbageCollected(['543', 2], 1)
yield* this.markGarbageCollected(['543', 4], 1) yield* this.markGarbageCollected(['543', 4], 1)
yield* this.markGarbageCollected(['544', 2], 1) yield* this.markGarbageCollected(['544', 2], 1)
@ -136,21 +136,21 @@ for (let database of databases) {
})) }))
it('Debug #7', async(function * (done) { it('Debug #7', async(function * (done) {
store.requestTransaction(function * () { store.requestTransaction(function * () {
yield* this.markDeleted(['9', 2]) yield* this.markDeleted(['9', 2], 1)
yield* this.markDeleted(['11', 2]) yield* this.markDeleted(['11', 2], 1)
yield* this.markDeleted(['11', 4]) yield* this.markDeleted(['11', 4], 1)
yield* this.markDeleted(['11', 1]) yield* this.markDeleted(['11', 1], 1)
yield* this.markDeleted(['9', 4]) yield* this.markDeleted(['9', 4], 1)
yield* this.markDeleted(['10', 0]) yield* this.markDeleted(['10', 0], 1)
yield* this.markGarbageCollected(['11', 2], 1) yield* this.markGarbageCollected(['11', 2], 1)
yield* this.markDeleted(['11', 2]) yield* this.markDeleted(['11', 2], 1)
yield* this.markGarbageCollected(['11', 3], 1) yield* this.markGarbageCollected(['11', 3], 1)
yield* this.markDeleted(['11', 3]) yield* this.markDeleted(['11', 3], 1)
yield* this.markDeleted(['11', 3]) yield* this.markDeleted(['11', 3], 1)
yield* this.markDeleted(['9', 4]) yield* this.markDeleted(['9', 4], 1)
yield* this.markDeleted(['10', 0]) yield* this.markDeleted(['10', 0], 1)
yield* this.markGarbageCollected(['11', 1], 1) yield* this.markGarbageCollected(['11', 1], 1)
yield* this.markDeleted(['11', 1]) yield* this.markDeleted(['11', 1], 1)
expect(yield* this.getDeleteSet()).toEqual({'9': [[2, 1, false], [4, 1, false]], '10': [[0, 1, false]], '11': [[1, 3, true], [4, 1, false]]}) expect(yield* this.getDeleteSet()).toEqual({'9': [[2, 1, false], [4, 1, false]], '10': [[0, 1, false]], '11': [[1, 3, true], [4, 1, false]]})
done() done()
}) })

View File

@ -127,7 +127,7 @@ module.exports = function (Y/* :any */) {
var i // loop counter var i // loop counter
var distanceToOrigin = i = yield* Struct.Insert.getDistanceToOrigin.call(this, op) // most cases: 0 (starts from 0) var distanceToOrigin = i = yield* Struct.Insert.getDistanceToOrigin.call(this, op) // most cases: 0 (starts from 0)
if (op.origin != null) { if (op.origin != null) { // TODO: !== instead of !=
// we save in origin that op originates in it // we save in origin that op originates in it
// we need that later when we eventually garbage collect origin (see transaction) // we need that later when we eventually garbage collect origin (see transaction)
var origin = yield* this.getOperation(op.origin) var origin = yield* this.getOperation(op.origin)

View File

@ -150,7 +150,7 @@ module.exports = function (Y/* :any */) {
var callType = false var callType = false
if (target == null || !target.deleted) { if (target == null || !target.deleted) {
yield* this.markDeleted(targetId) yield* this.markDeleted(targetId, 1)
} }
if (target != null && target.gc == null) { if (target != null && target.gc == null) {
@ -274,7 +274,8 @@ module.exports = function (Y/* :any */) {
* markDeleted (id, length) { * markDeleted (id, length) {
if (length == null) { if (length == null) {
length = 1 length = 1
// debugger // TODO!! debugger // TODO!!
throw new Error("dtrnd")
} }
// this.mem.push(["del", id]); // this.mem.push(["del", id]);
var n = yield* this.ds.findWithUpperBound(id) var n = yield* this.ds.findWithUpperBound(id)