private void assertBlocksEquals(PropertyBlock written, PropertyBlock read) { assertEquals(written.KeyIndexId, read.KeyIndexId); assertEquals(written.Size, read.Size); assertTrue(written.HasSameContentsAs(read)); assertArrayEquals(written.ValueBlocks, read.ValueBlocks); }
/// <summary> /// Converts physical changes to PropertyRecords for a entity into logical updates /// </summary> public virtual void ConvertPropertyRecord <T1>(EntityCommandGrouper <T1> changes, EntityUpdates.Builder properties) { MapBlocks(changes); int bc = 0; int ac = 0; while (bc < _beforeBlocksCursor || ac < _afterBlocksCursor) { PropertyBlock beforeBlock = null; PropertyBlock afterBlock = null; int beforeKey = int.MaxValue; int afterKey = int.MaxValue; int key; if (bc < _beforeBlocksCursor) { beforeBlock = _beforeBlocks[bc]; beforeKey = beforeBlock.KeyIndexId; } if (ac < _afterBlocksCursor) { afterBlock = _afterBlocks[ac]; afterKey = afterBlock.KeyIndexId; } if (beforeKey < afterKey) { afterBlock = null; key = beforeKey; bc++; } else if (beforeKey > afterKey) { beforeBlock = null; key = afterKey; ac++; } else { // They are the same key = afterKey; bc++; ac++; } if (beforeBlock != null && afterBlock != null) { // CHANGE if (!beforeBlock.HasSameContentsAs(afterBlock)) { Value beforeVal = ValueOf(beforeBlock); Value afterVal = ValueOf(afterBlock); properties.Changed(key, beforeVal, afterVal); } } else { // ADD/REMOVE if (afterBlock != null) { properties.Added(key, ValueOf(afterBlock)); } else { properties.Removed(key, ValueOf(beforeBlock)); } } } }