public void AppendStatistics(StoreStatistics statistics)
 {
     using (
         var headerWriter =
             new BinaryWriter(_persistenceManager.GetOutputStream(GetStatisticsHeaderFile(), FileMode.Append)))
     {
         using (
             var recordWriter =
                 new StreamWriter(_persistenceManager.GetOutputStream(GetStatisticsLogFile(),
                                                                      FileMode.Append)))
         {
             var recordStart = recordWriter.BaseStream.Position;
             var record = new StoreStatisticsRecord(statistics.CommitNumber, statistics.TripleCount,
                                                    statistics.PredicateTripleCounts);
             var header = new StoreStatisticsHeaderRecord(statistics.CommitNumber, statistics.CommitTime,
                                                          recordStart);
             record.Save(recordWriter);
             header.Save(headerWriter);
             recordWriter.Flush();
             headerWriter.Flush();
             recordWriter.Close();
             headerWriter.Close();
         }
     }
 }
Esempio n. 2
0
 public void AppendStatistics(StoreStatistics statistics)
 {
     using (
         var headerWriter =
             new BinaryWriter(_persistenceManager.GetOutputStream(GetStatisticsHeaderFile(), FileMode.Append)))
     {
         using (
             var recordWriter =
                 new StreamWriter(_persistenceManager.GetOutputStream(GetStatisticsLogFile(),
                                                                      FileMode.Append)))
         {
             var recordStart = recordWriter.BaseStream.Position;
             var record      = new StoreStatisticsRecord(statistics.CommitNumber, statistics.TripleCount,
                                                         statistics.PredicateTripleCounts);
             var header = new StoreStatisticsHeaderRecord(statistics.CommitNumber, statistics.CommitTime,
                                                          recordStart);
             record.Save(recordWriter);
             header.Save(headerWriter);
             recordWriter.Flush();
             headerWriter.Flush();
             recordWriter.Close();
             headerWriter.Close();
         }
     }
 }
Esempio n. 3
0
        public static StoreStatisticsHeaderRecord Load(BinaryReader dataStream)
        {
            var ret = new StoreStatisticsHeaderRecord();

            ret.Read(dataStream);
            return(ret);
        }
Esempio n. 4
0
        public IEnumerable <StoreStatistics> GetStatistics()
        {
            if (!_persistenceManager.FileExists(GetStatisticsHeaderFile()))
            {
                yield break;
            }
            using (var headerStream = _persistenceManager.GetInputStream(GetStatisticsHeaderFile()))
            {
                using (var headerReader = new BinaryReader(headerStream))
                {
                    using (
                        var recordStream =
                            _persistenceManager.GetInputStream(GetStatisticsLogFile()))
                    {
                        long offset = headerStream.Length - StoreStatisticsHeaderRecord.RecordSize;
                        while (offset >= 0)
                        {
                            headerReader.BaseStream.Seek(offset, SeekOrigin.Begin);
                            var header = StoreStatisticsHeaderRecord.Load(headerReader);
                            recordStream.Seek(header.StartOffset, SeekOrigin.Begin);
                            var recordReader = new StreamReader(recordStream);
                            var record       = StoreStatisticsRecord.Load(recordReader);
                            yield return
                                (new StoreStatistics(header.CommitNumber, header.Timestamp, record.TotalTripleCount,
                                                     record.PredicateTripleCounts));

                            offset -= StoreStatisticsHeaderRecord.RecordSize;
                        }
                    }
                }
            }
        }
 public static StoreStatisticsHeaderRecord Load(BinaryReader dataStream)
 {
     var ret = new StoreStatisticsHeaderRecord();
     ret.Read(dataStream);
     return ret;
 }