public void Iterate(bool sortTableByNameAsc = false) { LoadGlobalInfo(sortTableByNameAsc); foreach (var singleton in _singletons) { if (_visitor != null && !_visitor.VisitSingleton(singleton.Key, _tableId2Name.TryGetValue(singleton.Key, out var name) ? name : null, singleton.Value)) { continue; } MarkTableName(singleton.Key); if (_trkv.Find(Vuint2ByteBuffer(ObjectDB.TableSingletonsPrefix, singleton.Key), 0) == FindResult.Exact) { _fastVisitor.MarkCurrentKeyAsUsed(_trkv); } IterateOid(singleton.Value); } foreach (var relation in _relationId2Info) { if (_visitor != null && !_visitor.StartRelation(relation.Value)) { continue; } MarkRelationName(relation.Key); IterateRelation(relation.Value); _visitor?.EndRelation(); } }
public void Iterate(bool sortTableByNameAsc = false) { LoadTableNamesDict(); LoadRelationNamesDict(); MarkLastDictId(); _trkv.SetKeyPrefixUnsafe(ObjectDB.TableSingletonsPrefix); var keyReader = new KeyValueDBKeyReader(_trkv); var valueReader = new KeyValueDBValueReader(_trkv); _singletons = new Dictionary <uint, ulong>(); while (_trkv.FindNextKey()) { keyReader.Restart(); valueReader.Restart(); _singletons.Add(keyReader.ReadVUInt32(), valueReader.ReadVUInt64()); } if (sortTableByNameAsc) { _singletons = _singletons.OrderBy(item => { string name; return(_tableId2Name.TryGetValue(item.Key, out name) ? name : string.Empty); }).ToDictionary(item => item.Key, item => item.Value); } foreach (var singleton in _singletons) { string name; if (_visitor != null && !_visitor.VisitSingleton(singleton.Key, _tableId2Name.TryGetValue(singleton.Key, out name) ? name : null, singleton.Value)) { continue; } MarkTableName(singleton.Key); _trkv.SetKeyPrefixUnsafe(ObjectDB.TableSingletonsPrefix); if (_trkv.Find(Vuint2ByteBuffer(singleton.Key)) == FindResult.Exact) { _fastVisitor.MarkCurrentKeyAsUsed(_trkv); } IterateOid(singleton.Value); } foreach (var relation in _relationId2Name) { if (_visitor != null && !_visitor.StartRelation(relation.Value)) { continue; } MarkRelationName(relation.Key); IterateRelation(relation.Key, relation.Value); if (_visitor != null) { _visitor.EndRelation(); } } }