Ejemplo n.º 1
0
 public static void DropIndexData(SqlConnection conn, string bingo_schema, BingoIndexID id, bool throw_if_not_exists)
 {
     lock (index_data_list_lock)
     {
         _DropIndexData(conn, bingo_schema, id, throw_if_not_exists);
     }
 }
Ejemplo n.º 2
0
        public static BingoIndexData CreateIndexData(int spid, SqlConnection conn, string bingo_schema,
                                                     string table, string id_column, string data_column, bool reaction)
        {
            lock (index_data_list_lock)
            {
                BingoIndexID id = new BingoIndexID(conn, table);
                _DropIndexData(conn, bingo_schema, id, false);

                BingoIndexData data;

                if (reaction)
                {
                    data = new RingoIndexData(id, id_column, data_column, bingo_schema);
                }
                else
                {
                    data = new MangoIndexData(id, id_column, data_column, bingo_schema);
                }

                BingoSqlUtils.ExecNonQuery(conn,
                                           "INSERT INTO {0} VALUES({1}, {2}, '{3}', '{4}', '{5}', '{6}')",
                                           _contextTable(bingo_schema), id.table_id, id.database_id, id.FullTableName(conn),
                                           id_column, data_column,
                                           reaction ? "reaction" : "molecule");

                data.CreateTables(conn);
                _AddIndexDataToList(spid, data);

                BingoLog.logMessage("Bingo index for table {0} has been initialized", id.FullTableName(conn));

                return(data);
            }
        }
Ejemplo n.º 3
0
        private static void _DropIndexData(SqlConnection conn, string bingo_schema,
                                           BingoIndexID id, bool throw_if_not_exists)
        {
            BingoIndexData data = _extractIndexData(conn, bingo_schema, id, throw_if_not_exists);

            if (data != null)
            {
                data.DropTables(conn);
                data.DropTriggers(conn);
            }

            BingoSqlUtils.ExecNonQueryNoThrow(conn, "DELETE FROM {0} WHERE obj_id = '{1}'",
                                              _contextTable(bingo_schema), id.table_id);

            for (int i = index_data_list.Count - 1; i >= 0; i--)
            {
                BingoIndexDataRefs refs = (BingoIndexDataRefs)index_data_list[i];
                if (refs.index_data.id.Equals(id))
                {
                    index_data_list.RemoveAt(i);
                    BingoLog.logMessage("Sessions for table {0} have been released", id.InformationName(conn));
                }
            }
            if (data != null)
            {
                BingoLog.logMessage("Bingo index for table {0} has been dropped", id.InformationName(conn));
            }
        }
Ejemplo n.º 4
0
        public static BingoIndexData GetIndexData(SqlConnection conn, string bingo_schema,
                                                  string table, int spid)
        {
            BingoIndexID id = new BingoIndexID(conn, table);

            return(GetIndexDataById(conn, bingo_schema, id, spid));
        }
Ejemplo n.º 5
0
        private static BingoIndexData GetIndexDataById(SqlConnection conn, string bingo_schema,
                                                       BingoIndexID id, int spid)
        {
            lock (index_data_list_lock)
            {
                foreach (BingoIndexDataRefs index_data_refs in index_data_list)
                {
                    if (index_data_refs.index_data.id.Equals(id))
                    {
                        if (!index_data_refs.session_ids.Contains(spid))
                        {
                            BingoLog.logMessage("Existing BingoIndexData added for spid={0} table={1}",
                                                spid, id.FullTableName(conn));
                            index_data_refs.session_ids.Add(spid);
                        }
                        return(index_data_refs.index_data);
                    }
                }

                BingoLog.logMessage("Extracting new BingoIndexData for spid={0} table={1}",
                                    spid, id.FullTableName(conn));

                BingoIndexData data = _extractIndexData(conn, bingo_schema, id, true);
                _AddIndexDataToList(spid, data);

                return(data);
            }
        }
Ejemplo n.º 6
0
      public BingoIndexData (BingoIndexID id, string id_column, string data_column, string bingo_schema)
      {
         this.id = id;
         this.id_column = id_column;
         this.data_column = data_column;
         this.bingo_schema = bingo_schema;

         keep_cache = false;

         fingerprints = new BingoFingerprints(this);
         storage = new BingoStorage(this);
      }
Ejemplo n.º 7
0
        public BingoIndexData(BingoIndexID id, string id_column, string data_column, string bingo_schema)
        {
            this.id           = id;
            this.id_column    = id_column;
            this.data_column  = data_column;
            this.bingo_schema = bingo_schema;

            keep_cache = false;

            fingerprints = new BingoFingerprints(this);
            storage      = new BingoStorage(this);
        }
