コード例 #1
0
ファイル: BingoFingerprints.cs プロジェクト: yfyh2013/indigo
        IEnumerable <BitChunk> bitChunksReaderGrouped(SqlConnection conn, Block block,
                                                      List <int> bits, int size)
        {
            int offset = 0;

            while (offset < bits.Count)
            {
                int cur_size = size;
                if (offset + cur_size >= bits.Count)
                {
                    cur_size = bits.Count - offset;
                }

                StringBuilder indices = new StringBuilder();
                for (int i = offset; i < offset + cur_size; i++)
                {
                    if (indices.Length != 0)
                    {
                        indices.Append(", ");
                    }
                    indices.AppendFormat("{0}", bits[i]);
                }

                string command_text = String.Format("select bit, bits_chunk from {0} where part={1} and bit in ({2})",
                                                    _index_data.fingerprintBitsTable, block.part, indices.ToString());

                using (SqlCommand command = new SqlCommand(command_text, conn))
                {
                    command.CommandTimeout = 3600;
                    BingoTimer timer = new BingoTimer("fingerprints.read_grouped_exec");
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        timer.end();

                        while (true)
                        {
                            timer = new BingoTimer("fingerprints.read_grouped_read");
                            bool ret = reader.Read();
                            if (!ret)
                            {
                                break;
                            }

                            BitChunk bit_chunk = new BitChunk();
                            int      bit       = (int)reader[0];
                            bit_chunk.bit_index = bit;
                            bit_chunk.chunk     = (byte[])reader[1];

                            timer.end();
                            yield return(bit_chunk);
                        }
                    }
                }

                offset += size;
            }
        }
コード例 #2
0
      IEnumerable<BitChunk> bitChunksReaderGrouped (SqlConnection conn, Block block, 
         List<int> bits, int size)
      {
         int offset = 0;
         while (offset < bits.Count)
         {
            int cur_size = size;
            if (offset + cur_size >= bits.Count)
               cur_size = bits.Count - offset;

            StringBuilder indices = new StringBuilder();
            for (int i = offset; i < offset + cur_size; i++)
            {
               if (indices.Length != 0)
                  indices.Append(", ");
               indices.AppendFormat("{0}", bits[i]);
            }

            string command_text = String.Format("select bit, bits_chunk from {0} where part={1} and bit in ({2})",
               _index_data.fingerprintBitsTable, block.part, indices.ToString());

            using (SqlCommand command = new SqlCommand(command_text, conn))
            {
               command.CommandTimeout = 3600;
               BingoTimer timer = new BingoTimer("fingerprints.read_grouped_exec");
               using (SqlDataReader reader = command.ExecuteReader())
               {
                  timer.end();

                  while (true)
                  {
                     timer = new BingoTimer("fingerprints.read_grouped_read");
                     bool ret = reader.Read();
                     if (!ret)
                        break;

                     BitChunk bit_chunk = new BitChunk();
                     int bit = (int)reader[0];
                     bit_chunk.bit_index = bit;
                     bit_chunk.chunk = (byte[])reader[1];

                     timer.end();
                     yield return bit_chunk;

                  }
               }
            }

            offset += size;
         }
      }