예제 #1
0
        public DataContainerStats GetStats()
        {
            CheckHaveDescriptor();
            var stats = new DataContainerStats();

            foreach (var doc in m_descriptor.EnumerateDocumentTypes())
            {
                stats.SetDocumentCount(doc.DocumentType, m_dataContainer.RequireDocumentContainer(doc.DocumentType).UntrimmedCount);
            }

            return(stats);
        }
예제 #2
0
        public void WriteStatsToStore()
        {
            var stats = new DataContainerStats();

            foreach (var pair in m_documentDataContainers)
            {
                var docStore = RequireDocumentContainer(pair.Key);
                stats.SetDocumentCount(pair.Key, docStore.UntrimmedCount);
            }

            WriteStatsToStore(stats, m_storageRoot);
        }
        public DataContainerStatsFile(Version version, DataContainerStats stats)
        {
            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (stats == null)
            {
                throw new ArgumentNullException("stats");
            }

            DriverVersion      = version.ToString();
            DataContainerStats = stats;
        }
예제 #4
0
        public static void WriteStatsToStore(DataContainerStats stats, string storageRoot)
        {
            if (string.IsNullOrEmpty(storageRoot))
            {
                throw new ArgumentNullException(storageRoot);
            }

            if (stats == null)
            {
                throw new ArgumentNullException("stats");
            }

            Directory.CreateDirectory(storageRoot);

            var file = new DataContainerStatsFile(RamDriverFactory.CurrentStoreVersion(), stats);

            using (var writer = new StreamWriter(
                       new FileStream(Path.Combine(storageRoot, "stats.json"), FileMode.Create, FileAccess.ReadWrite)))
            {
                var serializer = new JsonSerializer();
                serializer.Serialize(writer, file);
                writer.Flush();
            }
        }