Comments (6)
As per discussions on slack, requiring people to have a binding to use Datalevin functions seems a bit excessive, so we will keep the set-config
function proposal, and hope people who have similar issues will land it here.
from datalevin.
Using print for regex is when importing/exporting data as text, so it is possible to only add the print-method when exporting.
from datalevin.
Just limit the change of print-method to dumping the DB.
from datalevin.
Because some data contains regex, in order to store and retrieve such data, print-method for regex was added, e.g. they are often used in transaction functions.
We can make this print-method optional for regex in order to support your use case. I can add a function set-confg
to allow setting some global configurations. In this case, (set-config :store-regex? false)
can be called to disable adding print-method for regex.
from datalevin.
I understand it is part of the serialization format. I would argue though that including the Datalevin namespace in your Clojure project should not break something that can be considered standard Clojure code. Especially for new users it would not be obvious to use your proposed setting. Also, what do you do when you need both. Maybe there is an alternative solution (idea below)?
Note: I haven't touched Datalevin much so I'm not sure about the impact of any change to this project.
;; in datalevin.bits
;; Don;t interfere with Clojure by default
(def :^dynamic *datalevin* false)
;; For Datalevin types *datalevin* is true
(defmethod print-method Indexable
[^Indexable i, ^Writer w]
(.write w "#datalevin/Indexable ")
;; This is Datalevin territory
(binding [*datalevin* true]
(.write w (pr-str (pr-indexable i)))))
;; Store original print-method
(defonce stdlib-print-method-pattern (get-method print-method java.util.regex.Pattern))
;; Depending on the *datalevin* value we will adapt printing for regex (and maybe others
(defmethod print-method Pattern
[^Pattern p, ^Writer w]
(if *datalevin*
(doto w
(.write "#datalevin/regex ")
(.write "\"")
(.write ^String (s/escape (.toString p) {\\ "\\\\"}))
(.write "\""))
;; => Default Clojure's print behaviour here
(stdlib-print-method-pattern p w)))
from datalevin.
Because some data contains regex, in order to store and retrieve such data, print-method for regex was added, e.g. they are often used in transaction functions.
is this because pr-str is used to write this data? Would it help to use custom functions similar to nippy's serialize?
from datalevin.
Related Issues (20)
- Transaction Error: Entity cannot be retracted HOT 7
- [Client/Server] deal with cases when predicate definition contains references to DB
- Improve re-index
- collection bindings OOM for large data sets HOT 1
- Expose Clojure vars to inter-fn
- dump/load database in nippy binary format HOT 1
- Queries inside an inter-fn doesn't resolve a built-in properly HOT 1
- Support for Heterogenous tuples with :db/tupleTypes supporting :db.type/refs HOT 4
- The difference between :db.unique/identity and :db.unique/value for :db.type/tuple HOT 1
- Getting warnings for clojure.core/load being redefined HOT 1
- TX report prints differently HOT 1
- `:xform` not being called for `:cardinality/one` ref attributes in pull expression HOT 1
- Error transacting db.type/bigdec
- :validate-data? does not recognise homogeneous tuple :db/tupleType HOT 1
- DB cannot be started HOT 2
- deal with client calls when server search engine is timed out
- value unification in function expression result
- [QUESTION]: separate the client into a small lib? HOT 23
- Allow indexing of arbitrary data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datalevin.