Ejemplo n.º 1
0
		bool SQLiteBundleSet::has(const dtn::data::BundleID &id) const throw ()
		{
			// check bloom-filter first
			if (!id.isIn(_bf)) return false;

			// Return true if the bloom-filter is not consistent with
			// the bundles set. This happen if the MemoryBundleSet gets deserialized.
			if (!_consistent) return true;

			try {
				SQLiteDatabase::Statement st( const_cast<sqlite3*>(_sqldb._database), SQLiteDatabase::_sql_queries[SQLiteDatabase::BUNDLE_SET_GET]);

				sqlite3_bind_int64(*st, 1, _set_id);
				sqlite3_bind_text(*st, 2, id.source.getString().c_str(), static_cast<int>(id.source.getString().length()), SQLITE_TRANSIENT);
				sqlite3_bind_int64(*st, 3, id.timestamp.get<uint64_t>());
				sqlite3_bind_int64(*st, 4, id.sequencenumber.get<uint64_t>());

				if (id.isFragment()) {
					sqlite3_bind_int64(*st, 5, id.fragmentoffset.get<uint64_t>());
					sqlite3_bind_int64(*st, 6, id.getPayloadLength());
				} else {
					sqlite3_bind_int64(*st, 5, -1);
					sqlite3_bind_int64(*st, 6, -1);
				}

				if (st.step() == SQLITE_ROW)
					return true;
			} catch (const SQLiteDatabase::SQLiteQueryException&) {
				// error
			}

			return false;
		}
Ejemplo n.º 2
0
		void SQLiteBundleSet::get_bundleid(SQLiteDatabase::Statement &st, dtn::data::BundleID &id, int offset) const throw (SQLiteDatabase::SQLiteQueryException)
		{
			id.source = dtn::data::EID((const char*)sqlite3_column_text(*st, offset + 0));
			id.timestamp = sqlite3_column_int64(*st, offset + 1);
			id.sequencenumber = sqlite3_column_int64(*st, offset + 2);
			dtn::data::Number fragmentoffset = 0;
			id.setFragment(sqlite3_column_int64(*st, offset + 2) >= 0);

			if (id.isFragment()) {
				id.fragmentoffset = sqlite3_column_int64(*st, offset + 3);
				id.setPayloadLength(sqlite3_column_int64(*st, offset + 4));
			} else {
				id.fragmentoffset = 0;
				id.setPayloadLength(0);
			}
		}