163
public uint32[] find_event_ids (TimeRange time_range,
164
GenericArray<Event> event_templates,
165
uint storage_state, uint max_events, uint result_type,
166
BusName? sender=null) throws EngineError
163
public uint32[] find_event_ids_for_clause (WhereClause where,
164
uint max_events, uint result_type) throws EngineError
169
WhereClause where = new WhereClause (WhereClause.Type.AND);
172
* We are using the unary operator here to tell SQLite to not use
173
* the index on the timestamp column at the first place. This is a
174
* "fix" for (LP: #672965) based on some benchmarks, which suggest
175
* a performance win, but we might not oversee all implications.
176
* (See http://www.sqlite.org/optoverview.html, section 6.0).
177
* -- Markus Korn, 29/11/2010
179
if (time_range.start != 0)
180
where.add (("+timestamp >= %" + int64.FORMAT).printf(
182
if (time_range.end != 0)
183
where.add (("+timestamp <= %" + int64.FORMAT).printf(
186
if (storage_state == StorageState.AVAILABLE ||
187
storage_state == StorageState.NOT_AVAILABLE)
189
where.add ("(subj_storage_state=? OR subj_storage_state IS NULL)",
190
storage_state.to_string ());
192
else if (storage_state != StorageState.ANY)
194
throw new EngineError.INVALID_ARGUMENT(
195
"Unknown storage state '%u'".printf(storage_state));
198
WhereClause tpl_conditions = get_where_clause_from_event_templates (
200
where.extend (tpl_conditions);
201
//if (!where.may_have_results ())
202
// return new uint32[0];
204
166
string sql = "SELECT id FROM event_view ";
205
167
string where_sql = "";
206
168
if (!where.is_empty ())
352
314
return event_ids;
317
public uint32[] find_event_ids (TimeRange time_range,
318
GenericArray<Event> event_templates,
319
uint storage_state, uint max_events, uint result_type,
320
BusName? sender=null) throws EngineError
322
WhereClause where = get_where_clause_for_query (time_range,
323
event_templates, storage_state);
325
//if (!where.may_have_results ())
326
// return new uint32[0];
328
return find_event_ids_for_clause (where, max_events, result_type);
355
331
public GenericArray<Event?> find_events (TimeRange time_range,
356
332
GenericArray<Event> event_templates,
357
333
uint storage_state, uint max_events, uint result_type,
361
337
storage_state, max_events, result_type));
340
public WhereClause get_where_clause_for_query (TimeRange time_range,
341
GenericArray<Event> event_templates, uint storage_state) throws EngineError
343
WhereClause where = new WhereClause (WhereClause.Type.AND);
346
* We are using the unary operator here to tell SQLite to not use
347
* the index on the timestamp column at the first place. This is a
348
* "fix" for (LP: #672965) based on some benchmarks, which suggest
349
* a performance win, but we might not oversee all implications.
350
* (See http://www.sqlite.org/optoverview.html, section 6.0).
351
* -- Markus Korn, 29/11/2010
353
if (time_range.start != 0)
354
where.add (("+timestamp >= %" + int64.FORMAT).printf(
356
if (time_range.end != 0)
357
where.add (("+timestamp <= %" + int64.FORMAT).printf(
360
if (storage_state == StorageState.AVAILABLE ||
361
storage_state == StorageState.NOT_AVAILABLE)
363
where.add ("(subj_storage_state=? OR subj_storage_state IS NULL)",
364
storage_state.to_string ());
366
else if (storage_state != StorageState.ANY)
368
throw new EngineError.INVALID_ARGUMENT(
369
"Unknown storage state '%u'".printf(storage_state));
372
WhereClause tpl_conditions = get_where_clause_from_event_templates (
374
where.extend (tpl_conditions);
364
379
private struct RelatedUri {
365
380
public uint32 id;
366
381
public int64 timestamp;
598
613
// Used by find_event_ids
599
protected WhereClause get_where_clause_from_event_templates (
614
public WhereClause get_where_clause_from_event_templates (
600
615
GenericArray<Event> templates) throws EngineError
602
617
WhereClause where = new WhereClause (WhereClause.Type.OR);