private static IDisposable ReadStats(DocumentsOperationContext context, Table table, TimeSeriesSliceHolder slicer, out long count, out DateTime start, out DateTime end, out Slice name) { count = 0; start = DateTime.MaxValue; end = DateTime.MinValue; name = slicer.NameSlice; if (table.ReadByKey(slicer.StatsKey, out var tvr) == false) { return(null); } count = DocumentsStorage.TableValueToLong((int)StatsColumns.Count, ref tvr); start = new DateTime(Bits.SwapBytes(DocumentsStorage.TableValueToLong((int)StatsColumns.Start, ref tvr))); end = DocumentsStorage.TableValueToDateTime((int)StatsColumns.End, ref tvr); if (count == 0 && start == default && end == default) { // this is delete a stats, that we re-create, so we need to treat is as a new one. start = DateTime.MaxValue; end = DateTime.MinValue; return(null); } return(DocumentsStorage.TableValueToSlice(context, (int)StatsColumns.Name, ref tvr, out name)); }