예제 #1
0
        void LoadVersionInfos(IKeyValueDBTransaction tr)
        {
            LastPersistedVersion = 0;
            var writer = new ByteBufferWriter();

            writer.WriteByteArrayRaw(ObjectDB.RelationVersionsPrefix);
            writer.WriteVUInt32(_id);
            tr.SetKeyPrefix(writer.Data);
            if (!tr.FindFirstKey())
            {
                return;
            }
            var keyReader   = new KeyValueDBKeyReader(tr);
            var valueReader = new KeyValueDBValueReader(tr);

            do
            {
                keyReader.Restart();
                valueReader.Restart();
                LastPersistedVersion = keyReader.ReadVUInt32();
                var relationVersionInfo = RelationVersionInfo.Load(valueReader,
                                                                   _relationInfoResolver.FieldHandlerFactory, _name);
                _relationVersions[LastPersistedVersion] = relationVersionInfo;
            } while (tr.FindNextKey());
        }
예제 #2
0
파일: ODBIterator.cs 프로젝트: saryn/BTDB
        uint ReadRelationVersions(uint relationIndex, string name, Dictionary <uint, RelationVersionInfo> relationVersions)
        {
            uint lastPersistedVersion = 0;

            {
                var relationInfoResolver = new RelationInfoResolver((ObjectDB)_tr.Owner);
                var writer = new ByteBufferWriter();
                writer.WriteByteArrayRaw(ObjectDB.RelationVersionsPrefix);
                writer.WriteVUInt32(relationIndex);
                _trkv.SetKeyPrefix(writer.Data);
                if (!_trkv.FindFirstKey())
                {
                    return(lastPersistedVersion);
                }
                var keyReader   = new KeyValueDBKeyReader(_trkv);
                var valueReader = new KeyValueDBValueReader(_trkv);
                do
                {
                    keyReader.Restart();
                    valueReader.Restart();
                    lastPersistedVersion = keyReader.ReadVUInt32();
                    relationVersions[lastPersistedVersion] = RelationVersionInfo.Load(valueReader,
                                                                                      relationInfoResolver.FieldHandlerFactory, name);
                } while (_trkv.FindNextKey());
            }
            return(lastPersistedVersion);
        }