Ejemplo n.º 8
0
        private static BingoIndexData _extractIndexData(SqlConnection conn, string bingo_schema,
                                                        BingoIndexID id, bool throw_if_not_exists)
        {
            BingoIndexData data = null;

            using (SqlCommand cmd = new SqlCommand(String.Format(
                                                       "SELECT id_column, data_column, type FROM {0} WHERE obj_id = '{1}'",
                                                       _contextTable(bingo_schema), id.table_id), conn))
            {
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        if (throw_if_not_exists)
                        {
                            throw new Exception("Cannot find Bingo index for table with id=" + id.table_id);
                        }
                        else
                        {
                            return(null);
                        }
                    }

                    string id_column   = Convert.ToString(reader[0]);
                    string data_column = Convert.ToString(reader[1]);
                    string type        = Convert.ToString(reader[2]);

                    if (type.ToLower().Equals("molecule"))
                    {
                        data = new MangoIndexData(id, id_column, data_column, bingo_schema);
                    }
                    if (type.ToLower().Equals("reaction"))
                    {
                        data = new RingoIndexData(id, id_column, data_column, bingo_schema);
                    }

                    if (data == null)
                    {
                        throw new Exception("unknown type: " + type);
                    }
                }
            }

            data.keep_cache =
                (BingoConfig.getInt(conn, bingo_schema, "KEEP_CACHE", id.table_id) != 0);

            return(data);
        }
Ejemplo n.º 9
0
      private static BingoIndexData _extractIndexData (SqlConnection conn, string bingo_schema, 
         BingoIndexID id, bool throw_if_not_exists)
      {
         BingoIndexData data = null;

         using (SqlCommand cmd = new SqlCommand(String.Format(
            "SELECT id_column, data_column, type FROM {0} WHERE obj_id = '{1}'",
            _contextTable(bingo_schema), id.table_id), conn))
         {
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
               if (!reader.Read())
               {
                  if (throw_if_not_exists)
                     throw new Exception("Cannot find Bingo index for table with id=" + id.table_id);
                  else
                     return null;
               }

               string id_column = Convert.ToString(reader[0]);
               string data_column = Convert.ToString(reader[1]);
               string type = Convert.ToString(reader[2]);

               if (type.ToLower().Equals("molecule"))
                  data = new MangoIndexData(id, id_column, data_column, bingo_schema);
               if (type.ToLower().Equals("reaction"))
                  data = new RingoIndexData(id, id_column, data_column, bingo_schema);

               if (data == null)
                  throw new Exception("unknown type: " + type);

            }
         }

         data.keep_cache =
            (BingoConfig.getInt(conn, bingo_schema, "KEEP_CACHE", id.table_id) != 0);

         return data;
      }
Ejemplo n.º 10
0
 public bool Equals(BingoIndexID other)
 {
     return(table_id == other.table_id && database_id == other.database_id);
 }
Ejemplo n.º 11
0
      private static void _DropIndexData (SqlConnection conn, string bingo_schema, 
         BingoIndexID id, bool throw_if_not_exists)
      {
         BingoIndexData data = _extractIndexData(conn, bingo_schema, id, throw_if_not_exists);
         if (data != null)
         {
            data.DropTables(conn);
            data.DropTriggers(conn);
         }

         BingoSqlUtils.ExecNonQueryNoThrow(conn, "DELETE FROM {0} WHERE obj_id = '{1}'",
            _contextTable(bingo_schema), id.table_id);

         for (int i = index_data_list.Count - 1; i >= 0; i--)
         {
            BingoIndexDataRefs refs = (BingoIndexDataRefs)index_data_list[i];
            if (refs.index_data.id.Equals(id))
            {
               index_data_list.RemoveAt(i);
               BingoLog.logMessage("Sessions for table {0} have been released", id.InformationName(conn));
            }
         }
         if (data != null)
            BingoLog.logMessage("Bingo index for table {0} has been dropped", id.InformationName(conn));
      }
Ejemplo n.º 12
0
 public static BingoIndexData GetIndexData (SqlConnection conn, string bingo_schema, 
    string table, int spid)
 {
    BingoIndexID id = new BingoIndexID(conn, table);
    return GetIndexDataById(conn, bingo_schema, id, spid);
 }
Ejemplo n.º 13
0
      private static BingoIndexData GetIndexDataById (SqlConnection conn, string bingo_schema, 
         BingoIndexID id, int spid)
      {
         lock (index_data_list_lock)
         {
            foreach (BingoIndexDataRefs index_data_refs in index_data_list)
            {
               if (index_data_refs.index_data.id.Equals(id))
               {
                  if (!index_data_refs.session_ids.Contains(spid))
                  {
                     BingoLog.logMessage("Existing BingoIndexData added for spid={0} table={1}",
                        spid, id.FullTableName(conn));
                     index_data_refs.session_ids.Add(spid);
                  }
                  return index_data_refs.index_data;
               }
            }

            BingoLog.logMessage("Extracting new BingoIndexData for spid={0} table={1}",
               spid, id.FullTableName(conn));

            BingoIndexData data = _extractIndexData(conn, bingo_schema, id, true);
            _AddIndexDataToList(spid, data);

            return data;
         }
      }
