jesspav commented on code in PR #446:
URL: https://github.com/apache/sedona-db/pull/446#discussion_r2617252123


##########
rust/sedona-schema/src/crs.rs:
##########
@@ -15,41 +15,61 @@
 // specific language governing permissions and limitations
 // under the License.
 use datafusion_common::{DataFusionError, Result};
+use lru::LruCache;
 use std::fmt::{Debug, Display};
+use std::num::NonZeroUsize;
 use std::str::FromStr;
 use std::sync::Arc;
+use std::sync::Mutex;
+use std::sync::OnceLock;
 
 use serde_json::Value;
 
+/// LRU cache for CRS deserialization
+static CRS_CACHE: OnceLock<Mutex<LruCache<String, Crs>>> = OnceLock::new();
+
+fn get_crs_cache() -> &'static Mutex<LruCache<String, Crs>> {
+    CRS_CACHE.get_or_init(|| {
+        // Cache up to 256 CRS strings
+        Mutex::new(LruCache::new(NonZeroUsize::new(256).unwrap()))
+    })
+}

Review Comment:
   I made it 50 for now.  I think this should be configurable given the perf 
implications.  I'll can add an issue so we don't forget.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to