@@ -20,8 +20,8 @@ mod filter_optimizer;
20
20
mod listing_table_builder;
21
21
pub mod stream_schema_provider;
22
22
23
+ use chrono:: NaiveDateTime ;
23
24
use chrono:: { DateTime , Duration , Utc } ;
24
- use chrono:: { NaiveDateTime , TimeZone } ;
25
25
use datafusion:: arrow:: record_batch:: RecordBatch ;
26
26
27
27
use datafusion:: common:: tree_node:: { Transformed , TreeNode , TreeNodeRecursion , TreeNodeVisitor } ;
@@ -38,9 +38,7 @@ use once_cell::sync::Lazy;
38
38
use relative_path:: RelativePathBuf ;
39
39
use serde:: { Deserialize , Serialize } ;
40
40
use serde_json:: { json, Value } ;
41
- use std:: collections:: HashMap ;
42
41
use std:: ops:: Bound ;
43
- use std:: path:: { Path , PathBuf } ;
44
42
use std:: sync:: Arc ;
45
43
use stream_schema_provider:: collect_manifest_files;
46
44
use sysinfo:: System ;
@@ -56,7 +54,7 @@ use crate::event;
56
54
use crate :: handlers:: http:: query:: QueryError ;
57
55
use crate :: metadata:: STREAM_INFO ;
58
56
use crate :: option:: { Mode , CONFIG } ;
59
- use crate :: storage:: { ObjectStorageProvider , ObjectStoreFormat , StorageDir , STREAM_ROOT_DIRECTORY } ;
57
+ use crate :: storage:: { ObjectStorageProvider , ObjectStoreFormat , STREAM_ROOT_DIRECTORY } ;
60
58
use crate :: utils:: time:: TimeRange ;
61
59
pub static QUERY_SESSION : Lazy < SessionContext > =
62
60
Lazy :: new ( || Query :: create_session_context ( CONFIG . storage ( ) ) ) ;
@@ -396,10 +394,6 @@ impl TableScanVisitor {
396
394
pub fn into_inner ( self ) -> Vec < String > {
397
395
self . tables
398
396
}
399
- #[ allow( dead_code) ]
400
- pub fn top ( & self ) -> Option < & str > {
401
- self . tables . first ( ) . map ( |s| s. as_ref ( ) )
402
- }
403
397
}
404
398
405
399
impl TreeNodeVisitor < ' _ > for TableScanVisitor {
@@ -563,47 +557,6 @@ fn table_contains_any_time_filters(
563
557
} )
564
558
}
565
559
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
-
607
560
/// unused for now might need it later
608
561
#[ allow( unused) ]
609
562
pub fn flatten_objects_for_count ( objects : Vec < Value > ) -> Vec < Value > {
@@ -671,16 +624,6 @@ mod tests {
671
624
672
625
use crate :: query:: flatten_objects_for_count;
673
626
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
-
684
627
#[ test]
685
628
fn test_flat_simple ( ) {
686
629
let val = vec ! [
0 commit comments