def make_sample_query_from_filter(sample_filter, require_meter=True):
 meter = sample_filter.meter
 if ((not meter) and require_meter):
  raise RuntimeError('Missing required meter specifier')
 (start_row, end_row, ts_query) = make_timestamp_query(make_general_rowkey_scan, start=sample_filter.start_timestamp, start_op=sample_filter.start_timestamp_op, end=sample_filter.end_timestamp, end_op=sample_filter.end_timestamp_op, some_id=meter)
 kwargs = dict(user_id=sample_filter.user, project_id=sample_filter.project, counter_name=meter, resource_id=sample_filter.resource, source=sample_filter.source, message_id=sample_filter.message_id)
 q = make_query(metaquery=sample_filter.metaquery, **kwargs)
 if q:
  res_q = (((q + ' AND ') + ts_query) if ts_query else q)
 else:
  res_q = (ts_query if ts_query else None)
 need_timestamp = ((sample_filter.start_timestamp or sample_filter.end_timestamp) is not None)
 columns = get_meter_columns(metaquery=sample_filter.metaquery, need_timestamp=need_timestamp, **kwargs)
 return (res_q, start_row, end_row, columns)

def make_sample_query_from_filter ( sample_filter , require_meter = True ) : meter = sample_filter . meter if ( ( not meter ) and require_meter ) : raise RuntimeError ( 'Missing required meter specifier' ) ( start_row , end_row , ts_query ) = make_timestamp_query ( make_general_rowkey_scan , start = sample_filter . start_timestamp , start_op = sample_filter . start_timestamp_op , end = sample_filter . end_timestamp , end_op = sample_filter . end_timestamp_op , some_id = meter ) kwargs = dict ( user_id = sample_filter . user , project_id = sample_filter . project , counter_name = meter , resource_id = sample_filter . resource , source = sample_filter . source , message_id = sample_filter . message_id ) q = make_query ( metaquery = sample_filter . metaquery , ** kwargs ) if q : res_q = ( ( ( q + ' AND ' ) + ts_query ) if ts_query else q ) else : res_q = ( ts_query if ts_query else None ) need_timestamp = ( ( sample_filter . start_timestamp or sample_filter . end_timestamp ) is not None ) columns = get_meter_columns ( metaquery = sample_filter . metaquery , need_timestamp = need_timestamp , ** kwargs ) return ( res_q , start_row , end_row , columns )
return a query dictionary based on the settings in the filter .