Пример #1
0
        private void ReadCallback(IAsyncResult ar)
        {
            ReadInfo info = ar.AsyncState as ReadInfo;

            int read = 0;

            try
            {
                read = info.Stream.EndRead(ar);
            } catch (IOException ex)
            {
                throw new Exception("Read Error", ex);
            }

            string data = EncodingHelper.GetString(info.Buffer, 0, read);

            if (Protocol == null)
            {
                throw new Exception("No Protocol Set, (Use BaseProtocol.MakeConnection)");
            }

            Protocol.DataReceived(data);

            Read(info);
        }
Пример #2
0
        void DeserializeContents(ReadInfo info, bool allowCircularDependencies)
        {
            if (info.HasReadContents)
            {
                return;
            }

            Assert.That(info.HasReadConstructor);

            if (!_activeContents.Add(info))
            {
                if (!allowCircularDependencies)
                {
                    Log.Warn("Circular reference while reading contents for '{0}'", info.SerializedType.Name());
                }

                return;
            }

            _groups.Push(info.Element);

            info.Serializer.DeserializeContents(ref info.Value, _version, this);
            info.HasReadContents = true;

            _groups.Pop();

            _activeContents.Remove(info);
        }
Пример #3
0
 /// <summary>
 /// 读写器的类型项
 /// </summary>
 /// <param name="typeID"></param>
 /// <param name="itemType"></param>
 /// <param name="readHandle"></param>
 /// <param name="writerHandle"></param>
 internal MemTypeItem(int typeID, Type itemType, ReadInfo readHandle, WriteInfo writerHandle)
 {
     _typeID       = typeID;
     _itemType     = itemType;
     _readHandle   = readHandle;
     _writerHandle = writerHandle;
 }
Пример #4
0
        static private void WriteToXML(ReadInfo readInfo, string fileName)
        {
            var spocReaderData = readInfo.readerData;

            if (spocReaderData == null)
            {
                return;
            }

            string directoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "ReadData");

            Directory.CreateDirectory(directoryPath);
            var filePath = Path.Combine(directoryPath, fileName);

            //Dummy data
            spocReaderData.Deprime          = 1.ToString();
            spocReaderData.EPPrime          = 2.ToString();
            spocReaderData.RetestWell       = 3.ToString();
            spocReaderData.ClockDevisor     = readInfo.parameters.clockDevisor;
            spocReaderData.NumOfBytesToRead = readInfo.numOfBytesToRead;

            //End of dummy code

            using (FileStream fs = new FileStream(filePath, FileMode.Create))
            {
                System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(spocReaderData.GetType());
                xmlSerializer.Serialize(fs, spocReaderData);
            }
        }
Пример #5
0
        /// <summary>
        /// 添加项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="typeID">分配的ID</param>
        /// <param name="readInfo">读取器</param>
        private static void AddItem <T>(int typeID, ReadInfo readInfo, WriteInfo writeInfo)
        {
            MemTypeItem item = new MemTypeItem(typeID, typeof(T), readInfo, writeInfo);

            _dicMemTypeItem[typeID] = item;
            _dicMemTypeItemByFullName[item.ItemType.FullName] = item;
        }
Пример #6
0
        void DeserializeContents(ReadInfo info, bool allowCircularDependencies)
        {
            if (info.HasReadContents)
            {
                return;
            }

            Assert.That(info.HasReadConstructor);

            if (!_activeContents.Add(info))
            {
                if (!allowCircularDependencies)
                {
                    Log.Warn("Circular reference while reading contents for '{0}'", info.SerializedType.Name());
                }

                return;
            }

            long returnPosition = _binaryReader.BaseStream.Position;

            _binaryReader.BaseStream.Seek(info.ContentsPosition, SeekOrigin.Begin);

            info.Serializer.DeserializeContents(ref info.Value, _version, this);
            info.HasReadContents = true;

            _binaryReader.BaseStream.Seek(returnPosition, SeekOrigin.Begin);

            _activeContents.Remove(info);
        }
Пример #7
0
 /// <summary>
 /// Adds a <see cref="IndexLibrary.ReadInfo"/> to the analysis stack
 /// </summary>
 /// <param name="info">The information being reported.</param>
 public void AddReadInfo(ReadInfo info)
 {
     if (this.trackReads)
     {
         this.reads.Enqueue(info);
     }
 }
