@@ -20,8 +20,8 @@ mod filter_optimizer;
2020mod listing_table_builder;
2121pub mod stream_schema_provider;
2222
23+ use chrono:: NaiveDateTime ;
2324use chrono:: { DateTime , Duration , Utc } ;
24- use chrono:: { NaiveDateTime , TimeZone } ;
2525use datafusion:: arrow:: record_batch:: RecordBatch ;
2626
2727use datafusion:: common:: tree_node:: { Transformed , TreeNode , TreeNodeRecursion , TreeNodeVisitor } ;
@@ -38,9 +38,7 @@ use once_cell::sync::Lazy;
3838use relative_path:: RelativePathBuf ;
3939use serde:: { Deserialize , Serialize } ;
4040use serde_json:: { json, Value } ;
41- use std:: collections:: HashMap ;
4241use std:: ops:: Bound ;
43- use std:: path:: { Path , PathBuf } ;
4442use std:: sync:: Arc ;
4543use stream_schema_provider:: collect_manifest_files;
4644use sysinfo:: System ;
@@ -56,7 +54,7 @@ use crate::event;
5654use crate :: handlers:: http:: query:: QueryError ;
5755use crate :: metadata:: STREAM_INFO ;
5856use crate :: option:: { Mode , CONFIG } ;
59- use crate :: storage:: { ObjectStorageProvider , ObjectStoreFormat , StorageDir , STREAM_ROOT_DIRECTORY } ;
57+ use crate :: storage:: { ObjectStorageProvider , ObjectStoreFormat , STREAM_ROOT_DIRECTORY } ;
6058use crate :: utils:: time:: TimeRange ;
6159pub static QUERY_SESSION : Lazy < SessionContext > =
6260 Lazy :: new ( || Query :: create_session_context ( CONFIG . storage ( ) ) ) ;
@@ -396,10 +394,6 @@ impl TableScanVisitor {
396394 pub fn into_inner ( self ) -> Vec < String > {
397395 self . tables
398396 }
399- #[ allow( dead_code) ]
400- pub fn top ( & self ) -> Option < & str > {
401- self . tables . first ( ) . map ( |s| s. as_ref ( ) )
402- }
403397}
404398
405399impl TreeNodeVisitor < ' _ > for TableScanVisitor {
@@ -563,47 +557,6 @@ fn table_contains_any_time_filters(
563557 } )
564558}
565559
566- #[ allow( dead_code) ]
567- fn get_staging_prefixes (
568- stream_name : & str ,
569- start : DateTime < Utc > ,
570- end : DateTime < Utc > ,
571- ) -> HashMap < PathBuf , Vec < PathBuf > > {
572- let dir = StorageDir :: new ( stream_name) ;
573- let mut files = dir. arrow_files_grouped_by_time ( ) ;
574- files. retain ( |k, _| path_intersects_query ( k, start, end) ) ;
575- files
576- }
577-
578- fn path_intersects_query ( path : & Path , starttime : DateTime < Utc > , endtime : DateTime < Utc > ) -> bool {
579- let time = time_from_path ( path) ;
580- starttime <= time && time <= endtime
581- }
582-
583- fn time_from_path ( path : & Path ) -> DateTime < Utc > {
584- let prefix = path
585- . file_name ( )
586- . expect ( "all given path are file" )
587- . to_str ( )
588- . expect ( "filename is valid" ) ;
589-
590- // Next three in order will be date, hour and minute
591- let mut components = prefix. splitn ( 3 , '.' ) ;
592-
593- let date = components. next ( ) . expect ( "date=xxxx-xx-xx" ) ;
594- let hour = components. next ( ) . expect ( "hour=xx" ) ;
595- let minute = components. next ( ) . expect ( "minute=xx" ) ;
596-
597- let year = date[ 5 ..9 ] . parse ( ) . unwrap ( ) ;
598- let month = date[ 10 ..12 ] . parse ( ) . unwrap ( ) ;
599- let day = date[ 13 ..15 ] . parse ( ) . unwrap ( ) ;
600- let hour = hour[ 5 ..7 ] . parse ( ) . unwrap ( ) ;
601- let minute = minute[ 7 ..9 ] . parse ( ) . unwrap ( ) ;
602-
603- Utc . with_ymd_and_hms ( year, month, day, hour, minute, 0 )
604- . unwrap ( )
605- }
606-
607560/// unused for now might need it later
608561#[ allow( unused) ]
609562pub fn flatten_objects_for_count ( objects : Vec < Value > ) -> Vec < Value > {
@@ -671,16 +624,6 @@ mod tests {
671624
672625 use crate :: query:: flatten_objects_for_count;
673626
674- use super :: time_from_path;
675- use std:: path:: PathBuf ;
676-
677- #[ test]
678- fn test_time_from_parquet_path ( ) {
679- let path = PathBuf :: from ( "date=2022-01-01.hour=00.minute=00.hostname.data.parquet" ) ;
680- let time = time_from_path ( path. as_path ( ) ) ;
681- assert_eq ! ( time. timestamp( ) , 1640995200 ) ;
682- }
683-
684627 #[ test]
685628 fn test_flat_simple ( ) {
686629 let val = vec ! [
0 commit comments