Ejemplo n.º 14
0
        public static void DropIndexData(SqlConnection conn, string bingo_schema, string table, bool throw_if_not_exists)
        {
            BingoIndexID id = new BingoIndexID(conn, table);

            DropIndexData(conn, bingo_schema, id, throw_if_not_exists);
        }
Ejemplo n.º 15
0
 public static void DropIndexData (SqlConnection conn, string bingo_schema, BingoIndexID id, bool throw_if_not_exists)
 {
    lock (index_data_list_lock)
    {
       _DropIndexData(conn, bingo_schema, id, throw_if_not_exists);
    }
 }
Ejemplo n.º 16
0
      private static IEnumerable CheckChemicalTable (SqlString table, SqlString id_column,
                 SqlString data_column, SqlString bingo_schema, bool is_reaction)
      {
         BingoLog.logMessage("Checking chemical table {0}", table.Value);
         using (BingoSession session = new BingoSession())
         {
            using (SqlConnection conn = new SqlConnection("context connection=true"))
            {
               conn.Open();
               prepareContext(conn, bingo_schema.Value, 0,
                  ContextFlags.NTHREADS | ContextFlags.FINGERPRINTS);

               BingoIndexID id = new BingoIndexID(conn, table.Value);
               BingoIndexData dummy_data;
               if (is_reaction)
                  dummy_data = new RingoIndexData(id, id_column.Value, data_column.Value, bingo_schema.Value);
               else
                  dummy_data = new MangoIndexData(id, id_column.Value, data_column.Value, bingo_schema.Value);

               ArrayList errors = new ArrayList();

               bingoOperationDelegate check_insert_op =
                  getInsertRecordsDelegate(table.Value, false, false, false, errors);
               if (BingoCore.lib.bingoIndexBegin() != 1)
                  throw new Exception(BingoCore.lib.bingoGetError());
               BingoCore.lib.bingoIndexSetSkipFP(true);
               check_insert_op(conn, conn, dummy_data);
               BingoCore.lib.bingoIndexEnd();

               return errors;
            }
         }
      }
Ejemplo n.º 17
0
      public static BingoIndexData CreateIndexData (int spid, SqlConnection conn, string bingo_schema,
                      string table, string id_column, string data_column, bool reaction)
      {
         lock (index_data_list_lock)
         {
            BingoIndexID id = new BingoIndexID(conn, table);
            _DropIndexData(conn, bingo_schema, id, false);

            BingoIndexData data;

            if (reaction)
               data = new RingoIndexData(id, id_column, data_column, bingo_schema);
            else
               data = new MangoIndexData(id, id_column, data_column, bingo_schema);

            BingoSqlUtils.ExecNonQuery(conn,
               "INSERT INTO {0} VALUES({1}, {2}, '{3}', '{4}', '{5}', '{6}')",
               _contextTable(bingo_schema), id.table_id, id.database_id, id.FullTableName(conn),
               id_column, data_column,
               reaction ? "reaction" : "molecule");

            data.CreateTables(conn);
            _AddIndexDataToList(spid, data);

            BingoLog.logMessage("Bingo index for table {0} has been initialized", id.FullTableName(conn));

            return data;
         }
      }
Ejemplo n.º 18
0
 public bool Equals (BingoIndexID other)
 {
    return table_id == other.table_id && database_id == other.database_id;
 }
Ejemplo n.º 19
0
 public RingoIndexData(BingoIndexID id, string id_column, string data_column, string bingo_schema) :
     base(id, id_column, data_column, bingo_schema)
 {
 }
Ejemplo n.º 20
0
 public MangoIndexData (BingoIndexID id, string id_column, string data_column, string bingo_schema) :
    base(id, id_column, data_column, bingo_schema)
 {
 }
Ejemplo n.º 21
0
 public static void _DropIndexByID (SqlInt32 table_id, SqlInt32 database_id, SqlString bingo_schema)
 {
    using (SqlConnection conn = new SqlConnection("context connection=true"))
    {
       conn.Open();
       BingoIndexID id = new BingoIndexID(table_id.Value, database_id.Value);
       BingoIndexData.DropIndexData(conn, bingo_schema.Value, id, false);
    }
 }
Ejemplo n.º 22
0
 public static void DropIndexData (SqlConnection conn, string bingo_schema, string table, bool throw_if_not_exists)
 {
    BingoIndexID id = new BingoIndexID(conn, table);
    DropIndexData(conn, bingo_schema, id, throw_if_not_exists);
 }