Пример #1
0
        private static IndexStats GetIndexStats(StructureReader <IndexingWorkStatsFields> indexingStats, StructureReader <ReducingWorkStatsFields> reduceStats, StructureReader <LastIndexedStatsFields> lastIndexedEtags, int priority, int touches)
        {
            var lastReducedEtag      = Etag.Parse(reduceStats.ReadBytes(ReducingWorkStatsFields.LastReducedEtag));
            var reduceAttempts       = reduceStats.ReadInt(ReducingWorkStatsFields.ReduceAttempts);
            var reduceErrors         = reduceStats.ReadInt(ReducingWorkStatsFields.ReduceErrors);
            var reduceSuccesses      = reduceStats.ReadInt(ReducingWorkStatsFields.ReduceSuccesses);
            var lastReducedTimestamp = reduceStats.ReadLong(ReducingWorkStatsFields.LastReducedTimestamp);

            return(new IndexStats
            {
                TouchCount = touches,
                IndexingAttempts = indexingStats.ReadInt(IndexingWorkStatsFields.IndexingAttempts),
                IndexingErrors = indexingStats.ReadInt(IndexingWorkStatsFields.IndexingErrors),
                IndexingSuccesses = indexingStats.ReadInt(IndexingWorkStatsFields.IndexingSuccesses),
                ReduceIndexingAttempts = reduceAttempts == -1 ? (int?)null : reduceAttempts,
                ReduceIndexingErrors = reduceErrors == -1 ? (int?)null : reduceErrors,
                ReduceIndexingSuccesses = reduceSuccesses == -1 ? (int?)null : reduceSuccesses,
                Id = indexingStats.ReadInt(IndexingWorkStatsFields.IndexId),
                Priority = (IndexingPriority)priority,
                LastIndexedEtag = Etag.Parse(lastIndexedEtags.ReadBytes(LastIndexedStatsFields.LastEtag)),
                LastIndexedTimestamp = DateTime.FromBinary(lastIndexedEtags.ReadLong(LastIndexedStatsFields.LastTimestamp)),
                CreatedTimestamp = DateTime.FromBinary(indexingStats.ReadLong(IndexingWorkStatsFields.CreatedTimestamp)),
                LastIndexingTime = DateTime.FromBinary(indexingStats.ReadLong(IndexingWorkStatsFields.LastIndexingTime)),
                LastReducedEtag =
                    lastReducedEtag.CompareTo(Etag.InvalidEtag) != 0
                        ? lastReducedEtag
                        : null,
                LastReducedTimestamp = lastReducedTimestamp == -1 ? (DateTime?)null : DateTime.FromBinary(lastReducedTimestamp)
            });
        }