예제 #1
0
파일: Lists.cs 프로젝트: IdanHaim/ravendb
 public List<ListsInfo> GetListsStatsVerySlowly()
 {
     Api.JetSetCurrentIndex(session, Lists, "by_name_and_key");
     Api.MoveBeforeFirst(Session, Lists);
     string currentName = null;
     List<ListsInfo> res = new List<ListsInfo>();
     ListsInfo currentListsInfo = null;
     while (Api.TryMoveNext(Session, Lists))
     {
         //Since i iterate on an index that starts with name i now that a specific list item comes sequentially
         var name = Api.RetrieveColumnAsString(Session, Lists, tableColumnsCache.ListsColumns["name"],
                                              Encoding.Unicode);
         if (currentName != name)
         {
             if (currentListsInfo != null)
             {
                 res.Add(currentListsInfo);
                 currentListsInfo.AverageListItemSizeOnDiskInBytes = currentListsInfo.SizeOnDiskInBytes/currentListsInfo.Count;
             }
             currentListsInfo = new ListsInfo {Name = name};
         }
         currentName = name;
         var sizeOnDisk = Api.RetrieveColumnSize(session, Lists, tableColumnsCache.ListsColumns["data"]);
         currentListsInfo.Count++;
         if (sizeOnDisk.HasValue)
         {
             currentListsInfo.SizeOnDiskInBytes += sizeOnDisk.Value;
             if (sizeOnDisk.Value > currentListsInfo.MaxListItemSizeOnDiskInBytes)
                 currentListsInfo.MaxListItemSizeOnDiskInBytes = sizeOnDisk.Value;
             if (currentListsInfo.MinListItemSizeOnDiskInBytes == 0 || sizeOnDisk.Value < currentListsInfo.MinListItemSizeOnDiskInBytes)
                 currentListsInfo.MinListItemSizeOnDiskInBytes = sizeOnDisk.Value;
         }
     }
     res.Add(currentListsInfo);
     currentListsInfo.AverageListItemSizeOnDiskInBytes = currentListsInfo.SizeOnDiskInBytes / currentListsInfo.Count;
     res.Sort((a,b)=> b.SizeOnDiskInBytes.CompareTo(a.SizeOnDiskInBytes));
     return res;
 }
예제 #2
0
 public List<ListsInfo> GetListsStatsVerySlowly()
 {
     string currentName = null;
     List<ListsInfo> res = new List<ListsInfo>();
     ListsInfo currentListsInfo = null;
     var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);
     using (var iterator = listsByName.Iterate(Snapshot, writeBatch.Value))
     {
         if (!iterator.Seek(Slice.BeforeAllKeys))
         {
             return res;
         }
         do
         {
             currentListsInfo = new ListsInfo() {Name = iterator.CurrentKey.ToString()};
             using (var internalIterator = listsByName.MultiRead(Snapshot, iterator.CurrentKey)) 
             {
                 if (!internalIterator.Seek(Slice.BeforeAllKeys))
                 {
                     continue;
                 }
                 do
                 {                        
                     var sizeOnDisk = iterator.GetCurrentDataSize();
                     currentListsInfo.Count++;
                     currentListsInfo.SizeOnDiskInBytes += sizeOnDisk;
                     if (sizeOnDisk > currentListsInfo.MaxListItemSizeOnDiskInBytes)
                         currentListsInfo.MaxListItemSizeOnDiskInBytes = sizeOnDisk;
                     if (currentListsInfo.MinListItemSizeOnDiskInBytes == 0 || sizeOnDisk < currentListsInfo.MinListItemSizeOnDiskInBytes)
                         currentListsInfo.MinListItemSizeOnDiskInBytes = sizeOnDisk;
                 } while (internalIterator.MoveNext());
             }
             res.Add(currentListsInfo);
             currentListsInfo.AverageListItemSizeOnDiskInBytes = currentListsInfo.SizeOnDiskInBytes / currentListsInfo.Count;
         } while (iterator.MoveNext());
     }
     res.Sort((a, b) => b.SizeOnDiskInBytes.CompareTo(a.SizeOnDiskInBytes));
     return res;
 }