@@ -32,7 +32,7 @@ use object_store::{BackoffConfig, ClientOptions, ObjectStore, PutPayload, RetryC
3232use relative_path:: { RelativePath , RelativePathBuf } ;
3333use tracing:: { error, info} ;
3434
35- use std:: collections:: BTreeMap ;
35+ use std:: collections:: { BTreeMap , HashSet } ;
3636use std:: fmt:: Display ;
3737use std:: iter:: Iterator ;
3838use std:: path:: Path as StdPath ;
@@ -43,11 +43,12 @@ use std::time::{Duration, Instant};
4343use super :: metrics_layer:: MetricLayer ;
4444use super :: object_storage:: parseable_json_path;
4545use super :: {
46- ObjectStorageProvider , SCHEMA_FILE_NAME , STREAM_METADATA_FILE_NAME , STREAM_ROOT_DIRECTORY ,
46+ LogStream , ObjectStorageProvider , SCHEMA_FILE_NAME , STREAM_METADATA_FILE_NAME ,
47+ STREAM_ROOT_DIRECTORY ,
4748} ;
4849use crate :: handlers:: http:: users:: USERS_ROOT_DIR ;
4950use crate :: metrics:: storage:: { s3:: REQUEST_RESPONSE_TIME , StorageMetrics } ;
50- use crate :: storage:: { LogStream , ObjectStorage , ObjectStorageError , PARSEABLE_ROOT_DIRECTORY } ;
51+ use crate :: storage:: { ObjectStorage , ObjectStorageError , PARSEABLE_ROOT_DIRECTORY } ;
5152use std:: collections:: HashMap ;
5253
5354// in bytes
@@ -402,8 +403,8 @@ impl S3 {
402403 Ok ( ( ) )
403404 }
404405
405- async fn _list_streams ( & self ) -> Result < Vec < LogStream > , ObjectStorageError > {
406- let mut result_file_list: Vec < LogStream > = Vec :: new ( ) ;
406+ async fn _list_streams ( & self ) -> Result < HashSet < LogStream > , ObjectStorageError > {
407+ let mut result_file_list = HashSet :: new ( ) ;
407408 let resp = self . client . list_with_delimiter ( None ) . await ?;
408409
409410 let streams = resp
@@ -423,7 +424,7 @@ impl S3 {
423424 . iter ( )
424425 . any ( |name| name. location . filename ( ) . unwrap ( ) . ends_with ( "stream.json" ) )
425426 {
426- result_file_list. push ( LogStream { name : stream } ) ;
427+ result_file_list. insert ( stream) ;
427428 }
428429 }
429430
@@ -709,19 +710,17 @@ impl ObjectStorage for S3 {
709710 }
710711 }
711712
712- async fn list_streams ( & self ) -> Result < Vec < LogStream > , ObjectStorageError > {
713- let streams = self . _list_streams ( ) . await ?;
714-
715- Ok ( streams)
713+ async fn list_streams ( & self ) -> Result < HashSet < LogStream > , ObjectStorageError > {
714+ self . _list_streams ( ) . await
716715 }
717716
718- async fn list_old_streams ( & self ) -> Result < Vec < LogStream > , ObjectStorageError > {
717+ async fn list_old_streams ( & self ) -> Result < HashSet < LogStream > , ObjectStorageError > {
719718 let resp = self . client . list_with_delimiter ( None ) . await ?;
720719
721720 let common_prefixes = resp. common_prefixes ; // get all dirs
722721
723722 // return prefixes at the root level
724- let dirs: Vec < _ > = common_prefixes
723+ let dirs: HashSet < _ > = common_prefixes
725724 . iter ( )
726725 . filter_map ( |path| path. parts ( ) . next ( ) )
727726 . map ( |name| name. as_ref ( ) . to_string ( ) )
@@ -738,7 +737,7 @@ impl ObjectStorage for S3 {
738737
739738 stream_json_check. try_collect :: < ( ) > ( ) . await ?;
740739
741- Ok ( dirs. into_iter ( ) . map ( |name| LogStream { name } ) . collect ( ) )
740+ Ok ( dirs)
742741 }
743742
744743 async fn list_dates ( & self , stream_name : & str ) -> Result < Vec < String > , ObjectStorageError > {
0 commit comments