void MangoShadowFetch::prepareTautomer (OracleEnv &env, int right_part) { if (right_part == 1) env.dbgPrintf("preparing shadow table for tautomer match\n"); else env.dbgPrintf("preparing shadow table for non-tautomer match\n"); _fetch_type = _TAUTOMER; _right_part = right_part; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_cmf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT mol_rowid, cmf FROM %s", _table_name.ptr()); if (right_part == 1) _statement->append(" WHERE gross = :gross OR gross LIKE :grossh"); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); if (right_part == 1) { ArrayOutput output(_counting_select); output.printf("SELECT COUNT(*) FROM %s WHERE gross = :gross", _table_name.ptr()); } else _counting_select.clear(); }
void MangoShadowFetch::prepareMass (OracleEnv &env) { env.dbgPrintf("preparing shadow table for molecular mass match\n"); QS_DEF(Array<char>, where); { ArrayOutput where_out(where); where_out.printf(""); where_out.writeChar(0); } _fetch_type = _MASS; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _statement->append("SELECT mol_rowid FROM %s WHERE mass >= :mass_min AND mass <= :mass_max", _table_name.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); ArrayOutput output(_counting_select); output.printf("SELECT COUNT(*) FROM %s WHERE WHERE mass >= :mass_min AND mass <= :mass_max", _table_name.ptr()); }
void MangoShadowFetch::prepareNonSubstructure (OracleEnv &env) { env.dbgPrintf("preparing shadow table for non-substructure match\n"); _fetch_type = _NON_SUBSTRUCTURE; _need_xyz = _context.substructure.needCoords(); _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); if (_need_xyz) { _lob_cmf.reset(new OracleLOB(_env.ref())); _lob_xyz.reset(new OracleLOB(_env.ref())); _statement->append("SELECT mol_rowid, cmf, xyz FROM %s", _table_name.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); _statement->defineBlobByPos(3, _lob_xyz.ref()); } else { _lob_cmf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT mol_rowid, cmf FROM %s", _table_name.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); } _counting_select.clear(); }
void RingoShadowFetch::prepareExact (OracleEnv &env, int right_part) { RingoExact & instance = _context.exact; if (right_part == 1) env.dbgPrintf("preparing shadow table for exact\n"); else env.dbgPrintf("preparing shadow table for non-exact\n"); _fetch_type = _EXACT; _right_part = right_part; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_crf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT sh.rid, sh.crf FROM %s sh", _table_name.ptr()); if (right_part == 1) _statement->append(" WHERE hash = :hash"); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_crf.ref()); if (_right_part == 1) { const char *hash_str = instance.getQueryHashStr(); _statement->bindStringByName(":hash", hash_str, strlen(hash_str) + 1); } ArrayOutput output_cnt(_counting_select); output_cnt.printf("SELECT COUNT(*) FROM %s sh", _table_name.ptr()); if (right_part == 1) output_cnt.printf(" WHERE hash = :hash"); }
void MangoShadowFetch::prepareNonTautomerSubstructure (OracleEnv &env) { env.dbgPrintf("preparing shadow table for non-tautomer-substructure match\n"); _fetch_type = _NON_TAUTOMER_SUBSTRUCTURE; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_cmf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT mol_rowid, cmf FROM %s", _table_name.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); _counting_select.clear(); }
void MangoShadowFetch::prepareExact (OracleEnv &env, int right_part) { const MangoExact & instance = _context.exact; if (right_part == 1) env.dbgPrintf("preparing shadow table for exact\n"); else env.dbgPrintf("preparing shadow table for non-exact\n"); _fetch_type = _EXACT; _right_part = right_part; _need_xyz = instance.needCoords(); _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _lob_cmf.reset(new OracleLOB(_env.ref())); _statement->append("SELECT sh.mol_rowid, sh.cmf"); if (_need_xyz) _statement->append(", sh.xyz", _table_name.ptr()); _statement->append(" FROM %s sh", _table_name.ptr()); QS_DEF(Array<char>, table_copies); QS_DEF(Array<char>, where_clause); _prepareExactQueryStrings(table_copies, where_clause); _statement->append(table_copies.ptr()); _statement->append(where_clause.ptr()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineBlobByPos(2, _lob_cmf.ref()); if (_need_xyz) { _lob_xyz.reset(new OracleLOB(_env.ref())); _statement->defineBlobByPos(3, _lob_xyz.ref()); } ArrayOutput output_cnt(_counting_select); output_cnt.printf("SELECT COUNT(*) FROM %s sh", _table_name.ptr()); output_cnt.printf("%s", table_copies.ptr()); output_cnt.printf("%s", where_clause.ptr()); }
void MangoShadowFetch::prepareGross (OracleEnv &env, int right_part) { MangoGross & instance = _context.gross; env.dbgPrintf("preparing shadow table for gross formula match\n"); _fetch_type = _GROSS; _right_part = right_part; _env.reset(new OracleEnv(env.ctx(), env.logger())); _statement.reset(new OracleStatement(_env.ref())); _statement->append("SELECT mol_rowid, gross FROM %s ", _table_name.ptr()); if (*instance.getConditions() != 0 && right_part == 1) _statement->append("WHERE %s", instance.getConditions()); _statement->prepare(); _statement->defineStringByPos(1, _rowid.ptr(), sizeof(_rowid)); _statement->defineStringByPos(2, _gross, sizeof(_gross)); ArrayOutput output(_counting_select); output.printf("SELECT COUNT(*) FROM %s WHERE %s", _table_name.ptr(), instance.getConditions()); }