public string Should_find_parition_hi_lo(string startStr, string endStr) { var iter = CreateIterator(); var partitions = CreatePartitions(new DateTime(2014, 04, 01), new DateTime(2014, 04, 02), 1, TimeSpan.FromHours(1)); var start = ToDateTime(startStr); var end = ToDateTime(endStr); DateInterval di = DateInterval.Any; if (start != null && end != null) { di = new DateInterval(start.Value, end.Value); } else if (start != null) { di = DateInterval.From(start.Value); } else if (end != null) { di = DateInterval.To(end.Value); } var resultIter = iter.IteratePartitions(partitions, di, _tx); return(string.Join(",", resultIter.Select(p => string.Format("{0}-{1}", p.Low, p.High)))); }
private ResultSetBuilder EvaluateCompare(Expression exp) { var memberName = ExHelper.GetMemberName(exp, _itemType); var literal = ExHelper.GetLiteralValue(exp, _parameters); var columnMetadata = GetTimestamp(_journal.Metadata); if (columnMetadata != null && string.Equals(columnMetadata.PropertyName, memberName, StringComparison.OrdinalIgnoreCase) && (literal is long || literal is DateTime)) { DateInterval filterInterval; var nodeType = exp.NodeType; if (exp.GetLeft().NodeType == ExpressionType.Constant) { nodeType = InvertComarison(nodeType); } switch (nodeType) { case ExpressionType.GreaterThan: var timestamp = literal is long ?DateUtils.UnixTimestampToDateTime((long)literal + 1) : ((DateTime)literal).AddTicks(1); filterInterval = DateInterval.From(timestamp); break; case ExpressionType.GreaterThanOrEqual: timestamp = literal is long ?DateUtils.UnixTimestampToDateTime((long)literal) : (DateTime)literal; filterInterval = DateInterval.From(timestamp); break; case ExpressionType.LessThan: timestamp = literal is long ?DateUtils.UnixTimestampToDateTime((long)literal) : (DateTime)literal; filterInterval = DateInterval.To(timestamp); break; case ExpressionType.LessThanOrEqual: timestamp = literal is long ?DateUtils.UnixTimestampToDateTime((long)literal + 1) : ((DateTime)literal).AddTicks(1); filterInterval = DateInterval.To(timestamp); break; default: throw QueryExceptionExtensions.ExpressionNotSupported(string.Format( "Timestamp column operation {0} is not supported. Supported operations are <, >, <=, >=", nodeType), exp); } var result = new ResultSetBuilder(_journal, _tx); result.TimestampInterval(filterInterval); return(result); } throw QueryExceptionExtensions.ExpressionNotSupported( "Comparison is supported for timestamp column only. Unable to bind '{0} to journal query operation", exp); }