bool _ringoRegisterReaction (OracleEnv &env, const char *rowid, const Array<char> &reaction_buf, RingoOracleContext &context, RingoIndex &index, BingoFingerprints &fingerprints) { QS_DEF(Array<char>, data); QS_DEF(Array<char>, compressed_rowid); ArrayOutput output(data); output.writeChar(0); // 0 -- present, 1 -- removed from index ArrayOutput rid_output(compressed_rowid); RowIDSaver rid_saver(context.context().rid_dict, rid_output); rid_saver.saveRowID(rowid); output.writeByte((byte)compressed_rowid.size()); output.writeArray(compressed_rowid); TRY_READ_TARGET_RXN { BufferScanner scanner(reaction_buf); try { index.prepare(scanner, output, NULL); } catch (CmfSaver::Error &e) { if (context.context().reject_invalid_structures) throw; // Rethrow this exception further env.dbgPrintf(bad_reaction_warning_rowid, rowid, e.message()); return false; } catch (CrfSaver::Error &e) { if (context.context().reject_invalid_structures) throw; // Rethrow this exception further env.dbgPrintf(bad_reaction_warning_rowid, rowid, e.message()); return false; } } CATCH_READ_TARGET_RXN_ROWID(rowid, { if (context.context().reject_invalid_structures) throw; // Rethrow this exception further return false; });
bool _ringoRegisterReaction (OracleEnv &env, const char *rowid, const Array<char> &reaction_buf, RingoOracleContext &context, RingoIndex &index, BingoFingerprints &fingerprints) { QS_DEF(Array<char>, data); QS_DEF(Array<char>, compressed_rowid); ArrayOutput output(data); output.writeChar(0); // 0 -- present, 1 -- removed from index ArrayOutput rid_output(compressed_rowid); RowIDSaver rid_saver(context.context().rid_dict, rid_output); rid_saver.saveRowID(rowid); output.writeByte((byte)compressed_rowid.size()); output.writeArray(compressed_rowid); TRY_READ_TARGET_RXN { BufferScanner scanner(reaction_buf); try { index.prepare(scanner, output, NULL); } catch (CmfSaver::Error &e) { env.dbgPrintf(bad_reaction_warning_rowid, rowid, e.message()); return false;} catch (CrfSaver::Error &e) { env.dbgPrintf(bad_reaction_warning_rowid, rowid, e.message()); return false;} } CATCH_READ_TARGET_RXN_ROWID(rowid, return false); // some magic: round it up to avoid ora-22282 if (data.size() % 2 == 1) output.writeChar(0); int blockno, offset; context.context().storage.add(env, data, blockno, offset); fingerprints.addFingerprint(env, index.getFingerprint()); context.shadow_table.addReaction(env, index, rowid, blockno + 1, offset); return true; }