예제 #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;
		}
예제 #2
0
		bool MemoryBundleSet::has(const dtn::data::BundleID &bundle) const throw ()
		{
			// check bloom-filter first
			if (bundle.isIn(_bf)) {
				// Return true if the bloom-filter is not consistent with
				// the bundles set. This happen if the MemoryBundleSet gets deserialized.
				if (!_consistent) return true;

				bundle_set::iterator iter = _bundles.find(dtn::data::MetaBundle::create(bundle));
				return (iter != _bundles.end());
			}

			return false;
		}