mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-26 09:50:40 +00:00
fix: order by optimization (#1748)
* add some debug log * fix: use lazy parquet reader in MitoTable::scan_to_stream to avoid IO in plan stage * fix: unit tests * fix: order-by optimization * add some tests * fix: move metric names to metrics.rs * fix: some cr comments
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
|
||||
use crate::timestamp::TimeUnit;
|
||||
use crate::timestamp_millis::TimestampMillis;
|
||||
use crate::Timestamp;
|
||||
@@ -193,6 +195,38 @@ impl<T: PartialOrd> GenericRange<T> {
|
||||
|
||||
pub type TimestampRange = GenericRange<Timestamp>;
|
||||
|
||||
impl Display for TimestampRange {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let s = match (&self.start, &self.end) {
|
||||
(Some(start), Some(end)) => {
|
||||
format!(
|
||||
"TimestampRange{{[{}{},{}{})}}",
|
||||
start.value(),
|
||||
start.unit().short_name(),
|
||||
end.value(),
|
||||
end.unit().short_name()
|
||||
)
|
||||
}
|
||||
(Some(start), None) => {
|
||||
format!(
|
||||
"TimestampRange{{[{}{},#)}}",
|
||||
start.value(),
|
||||
start.unit().short_name()
|
||||
)
|
||||
}
|
||||
(None, Some(end)) => {
|
||||
format!(
|
||||
"TimestampRange{{[#,{}{})}}",
|
||||
end.value(),
|
||||
end.unit().short_name()
|
||||
)
|
||||
}
|
||||
(None, None) => "TimestampRange{{[#,#)}}".to_string(),
|
||||
};
|
||||
f.write_str(&s)
|
||||
}
|
||||
}
|
||||
|
||||
impl TimestampRange {
|
||||
/// Create a TimestampRange with optional inclusive end timestamp.
|
||||
/// If end timestamp is present and is less than start timestamp, this method will return
|
||||
|
||||
@@ -336,6 +336,15 @@ impl TimeUnit {
|
||||
TimeUnit::Nanosecond => 1,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn short_name(&self) -> &'static str {
|
||||
match self {
|
||||
TimeUnit::Second => "s",
|
||||
TimeUnit::Millisecond => "ms",
|
||||
TimeUnit::Microsecond => "us",
|
||||
TimeUnit::Nanosecond => "ns",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Timestamp {
|
||||
|
||||
Reference in New Issue
Block a user