Пример #8
0
 void TcpByteReader_ByteReaded(ReadInfo readInfo, int id)
 {
     lock (this)
     {
         clientHandledData.Enqueue(readInfo.NetworkData);
     }
 }
Пример #9
0
        /// <summary>
        /// Fires the specified info to each subscribed <see cref="IAnalysisWriter"/>.
        /// </summary>
        /// <param name="info">The info to pass to each subscriber.</param>
        public static void Fire(ReadInfo info)
        {
            List <IAnalysisWriter> writers = null;

            lock (syncRoot)
                writers = new List <IAnalysisWriter>(analysisWriters);
            if (writers == null)
            {
                return;
            }

            int totalWriters = writers.Count;

            if (totalWriters == 0)
            {
                return;
            }

            if (totalWriters % 2 == 1)
            {
                writers[totalWriters - 1].AddReadInfo(info);
                totalWriters--;
            }

            for (int i = 0; i < totalWriters; i += 2)
            {
                writers[i].AddReadInfo(info);
                writers[i + 1].AddReadInfo(info);
            }
        }
Пример #10
0
        static void Main(string[] args)
        {
            try
            {
                for (int repeat = 1; repeat < 11; repeat++)
                {
                    SpocReaderData          spocReaderData = new SpocReaderData();
                    List <byte>             RawData        = new List <byte>();
                    MpsseDevice.MpsseParams mpsseParams    = new MpsseDevice.MpsseParams();
                    mpsseParams.clockDevisor = 1;
                    UInt16 NumOfBytesToRead = 6500;


                    String csvFilename = "ReadData_" + DateTime.Now.ToString("ddMMMyy--HH.mm.ss") + ".csv";
                    String xmlFilename = "ReadData_" + DateTime.Now.ToString("ddMMMyy--HH.mm.ss") + ".xml";

                    using (var mpsse = new FT2232H("", mpsseParams))
                    {
                        // configure FTDI port for MPSSE Use
                        mpsse.AdaptiveClocking       = false;
                        mpsse.ThreePhaseDataClocking = false;
                        mpsse.ClkDivideBy5           = false;

                        Stopwatch stopWatch = new Stopwatch();
                        stopWatch.Start();

                        while (stopWatch.ElapsedMilliseconds < 5000)
                        {
                            EnableLine(mpsse);
                            var OutputData = mpsse.BytesInOnMinusEdgeWithMsbFirst(NumOfBytesToRead);
                            DisableLine(mpsse);

                            Console.Write(".");
                            RawData.AddRange(OutputData);
                        }

                        int HighBit = 30;
                        List <List <BinData> > ReadBuffer = TruncateData(RawData, HighBit);

                        spocReaderData.RawFocusData = RawData.ToArray();

                        // write to files
                        ReadInfo readInfo = new ReadInfo {
                            readerData = spocReaderData, parameters = mpsseParams, numOfBytesToRead = NumOfBytesToRead
                        };
                        //WriteToCsv(ReadBuffer[0], csvFilename);
                        WriteToXML(readInfo, xmlFilename);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
Пример #11
0
    public override int Read(byte[] buffer, int offset, int count)
    {
        var info = new ReadInfo {
            Position = Position
        };

        info.Count = base.Read(buffer, offset, count);
        ReadInfo.Add(info);
        TotalReadCount += info.Count;
        return(info.Count);
    }
 internal static bool TryGetInfo(string path, out ReadInfo info)
 {
     if (ApkMode)
     {
         return(ApkImpl.TryGetInfo(path, out info));
     }
     else
     {
         return(LooseFilesImpl.TryGetInfo(path, out info));
     }
 }
Пример #13
0
        void byteReader_ByteReaded(ReadInfo readInfo, int id)
        {
            var userInput = readInfo.NetworkData is PingNetworkData;

            readInfo.NetworkData.Id = id;
            Enqueue(readInfo.NetworkData);
            if (userInput)
            {
                lock (userLastUpdatedAt)
                {
                    userLastUpdatedAt[id] = DateTime.Now;
                }
            }
        }
Пример #14
0
 void TcpByteReader_ByteReaded(ReadInfo readInfo, int id)
 {
     if (readInfo.NetworkData is PingNetworkData)
     {
         var pingNetworkData = readInfo.NetworkData as PingNetworkData;
         client.Write(MessagePackSerializer.Serialize(new PingNetworkData {
             Time = pingNetworkData.Time
         }));
     }
     lock (this)
     {
         clientHandledData.Enqueue(readInfo.NetworkData);
     }
 }
        public static bool TryGetInfo(string path, out ReadInfo info)
        {
            path = PathUtil.NormalizeRelativePath(path);

            info = new ReadInfo();

            var fullPath = s_root + path;

            if (!File.Exists(fullPath))
            {
                return(false);
            }

            info.readPath = fullPath;
            return(true);
        }
Пример #16
0
        public object ReadXml()
        {
            var  root   = _doc.Root;
            long rootId = (long)root.GetAttribute("id");

            _version = (int)root.GetAttribute("version");

            Assert.That(_rootReferences.IsEmpty());

            foreach (var element in root.Elements())
            {
                Assert.That(element.Name.LocalName == "Reference");

                var id       = (long)element.GetAttribute("id");
                var typeName = (string)element.GetAttribute("type");

                var info = new ReadInfo();

                info.Element        = element;
                info.SerializedType = SerializerRegistry.ParseSerializedType(typeName);
                info.Serializer     = SerializerRegistry.GetSerializer(info.SerializedType);

                _rootReferences.Add(id, info);
            }

            foreach (var info in _rootReferences.Values)
            {
                DeserializeConstructor(info);
                DeserializeContents(info, false);
            }

            foreach (var info in _rootReferences.Values)
            {
                _groups.Push(info.Element);
                info.Serializer.DeserializeBacklinks(ref info.Value, _version, this);
                _groups.Pop();
            }

            foreach (var info in _rootReferences.Values)
            {
                info.Serializer.DeserializationComplete(ref info.Value, _version);
            }

            return(_rootReferences[rootId].Value);
        }
Пример #17
0
        void DeserializeConstructor(ReadInfo info)
        {
            if (info.HasReadConstructor)
            {
                return;
            }

            Assert.That(_activeConstructors.Add(info),
                        "circular reference while reading constructor for '{0}'",
                        info.SerializedType.Name());

            _groups.Push(info.Element);

            info.Serializer.DeserializeConstructor(out info.Value, _version, this);
            info.HasReadConstructor = true;

            _groups.Pop();

            _activeConstructors.Remove(info);
        }
        public static bool TryGetInfo(string path, out ReadInfo info)
        {
            path = PathUtil.NormalizeRelativePath(path);
            info = new ReadInfo();

            var index = Array.BinarySearch(s_paths, path, StringComparer.OrdinalIgnoreCase);

            if (index < 0)
            {
                return(false);
            }

            var dataInfo = s_streamingAssets[index];

            info.crc32    = dataInfo.crc32;
            info.offset   = dataInfo.offset;
            info.size     = dataInfo.size;
            info.readPath = s_root;
            return(true);
        }
Пример #19
0
        public void SavsReadingInfo()
        {
            FeedInfo info = new FeedInfo();

            info.Sort    = 1;
            info.FeedUrl = "http://www.shisujie.com/rss?containerid=31";

            ReadInfo reading = new ReadInfo();

            reading.Id = "http://www.baidu.com";
            List <ReadInfo> readinglist = new List <ReadInfo>();

            readinglist.Add(reading);
            RSSHandle.SaveReadsInfo(AppDomain.CurrentDomain.BaseDirectory, info, readinglist);

            List <FeedInfo> list = new List <FeedInfo>();

            list.Add(info);

            RSSHandle.SaveFeedToXml(AppDomain.CurrentDomain.BaseDirectory, list);
        }
Пример #20
0
        /// <summary>
        /// Adds <see cref="IndexLibrary.ReadInfo"/> to this summary
        /// </summary>
        /// <param name="info">The info to add.</param>
        public void AddReadInfo(ReadInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info", "info cannot be null");
            }
            if (info.IsEmpty)
            {
                throw new ArgumentNullException("info", "info cannot be empty");
            }

            this.totalReads++;

            if ((info.TotalDocumentsRetrieved > 0) && ((this.features & ReadInfoSummaryFeature.TotalReads) == ReadInfoSummaryFeature.TotalReads))
            {
                this.totalReadsWithResults++;
            }
            if (info.BuiltFiltersOnAllData && ((this.features & ReadInfoSummaryFeature.TotalReadsThatBuiltFiltersOnAllData) == ReadInfoSummaryFeature.TotalReadsThatBuiltFiltersOnAllData))
            {
                this.totalReadsThatBuiltAllFilters++;
            }

            if ((this.features & ReadInfoSummaryFeature.TotalReadsByIndex) == ReadInfoSummaryFeature.TotalReadsByIndex)
            {
                if (!this.totalReadsFromEachIndex.ContainsKey(info.IndexName))
                {
                    this.totalReadsFromEachIndex.Add(info.IndexName, 0);
                }
                this.totalReadsFromEachIndex[info.IndexName]++;
            }
            if ((this.features & ReadInfoSummaryFeature.ReadTimeSpread) == ReadInfoSummaryFeature.ReadTimeSpread)
            {
                DateTime key = new DateTime(info.CreatedTime.Year, info.CreatedTime.Month, info.CreatedTime.Day, info.CreatedTime.Hour, info.CreatedTime.Minute, 0);
                if (!this.readSpread.ContainsKey(key))
                {
                    this.readSpread.Add(key, 0);
                }
                this.readSpread[key]++;
            }
        }
Пример #21
0
        void DeserializeConstructor(ReadInfo info)
        {
            if (info.HasReadConstructor)
            {
                return;
            }

            Assert.That(_activeConstructors.Add(info),
                        "circular reference while reading constructor for '{0}'",
                        info.SerializedType.Name());

            long returnPosition = _binaryReader.BaseStream.Position;

            _binaryReader.BaseStream.Seek(info.ConstructorPosition, SeekOrigin.Begin);

            info.Serializer.DeserializeConstructor(out info.Value, _version, this);
            info.HasReadConstructor = true;

            _binaryReader.BaseStream.Seek(returnPosition, SeekOrigin.Begin);

            _activeConstructors.Remove(info);
        }
        private void ReadCallback(IAsyncResult ar)
        {
            ReadInfo info = ar.AsyncState as ReadInfo;

            int read = 0;

            try
            {
                read = info.Stream.EndRead(ar);
            }
            catch (IOException ex)
            {
                throw new Exception("Read Error", ex);
            }

            string data = EncodingHelper.GetString(info.Buffer, 0, read);

            DataReceived(this, new DataReceivedEventArgs()
            {
                Data = data
            });

            Read(info);
        }
Пример #23
0
 public void Read(ReadInfo info)
 {
     info.Stream.BeginRead(info.Buffer, 0, info.Buffer.Length,
                      new AsyncCallback(ReadCallback), info);
 }
Пример #24
0
        /// <summary>
        /// Adds <see cref="IndexLibrary.ReadInfo"/> to this summary
        /// </summary>
        /// <param name="info">The info to add.</param>
        public void AddReadInfo(ReadInfo info)
        {
            if (info == null) throw new ArgumentNullException("info", "info cannot be null");
            if (info.IsEmpty) throw new ArgumentNullException("info", "info cannot be empty");

            this.totalReads++;

            if ((info.TotalDocumentsRetrieved > 0) && ((this.features & ReadInfoSummaryFeature.TotalReads) == ReadInfoSummaryFeature.TotalReads)) this.totalReadsWithResults++;
            if (info.BuiltFiltersOnAllData && ((this.features & ReadInfoSummaryFeature.TotalReadsThatBuiltFiltersOnAllData) == ReadInfoSummaryFeature.TotalReadsThatBuiltFiltersOnAllData)) this.totalReadsThatBuiltAllFilters++;

            if ((this.features & ReadInfoSummaryFeature.TotalReadsByIndex) == ReadInfoSummaryFeature.TotalReadsByIndex) {
                if (!this.totalReadsFromEachIndex.ContainsKey(info.IndexName)) this.totalReadsFromEachIndex.Add(info.IndexName, 0);
                this.totalReadsFromEachIndex[info.IndexName]++;
            }
            if ((this.features & ReadInfoSummaryFeature.ReadTimeSpread) == ReadInfoSummaryFeature.ReadTimeSpread) {
                DateTime key = new DateTime(info.CreatedTime.Year, info.CreatedTime.Month, info.CreatedTime.Day, info.CreatedTime.Hour, info.CreatedTime.Minute, 0);
                if (!this.readSpread.ContainsKey(key)) this.readSpread.Add(key, 0);
                this.readSpread[key]++;
            }
        }
Пример #25
0
 public override bool ConcurrentReader(ref AdId key, ref AdInput input, ref NumClicks value, ref Output dst, ref ReadInfo readInfo)
 {
     dst.value = value;
     return(true);
 }
Пример #26
0
 public override bool ConcurrentReader(ref MyKey key, ref MyInput input, ref MyValue value, ref MyOutput dst, ref ReadInfo readInfo)
 {
     dst.value = value;
     return(true);
 }
Пример #27
0
 /// <summary>
 /// Adds a <see cref="IndexLibrary.ReadInfo"/> to the analysis stack
 /// </summary>
 /// <param name="info">The information being reported.</param>
 public void AddReadInfo(ReadInfo info)
 {
     if (this.trackReads) this.reads.Enqueue(info);
 }
Пример #28
0
 public override bool SingleReader(ref MyKey key, ref MyInput input, ref MyLargeValue value, ref MyLargeOutput dst, ref ReadInfo readInfo)
 {
     dst.value = value;
     return(true);
 }
Пример #29
0
 public override bool SingleReader(ref MyKey key, ref MyInput input, ref MyValue value, ref MyOutput dst, ref ReadInfo readInfo)
 {
     if (dst == null)
     {
         dst = new MyOutput();
     }
     dst.value = value;
     return(true);
 }
Пример #30
0
 public override bool ConcurrentReader(ref MyValue key, ref MyInput input, ref MyValue value, ref MyOutput dst, ref ReadInfo readInfo)
 {
     if (dst == default)
     {
         dst = new MyOutput();
     }
     dst.value = value;
     return(true);
 }
Пример #31
0
        /// <summary>
        /// The background thread that handles all events and flushing to the database.
        /// </summary>
        private void syncThread_DoWork()
        {
            int partTime       = (int)(this.outputThresholdTime.TotalMilliseconds / 5.0);
            int timeIterations = 0;
            int totalSearches  = this.searches.Count;
            int totalReads     = this.reads.Count;
            int totalWrites    = this.writes.Count;

            while (!this.ending)
            {
                int partTimeCounter = 0;
                while ((partTimeCounter < partTime) && !this.ending)
                {
                    partTimeCounter += 1000;
                    Thread.Sleep(1000);
                    if (this.flush)
                    {
                        break;
                    }
                }
                timeIterations++;

                totalSearches = this.searches.Count;
                totalReads    = this.reads.Count;
                totalWrites   = this.writes.Count;

                if (!this.flush)
                {
                    if ((timeIterations != 5 && totalSearches < this.outputThresholdCount && totalReads < this.outputThresholdCount && totalWrites < this.outputThresholdCount) || this.ending)
                    {
                        continue;
                    }
                }
                timeIterations = 0;
                DateTime now        = DateTime.Now;
                string   path       = Path.Combine(Directory.GetCurrentDirectory(), string.Format("analysis {0}{1}{2}.db", now.Year, now.Month.ToString().PadLeft(2, '0'), now.Day.ToString().PadLeft(2, '0')));
                bool     fileExists = File.Exists(path);
                using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};Version=3", path))) {
                    connection.Open();
                    if (!fileExists)
                    {
                        this.ExecuteQuery("CREATE TABLE SearchAnalysis (Canceled bit, CreateTime varchar(24), IndexName varchar(128), Query varchar(8000), SearchMethodType varchar(6), TotalResults int)", connection);
                        this.ExecuteQuery("CREATE TABLE ReadAnalysis (BuiltFiltersForAllData bit, CreateTime varchar(24), IndexName varchar(128), TotalDocumentsRetrieved int, TotalDocsInIndex int, Optimized bit)", connection);
                        this.ExecuteQuery("CREATE TABLE IndexAnalysis (CreateTime varchar(24), IndexName varchar(512), IndexDirectory varchar(512), Optimized bit, TotalDocuments int)", connection);
                    }

                    System.Text.StringBuilder builder = new System.Text.StringBuilder();

                    // I know it looks weird but its a HUGE performance increase
                    // its 83 so that there are less than 500 parameters input to a command at any given time
                    for (int i = 0; i < totalSearches; i += 83)
                    {
                        int totalToUpdate = totalSearches - i;
                        if (totalToUpdate > 83)
                        {
                            totalToUpdate = 83;
                        }

                        using (SQLiteCommand command = new SQLiteCommand(connection)) {
                            builder.Append("INSERT INTO SearchAnalysis SELECT @canceled, @createdTime, @indexName, @query, @searchMethod, @totalResults ");
                            SearchInfo initialInfo = this.searches.Dequeue();
                            command.Parameters.Add(new SQLiteParameter("@canceled", initialInfo.Canceled));
                            command.Parameters.Add(new SQLiteParameter("@createdTime", initialInfo.CreatedTime.ToString("G")));
                            command.Parameters.Add(new SQLiteParameter("@indexName", initialInfo.IndexName));
                            command.Parameters.Add(new SQLiteParameter("@query", initialInfo.Query));
                            command.Parameters.Add(new SQLiteParameter("@searchMethod", initialInfo.SearchMethodType.ToString()));
                            command.Parameters.Add(new SQLiteParameter("@totalResults", initialInfo.TotalResultsFound));
                            totalToUpdate--;

                            for (int j = 0; j < totalToUpdate; j++)
                            {
                                builder.Append(string.Format("UNION SELECT @canceled{0}, @createdTime{0}, @indexName{0}, @query{0}, @searchMethod{0}, @totalResults{0} ", j.ToString()));
                                SearchInfo info = this.searches.Dequeue();
                                command.Parameters.Add(new SQLiteParameter("@canceled" + j.ToString(), info.Canceled));
                                command.Parameters.Add(new SQLiteParameter("@createdTime" + j.ToString(), info.CreatedTime.ToString("G")));
                                command.Parameters.Add(new SQLiteParameter("@indexName" + j.ToString(), info.IndexName));
                                command.Parameters.Add(new SQLiteParameter("@query" + j.ToString(), info.Query));
                                command.Parameters.Add(new SQLiteParameter("@searchMethod" + j.ToString(), info.SearchMethodType.ToString()));
                                command.Parameters.Add(new SQLiteParameter("@totalResults" + j.ToString(), info.TotalResultsFound));
                            }

                            command.CommandText = builder.ToString();
                            command.ExecuteNonQuery();
                        }
                        builder.Remove(0, builder.Length);
                    }

                    // Again, crazy but lots of performance increase
                    for (int i = 0; i < totalReads; i += 83)
                    {
                        int totalToUpdate = totalReads - i;
                        if (totalToUpdate > 83)
                        {
                            totalToUpdate = 83;
                        }

                        using (SQLiteCommand command = new SQLiteCommand(connection)) {
                            builder.Append("INSERT INTO ReadAnalysis SELECT @builtAllData, @createdTime, @indexName, @totalDocsRetrieved, @totalDocsInIndex, @optimized ");
                            ReadInfo initialInfo = this.reads.Dequeue();
                            command.Parameters.Add(new SQLiteParameter("@builtAllData", initialInfo.BuiltFiltersOnAllData));
                            command.Parameters.Add(new SQLiteParameter("@createdTime", initialInfo.CreatedTime.ToString("G")));
                            command.Parameters.Add(new SQLiteParameter("@indexName", initialInfo.IndexName));
                            command.Parameters.Add(new SQLiteParameter("@totalDocsretrieved", initialInfo.TotalDocumentsRetrieved));
                            command.Parameters.Add(new SQLiteParameter("@totalDocsInIndex", initialInfo.TotalDocumentsInIndex));
                            command.Parameters.Add(new SQLiteParameter("@optimized", initialInfo.IsOptimized));
                            totalToUpdate--;

                            for (int j = 0; j < totalToUpdate; j++)
                            {
                                builder.Append(string.Format("UNION SELECT @builtAllData{0}, @createdTime{0}, @indexName{0}, @totalDocsRetrieved{0}, @totalDocsInIndex{0}, @optimized{0} ", j.ToString()));
                                ReadInfo info = this.reads.Dequeue();
                                command.Parameters.Add(new SQLiteParameter("@builtAllData" + j.ToString(), info.BuiltFiltersOnAllData));
                                command.Parameters.Add(new SQLiteParameter("@createdTime" + j.ToString(), info.CreatedTime.ToString("G")));
                                command.Parameters.Add(new SQLiteParameter("@indexName" + j.ToString(), info.IndexName));
                                command.Parameters.Add(new SQLiteParameter("@totalDocsretrieved" + j.ToString(), info.TotalDocumentsRetrieved));
                                command.Parameters.Add(new SQLiteParameter("@totalDocsInIndex" + j.ToString(), info.TotalDocumentsInIndex));
                                command.Parameters.Add(new SQLiteParameter("@optimized" + j.ToString(), info.IsOptimized));
                            }

                            command.CommandText = builder.ToString();
                            command.ExecuteNonQuery();
                        }

                        builder.Remove(0, builder.Length);
                    }

                    //125
                    for (int i = 0; i < totalWrites; i += 125)
                    {
                        int totalToUpdate = totalWrites - i;
                        if (totalToUpdate > 125)
                        {
                            totalToUpdate = 125;
                        }

                        using (SQLiteCommand command = new SQLiteCommand(connection)) {
                            builder.Append("INSERT INTO IndexAnalysis SELECT @createTime, @indexName, @indexDir, @optimized, @totalDocs ");
                            IndexInfo initialInfo = this.writes.Dequeue();
                            command.Parameters.Add(new SQLiteParameter("@createTime", initialInfo.CreatedTime.ToString("G")));
                            command.Parameters.Add(new SQLiteParameter("@indexName", initialInfo.IndexName));
                            command.Parameters.Add(new SQLiteParameter("@indexDir", initialInfo.IndexDirectory));
                            command.Parameters.Add(new SQLiteParameter("@optimized", initialInfo.Optimized));
                            command.Parameters.Add(new SQLiteParameter("@totalDocs", initialInfo.TotalDocuments));
                            totalToUpdate--;

                            for (int j = 0; j < totalToUpdate; j++)
                            {
                                builder.Append(string.Format("UNION SELECT @createTime{0}, @indexName{0}, @indexDir{0}, @optimized{0}, @totalDocs{0}  ", j.ToString()));
                                IndexInfo info = this.writes.Dequeue();
                                command.Parameters.Add(new SQLiteParameter("@createTime" + j.ToString(), info.CreatedTime.ToString("G")));
                                command.Parameters.Add(new SQLiteParameter("@indexName" + j.ToString(), info.IndexName));
                                command.Parameters.Add(new SQLiteParameter("@indexDir" + j.ToString(), info.IndexDirectory));
                                command.Parameters.Add(new SQLiteParameter("@optimized" + j.ToString(), info.Optimized));
                                command.Parameters.Add(new SQLiteParameter("@totalDocs" + j.ToString(), info.TotalDocuments));
                            }

                            command.CommandText = builder.ToString();
                            command.ExecuteNonQuery();
                        }

                        builder.Remove(0, builder.Length);
                    } // end for
                }     // end using

                this.flush = false;
            }
        }
Пример #32
0
 public override bool ConcurrentReader(ref int key, ref Empty input, ref RefCountedValue value, ref RefCountedValue dst, ref ReadInfo readInfo)
 {
     dst = value;
     return(true);
 }
Пример #33
0
        /// <summary>
        /// Fires the specified info to each subscribed <see cref="IAnalysisWriter"/>.
        /// </summary>
        /// <param name="info">The info to pass to each subscriber.</param>
        public static void Fire(ReadInfo info)
        {
            List<IAnalysisWriter> writers = null;
            lock (syncRoot)
                writers = new List<IAnalysisWriter>(analysisWriters);
            if (writers == null)
                return;

            int totalWriters = writers.Count;
            if (totalWriters == 0)
                return;

            if (totalWriters % 2 == 1) {
                writers[totalWriters - 1].AddReadInfo(info);
                totalWriters--;
            }

            for (int i = 0; i < totalWriters; i += 2) {
                writers[i].AddReadInfo(info);
                writers[i + 1].AddReadInfo(info);
            }
        }
Пример #34
0
 public override bool ConcurrentReader(ref KeyStruct key, ref InputStruct input, ref ValueStruct value, ref OutputStruct dst, ref ReadInfo readInfo)
 {
     Assert.IsFalse(readInfo.RecordInfo.IsNull());
     dst.value = value;
     return(true);
 }