Merge branch 'dev'
This commit is contained in:
commit
9085614d24
13 changed files with 319 additions and 454 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,9 +5,8 @@
|
||||||
/logs
|
/logs
|
||||||
/docs
|
/docs
|
||||||
/doc
|
/doc
|
||||||
pom.xml
|
|
||||||
*.jar
|
*.jar
|
||||||
*.class
|
*.class
|
||||||
*.sh
|
|
||||||
.lein*
|
.lein*
|
||||||
|
pom.xml*
|
||||||
.env
|
.env
|
||||||
|
|
|
||||||
40
CHANGELOG.md
40
CHANGELOG.md
|
|
@ -1,8 +1,9 @@
|
||||||
## v2.6.0-alpha4 / 2014-Feb-16
|
## v2.6.0-beta1 / 2014 Feb 23
|
||||||
|
|
||||||
**WARNING**: This is an **EXPERIMENTAL early testing release** and **unsuitable for use in production**. Welcoming feedback on any issues, etc.!
|
> Welcoming feedback on any issues, etc.!
|
||||||
|
|
||||||
|
### New
|
||||||
|
|
||||||
### Features
|
|
||||||
* Low-level fns added: `freeze-to-out!`, `thaw-from-in!` for operating directly on DataOutputs/DataInputs.
|
* Low-level fns added: `freeze-to-out!`, `thaw-from-in!` for operating directly on DataOutputs/DataInputs.
|
||||||
* Data size optimizations for some common small data types (small strings/keywords, small integers).
|
* Data size optimizations for some common small data types (small strings/keywords, small integers).
|
||||||
* New test suite added to ensure a 1-to-1 value->binary representation mapping for all core data types. This will be a guarantee kept going forward.
|
* New test suite added to ensure a 1-to-1 value->binary representation mapping for all core data types. This will be a guarantee kept going forward.
|
||||||
|
|
@ -11,28 +12,37 @@
|
||||||
* Added experimental `freezable?` util fn to main ns.
|
* Added experimental `freezable?` util fn to main ns.
|
||||||
* Added some property-based [simple-check](https://github.com/reiddraper/simple-check) roundtrip tests.
|
* Added some property-based [simple-check](https://github.com/reiddraper/simple-check) roundtrip tests.
|
||||||
|
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
* **BREAKING**: the experimental `Compressable-LZMA2` type has changed (less overhead).
|
* **BREAKING**: the experimental `Compressable-LZMA2` type has changed (less overhead).
|
||||||
* **DEPRECATED**: `freeze-to-stream!`, `thaw-from-stream!` are deprecated in favor of the more general `freeze-to-out!`, `thaw-from-in!`.
|
* **DEPRECATED**: `freeze-to-stream!`, `thaw-from-stream!` are deprecated in favor of the more general `freeze-to-out!`, `thaw-from-in!`.
|
||||||
* **DEPRECATED**: `:legacy-mode` options. This was being used mainly for headerless freezing, so a new headerless mode is taking its place.
|
* **DEPRECATED**: `:legacy-mode` options. This was being used mainly for headerless freezing, so a new headerless mode is taking its place.
|
||||||
* Public utils now available for custom type extension: `write-bytes`, `write-biginteger`, `write-utf8`, `write-compact-long`, and respective readers.
|
* Public utils now available for custom type extension: `write-bytes`, `write-biginteger`, `write-utf8`, `write-compact-long`, and respective readers.
|
||||||
* Now distinguish between `BigInteger` and `BigInt` on thawing (previously both thawed to `BigInt`s). (mlacorte).
|
* Now distinguish between `BigInteger` and `BigInt` on thawing (previously both thawed to `BigInt`s). (mlacorte).
|
||||||
|
* Moved most utils to external `encore` dependency.
|
||||||
|
|
||||||
|
|
||||||
### Fixes
|
## v2.5.2 / 2013 Dec 7
|
||||||
* None.
|
|
||||||
|
|
||||||
|
### New
|
||||||
|
|
||||||
## v2.5.2 / 2013-12-07
|
|
||||||
* Test Serializable objects at freeze time for better reliability.
|
* Test Serializable objects at freeze time for better reliability.
|
||||||
* Don't cache `serializable?`/`readable?` for types with gensym-style names (e.g. as used for anonymous fns, etc.).
|
|
||||||
* Failed serialized/reader thaws will try return what they can (e.g. unreadable string) instead of just throwing.
|
|
||||||
* Thaw error messages now include failing type-id.
|
* Thaw error messages now include failing type-id.
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
* Don't cache `serializable?`/`readable?` for types with gensym-style names (e.g. as used for anonymous fns, etc.).
|
||||||
|
* Failed serialized/reader thaws will try return what they can (e.g. unreadable string) instead of just throwing.
|
||||||
|
|
||||||
|
|
||||||
|
## v2.5.1 / 2013 Dec 3
|
||||||
|
|
||||||
|
### New
|
||||||
|
|
||||||
## v2.5.1 / 2013-12-03
|
|
||||||
* Added experimental `inspect-ba` fn for examining data possibly frozen by Nippy.
|
* Added experimental `inspect-ba` fn for examining data possibly frozen by Nippy.
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
* Now throw exception at freeze (rather than thaw) time when trying to serialize an unreadable object using the Clojure reader.
|
* Now throw exception at freeze (rather than thaw) time when trying to serialize an unreadable object using the Clojure reader.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -102,13 +112,3 @@
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [README](https://github.com/ptaoussanis/nippy#encryption-currently-in-alpha) for an example using encryption.
|
See the [README](https://github.com/ptaoussanis/nippy#encryption-currently-in-alpha) for an example using encryption.
|
||||||
|
|
||||||
|
|
||||||
## For older versions please see the [commit history][]
|
|
||||||
|
|
||||||
[commit history]: https://github.com/ptaoussanis/nippy/commits/master
|
|
||||||
[API docs]: http://ptaoussanis.github.io/nippy
|
|
||||||
[Taoensso libs]: https://www.taoensso.com/clojure-libraries
|
|
||||||
[Nippy GitHub]: https://github.com/ptaoussanis/nippy
|
|
||||||
[Nippy CHANGELOG]: https://github.com/ptaoussanis/carmine/blob/master/CHANGELOG.md
|
|
||||||
[Nippy API docs]: http://ptaoussanis.github.io/nippy
|
|
||||||
|
|
|
||||||
198
LICENSE
Normal file
198
LICENSE
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
Eclipse Public License - v 1.0
|
||||||
|
|
||||||
|
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
|
||||||
|
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
|
||||||
|
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
||||||
|
|
||||||
|
1. DEFINITIONS
|
||||||
|
|
||||||
|
"Contribution" means:
|
||||||
|
|
||||||
|
a) in the case of the initial Contributor, the initial code and documentation
|
||||||
|
distributed under this Agreement, and
|
||||||
|
b) in the case of each subsequent Contributor:
|
||||||
|
i) changes to the Program, and
|
||||||
|
ii) additions to the Program;
|
||||||
|
|
||||||
|
where such changes and/or additions to the Program originate from and are
|
||||||
|
distributed by that particular Contributor. A Contribution 'originates' from
|
||||||
|
a Contributor if it was added to the Program by such Contributor itself or
|
||||||
|
anyone acting on such Contributor's behalf. Contributions do not include
|
||||||
|
additions to the Program which: (i) are separate modules of software
|
||||||
|
distributed in conjunction with the Program under their own license
|
||||||
|
agreement, and (ii) are not derivative works of the Program.
|
||||||
|
|
||||||
|
"Contributor" means any person or entity that distributes the Program.
|
||||||
|
|
||||||
|
"Licensed Patents" mean patent claims licensable by a Contributor which are
|
||||||
|
necessarily infringed by the use or sale of its Contribution alone or when
|
||||||
|
combined with the Program.
|
||||||
|
|
||||||
|
"Program" means the Contributions distributed in accordance with this Agreement.
|
||||||
|
|
||||||
|
"Recipient" means anyone who receives the Program under this Agreement,
|
||||||
|
including all Contributors.
|
||||||
|
|
||||||
|
2. GRANT OF RIGHTS
|
||||||
|
a) Subject to the terms of this Agreement, each Contributor hereby grants
|
||||||
|
Recipient a non-exclusive, worldwide, royalty-free copyright license to
|
||||||
|
reproduce, prepare derivative works of, publicly display, publicly perform,
|
||||||
|
distribute and sublicense the Contribution of such Contributor, if any, and
|
||||||
|
such derivative works, in source code and object code form.
|
||||||
|
b) Subject to the terms of this Agreement, each Contributor hereby grants
|
||||||
|
Recipient a non-exclusive, worldwide, royalty-free patent license under
|
||||||
|
Licensed Patents to make, use, sell, offer to sell, import and otherwise
|
||||||
|
transfer the Contribution of such Contributor, if any, in source code and
|
||||||
|
object code form. This patent license shall apply to the combination of the
|
||||||
|
Contribution and the Program if, at the time the Contribution is added by
|
||||||
|
the Contributor, such addition of the Contribution causes such combination
|
||||||
|
to be covered by the Licensed Patents. The patent license shall not apply
|
||||||
|
to any other combinations which include the Contribution. No hardware per
|
||||||
|
se is licensed hereunder.
|
||||||
|
c) Recipient understands that although each Contributor grants the licenses to
|
||||||
|
its Contributions set forth herein, no assurances are provided by any
|
||||||
|
Contributor that the Program does not infringe the patent or other
|
||||||
|
intellectual property rights of any other entity. Each Contributor
|
||||||
|
disclaims any liability to Recipient for claims brought by any other entity
|
||||||
|
based on infringement of intellectual property rights or otherwise. As a
|
||||||
|
condition to exercising the rights and licenses granted hereunder, each
|
||||||
|
Recipient hereby assumes sole responsibility to secure any other
|
||||||
|
intellectual property rights needed, if any. For example, if a third party
|
||||||
|
patent license is required to allow Recipient to distribute the Program, it
|
||||||
|
is Recipient's responsibility to acquire that license before distributing
|
||||||
|
the Program.
|
||||||
|
d) Each Contributor represents that to its knowledge it has sufficient
|
||||||
|
copyright rights in its Contribution, if any, to grant the copyright
|
||||||
|
license set forth in this Agreement.
|
||||||
|
|
||||||
|
3. REQUIREMENTS
|
||||||
|
|
||||||
|
A Contributor may choose to distribute the Program in object code form under its
|
||||||
|
own license agreement, provided that:
|
||||||
|
|
||||||
|
a) it complies with the terms and conditions of this Agreement; and
|
||||||
|
b) its license agreement:
|
||||||
|
i) effectively disclaims on behalf of all Contributors all warranties and
|
||||||
|
conditions, express and implied, including warranties or conditions of
|
||||||
|
title and non-infringement, and implied warranties or conditions of
|
||||||
|
merchantability and fitness for a particular purpose;
|
||||||
|
ii) effectively excludes on behalf of all Contributors all liability for
|
||||||
|
damages, including direct, indirect, special, incidental and
|
||||||
|
consequential damages, such as lost profits;
|
||||||
|
iii) states that any provisions which differ from this Agreement are offered
|
||||||
|
by that Contributor alone and not by any other party; and
|
||||||
|
iv) states that source code for the Program is available from such
|
||||||
|
Contributor, and informs licensees how to obtain it in a reasonable
|
||||||
|
manner on or through a medium customarily used for software exchange.
|
||||||
|
|
||||||
|
When the Program is made available in source code form:
|
||||||
|
|
||||||
|
a) it must be made available under this Agreement; and
|
||||||
|
b) a copy of this Agreement must be included with each copy of the Program.
|
||||||
|
Contributors may not remove or alter any copyright notices contained within
|
||||||
|
the Program.
|
||||||
|
|
||||||
|
Each Contributor must identify itself as the originator of its Contribution, if
|
||||||
|
any, in a manner that reasonably allows subsequent Recipients to identify the
|
||||||
|
originator of the Contribution.
|
||||||
|
|
||||||
|
4. COMMERCIAL DISTRIBUTION
|
||||||
|
|
||||||
|
Commercial distributors of software may accept certain responsibilities with
|
||||||
|
respect to end users, business partners and the like. While this license is
|
||||||
|
intended to facilitate the commercial use of the Program, the Contributor who
|
||||||
|
includes the Program in a commercial product offering should do so in a manner
|
||||||
|
which does not create potential liability for other Contributors. Therefore, if
|
||||||
|
a Contributor includes the Program in a commercial product offering, such
|
||||||
|
Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
|
||||||
|
every other Contributor ("Indemnified Contributor") against any losses, damages
|
||||||
|
and costs (collectively "Losses") arising from claims, lawsuits and other legal
|
||||||
|
actions brought by a third party against the Indemnified Contributor to the
|
||||||
|
extent caused by the acts or omissions of such Commercial Contributor in
|
||||||
|
connection with its distribution of the Program in a commercial product
|
||||||
|
offering. The obligations in this section do not apply to any claims or Losses
|
||||||
|
relating to any actual or alleged intellectual property infringement. In order
|
||||||
|
to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
|
||||||
|
Contributor in writing of such claim, and b) allow the Commercial Contributor to
|
||||||
|
control, and cooperate with the Commercial Contributor in, the defense and any
|
||||||
|
related settlement negotiations. The Indemnified Contributor may participate in
|
||||||
|
any such claim at its own expense.
|
||||||
|
|
||||||
|
For example, a Contributor might include the Program in a commercial product
|
||||||
|
offering, Product X. That Contributor is then a Commercial Contributor. If that
|
||||||
|
Commercial Contributor then makes performance claims, or offers warranties
|
||||||
|
related to Product X, those performance claims and warranties are such
|
||||||
|
Commercial Contributor's responsibility alone. Under this section, the
|
||||||
|
Commercial Contributor would have to defend claims against the other
|
||||||
|
Contributors related to those performance claims and warranties, and if a court
|
||||||
|
requires any other Contributor to pay any damages as a result, the Commercial
|
||||||
|
Contributor must pay those damages.
|
||||||
|
|
||||||
|
5. NO WARRANTY
|
||||||
|
|
||||||
|
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
|
||||||
|
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
|
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
|
||||||
|
Recipient is solely responsible for determining the appropriateness of using and
|
||||||
|
distributing the Program and assumes all risks associated with its exercise of
|
||||||
|
rights under this Agreement , including but not limited to the risks and costs
|
||||||
|
of program errors, compliance with applicable laws, damage to or loss of data,
|
||||||
|
programs or equipment, and unavailability or interruption of operations.
|
||||||
|
|
||||||
|
6. DISCLAIMER OF LIABILITY
|
||||||
|
|
||||||
|
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
|
||||||
|
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
|
||||||
|
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
|
||||||
|
GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
7. GENERAL
|
||||||
|
|
||||||
|
If any provision of this Agreement is invalid or unenforceable under applicable
|
||||||
|
law, it shall not affect the validity or enforceability of the remainder of the
|
||||||
|
terms of this Agreement, and without further action by the parties hereto, such
|
||||||
|
provision shall be reformed to the minimum extent necessary to make such
|
||||||
|
provision valid and enforceable.
|
||||||
|
|
||||||
|
If Recipient institutes patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Program itself
|
||||||
|
(excluding combinations of the Program with other software or hardware)
|
||||||
|
infringes such Recipient's patent(s), then such Recipient's rights granted under
|
||||||
|
Section 2(b) shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
All Recipient's rights under this Agreement shall terminate if it fails to
|
||||||
|
comply with any of the material terms or conditions of this Agreement and does
|
||||||
|
not cure such failure in a reasonable period of time after becoming aware of
|
||||||
|
such noncompliance. If all Recipient's rights under this Agreement terminate,
|
||||||
|
Recipient agrees to cease use and distribution of the Program as soon as
|
||||||
|
reasonably practicable. However, Recipient's obligations under this Agreement
|
||||||
|
and any licenses granted by Recipient relating to the Program shall continue and
|
||||||
|
survive.
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute copies of this Agreement, but in
|
||||||
|
order to avoid inconsistency the Agreement is copyrighted and may only be
|
||||||
|
modified in the following manner. The Agreement Steward reserves the right to
|
||||||
|
publish new versions (including revisions) of this Agreement from time to time.
|
||||||
|
No one other than the Agreement Steward has the right to modify this Agreement.
|
||||||
|
The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
|
||||||
|
may assign the responsibility to serve as the Agreement Steward to a suitable
|
||||||
|
separate entity. Each new version of the Agreement will be given a
|
||||||
|
distinguishing version number. The Program (including Contributions) may always
|
||||||
|
be distributed subject to the version of the Agreement under which it was
|
||||||
|
received. In addition, after a new version of the Agreement is published,
|
||||||
|
Contributor may elect to distribute the Program (including its Contributions)
|
||||||
|
under the new version. Except as expressly stated in Sections 2(a) and 2(b)
|
||||||
|
above, Recipient receives no rights or licenses to the intellectual property of
|
||||||
|
any Contributor under this Agreement, whether expressly, by implication,
|
||||||
|
estoppel or otherwise. All rights in the Program not expressly granted under
|
||||||
|
this Agreement are reserved.
|
||||||
|
|
||||||
|
This Agreement is governed by the laws of the State of New York and the
|
||||||
|
intellectual property laws of the United States of America. No party to this
|
||||||
|
Agreement will bring a legal action under this Agreement more than one year
|
||||||
|
after the cause of action arose. Each party waives its rights to a jury trial in
|
||||||
|
any resulting litigation.
|
||||||
30
README.md
30
README.md
|
|
@ -1,8 +1,8 @@
|
||||||
**[API docs](http://ptaoussanis.github.io/nippy/)** | **[CHANGELOG](https://github.com/ptaoussanis/nippy/blob/master/CHANGELOG.md)** | [contact & contributing](#contact--contributing) | [other Clojure libs](https://www.taoensso.com/clojure-libraries) | [Twitter](https://twitter.com/#!/ptaoussanis) | current [semantic](http://semver.org/) version:
|
**[API docs][]** | **[CHANGELOG][]** | [other Clojure libs][] | [Twitter][] | [contact/contributing](#contact--contributing) | current ([semantic][]) version:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
[com.taoensso/nippy "2.5.2"] ; Stable
|
[com.taoensso/nippy "2.5.2"] ; Stable
|
||||||
[com.taoensso/nippy "2.6.0-alpha4"] ; EXPERIMENTAL early testing release, unsuitable for production
|
[com.taoensso/nippy "2.6.0-beta1"] ; For early adopters
|
||||||
```
|
```
|
||||||
|
|
||||||
v2.6 will be a backwards-compatible release with: improved performance (incl. frozen data size), a new low-level DataInput/DataOuput API, improved support for headerless freezing, and 1-to-1 binary-value representation guarantees. See the [Changelog](https://github.com/ptaoussanis/nippy/blob/master/CHANGELOG.md) for details.
|
v2.6 will be a backwards-compatible release with: improved performance (incl. frozen data size), a new low-level DataInput/DataOuput API, improved support for headerless freezing, and 1-to-1 binary-value representation guarantees. See the [Changelog](https://github.com/ptaoussanis/nippy/blob/master/CHANGELOG.md) for details.
|
||||||
|
|
@ -32,7 +32,7 @@ Nippy is an attempt to provide a reliable, high-performance **drop-in alternativ
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
Add the necessary dependency to your [Leiningen](http://leiningen.org/) `project.clj` and `require` the library in your ns:
|
Add the necessary dependency to your [Leiningen][] `project.clj` and `require` the library in your ns:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
[com.taoensso/nippy "2.5.2"] ; project.clj
|
[com.taoensso/nippy "2.5.2"] ; project.clj
|
||||||
|
|
@ -151,16 +151,30 @@ There's two default forms of encryption on offer: `:salted` and `:cached`. Each
|
||||||
|
|
||||||
## This project supports the CDS and  goals
|
## This project supports the CDS and  goals
|
||||||
|
|
||||||
* [CDS](http://clojure-doc.org/), the **Clojure Documentation Site**, is a **contributer-friendly** community project aimed at producing top-notch, **beginner-friendly** Clojure tutorials and documentation. Awesome resource.
|
* [CDS][], the **Clojure Documentation Site**, is a **contributer-friendly** community project aimed at producing top-notch, **beginner-friendly** Clojure tutorials and documentation. Awesome resource.
|
||||||
|
|
||||||
* [ClojureWerkz](http://clojurewerkz.org/) is a growing collection of open-source, **batteries-included Clojure libraries** that emphasise modern targets, great documentation, and thorough testing. They've got a ton of great stuff, check 'em out!
|
* [ClojureWerkz][] is a growing collection of open-source, **batteries-included Clojure libraries** that emphasise modern targets, great documentation, and thorough testing. They've got a ton of great stuff, check 'em out!
|
||||||
|
|
||||||
## Contact & contributing
|
## Contact & contributing
|
||||||
|
|
||||||
Please use the [project's GitHub issues page](https://github.com/ptaoussanis/nippy/issues) for project questions/comments/suggestions/whatever **(pull requests welcome!)**. Am very open to ideas if you have any!
|
Please use the project's GitHub [issues page][] for project questions/comments/suggestions/whatever **(pull requests welcome!)**. Am very open to ideas if you have any!
|
||||||
|
|
||||||
Otherwise reach me (Peter Taoussanis) at [taoensso.com](https://www.taoensso.com) or on Twitter ([@ptaoussanis](https://twitter.com/#!/ptaoussanis)). Cheers!
|
Otherwise reach me (Peter Taoussanis) at [taoensso.com][] or on [Twitter][]. Cheers!
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © 2012, 2013 Peter Taoussanis. Distributed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html), the same as Clojure.
|
Copyright © 2012-2014 Peter Taoussanis. Distributed under the [Eclipse Public License][], the same as Clojure.
|
||||||
|
|
||||||
|
|
||||||
|
[API docs]: <http://ptaoussanis.github.io/nippy/>
|
||||||
|
[CHANGELOG]: <https://github.com/ptaoussanis/nippy/blob/master/CHANGELOG.md>
|
||||||
|
[other Clojure libs]: <https://www.taoensso.com/clojure-libraries>
|
||||||
|
[Twitter]: <https://twitter.com/ptaoussanis>
|
||||||
|
[semantic]: <http://semver.org/>
|
||||||
|
[Leiningen]: <http://leiningen.org/>
|
||||||
|
[CDS]: <http://clojure-doc.org/>
|
||||||
|
[ClojureWerkz]: <http://clojurewerkz.org/>
|
||||||
|
[issues page]: <https://github.com/ptaoussanis/nippy/issues>
|
||||||
|
[commit history]: <https://github.com/ptaoussanis/nippy/commits/master>
|
||||||
|
[taoensso.com]: <https://www.taoensso.com>
|
||||||
|
[Eclipse Public License]: <https://raw2.github.com/ptaoussanis/nippy/master/LICENSE>
|
||||||
|
|
|
||||||
261
epl-v10.html
261
epl-v10.html
|
|
@ -1,261 +0,0 @@
|
||||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
|
||||||
<title>Eclipse Public License - Version 1.0</title>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
size: 8.5in 11.0in;
|
|
||||||
margin: 0.25in 0.5in 0.25in 0.5in;
|
|
||||||
tab-interval: 0.5in;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-top: 0.5em;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
p.list {
|
|
||||||
margin-left: 0.5in;
|
|
||||||
margin-top: 0.05em;
|
|
||||||
margin-bottom: 0.05em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body lang="EN-US">
|
|
||||||
|
|
||||||
<p align=center><b>Eclipse Public License - v 1.0</b></p>
|
|
||||||
|
|
||||||
<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
|
||||||
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
|
|
||||||
DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
|
|
||||||
AGREEMENT.</p>
|
|
||||||
|
|
||||||
<p><b>1. DEFINITIONS</b></p>
|
|
||||||
|
|
||||||
<p>"Contribution" means:</p>
|
|
||||||
|
|
||||||
<p class="list">a) in the case of the initial Contributor, the initial
|
|
||||||
code and documentation distributed under this Agreement, and</p>
|
|
||||||
<p class="list">b) in the case of each subsequent Contributor:</p>
|
|
||||||
<p class="list">i) changes to the Program, and</p>
|
|
||||||
<p class="list">ii) additions to the Program;</p>
|
|
||||||
<p class="list">where such changes and/or additions to the Program
|
|
||||||
originate from and are distributed by that particular Contributor. A
|
|
||||||
Contribution 'originates' from a Contributor if it was added to the
|
|
||||||
Program by such Contributor itself or anyone acting on such
|
|
||||||
Contributor's behalf. Contributions do not include additions to the
|
|
||||||
Program which: (i) are separate modules of software distributed in
|
|
||||||
conjunction with the Program under their own license agreement, and (ii)
|
|
||||||
are not derivative works of the Program.</p>
|
|
||||||
|
|
||||||
<p>"Contributor" means any person or entity that distributes
|
|
||||||
the Program.</p>
|
|
||||||
|
|
||||||
<p>"Licensed Patents" mean patent claims licensable by a
|
|
||||||
Contributor which are necessarily infringed by the use or sale of its
|
|
||||||
Contribution alone or when combined with the Program.</p>
|
|
||||||
|
|
||||||
<p>"Program" means the Contributions distributed in accordance
|
|
||||||
with this Agreement.</p>
|
|
||||||
|
|
||||||
<p>"Recipient" means anyone who receives the Program under
|
|
||||||
this Agreement, including all Contributors.</p>
|
|
||||||
|
|
||||||
<p><b>2. GRANT OF RIGHTS</b></p>
|
|
||||||
|
|
||||||
<p class="list">a) Subject to the terms of this Agreement, each
|
|
||||||
Contributor hereby grants Recipient a non-exclusive, worldwide,
|
|
||||||
royalty-free copyright license to reproduce, prepare derivative works
|
|
||||||
of, publicly display, publicly perform, distribute and sublicense the
|
|
||||||
Contribution of such Contributor, if any, and such derivative works, in
|
|
||||||
source code and object code form.</p>
|
|
||||||
|
|
||||||
<p class="list">b) Subject to the terms of this Agreement, each
|
|
||||||
Contributor hereby grants Recipient a non-exclusive, worldwide,
|
|
||||||
royalty-free patent license under Licensed Patents to make, use, sell,
|
|
||||||
offer to sell, import and otherwise transfer the Contribution of such
|
|
||||||
Contributor, if any, in source code and object code form. This patent
|
|
||||||
license shall apply to the combination of the Contribution and the
|
|
||||||
Program if, at the time the Contribution is added by the Contributor,
|
|
||||||
such addition of the Contribution causes such combination to be covered
|
|
||||||
by the Licensed Patents. The patent license shall not apply to any other
|
|
||||||
combinations which include the Contribution. No hardware per se is
|
|
||||||
licensed hereunder.</p>
|
|
||||||
|
|
||||||
<p class="list">c) Recipient understands that although each Contributor
|
|
||||||
grants the licenses to its Contributions set forth herein, no assurances
|
|
||||||
are provided by any Contributor that the Program does not infringe the
|
|
||||||
patent or other intellectual property rights of any other entity. Each
|
|
||||||
Contributor disclaims any liability to Recipient for claims brought by
|
|
||||||
any other entity based on infringement of intellectual property rights
|
|
||||||
or otherwise. As a condition to exercising the rights and licenses
|
|
||||||
granted hereunder, each Recipient hereby assumes sole responsibility to
|
|
||||||
secure any other intellectual property rights needed, if any. For
|
|
||||||
example, if a third party patent license is required to allow Recipient
|
|
||||||
to distribute the Program, it is Recipient's responsibility to acquire
|
|
||||||
that license before distributing the Program.</p>
|
|
||||||
|
|
||||||
<p class="list">d) Each Contributor represents that to its knowledge it
|
|
||||||
has sufficient copyright rights in its Contribution, if any, to grant
|
|
||||||
the copyright license set forth in this Agreement.</p>
|
|
||||||
|
|
||||||
<p><b>3. REQUIREMENTS</b></p>
|
|
||||||
|
|
||||||
<p>A Contributor may choose to distribute the Program in object code
|
|
||||||
form under its own license agreement, provided that:</p>
|
|
||||||
|
|
||||||
<p class="list">a) it complies with the terms and conditions of this
|
|
||||||
Agreement; and</p>
|
|
||||||
|
|
||||||
<p class="list">b) its license agreement:</p>
|
|
||||||
|
|
||||||
<p class="list">i) effectively disclaims on behalf of all Contributors
|
|
||||||
all warranties and conditions, express and implied, including warranties
|
|
||||||
or conditions of title and non-infringement, and implied warranties or
|
|
||||||
conditions of merchantability and fitness for a particular purpose;</p>
|
|
||||||
|
|
||||||
<p class="list">ii) effectively excludes on behalf of all Contributors
|
|
||||||
all liability for damages, including direct, indirect, special,
|
|
||||||
incidental and consequential damages, such as lost profits;</p>
|
|
||||||
|
|
||||||
<p class="list">iii) states that any provisions which differ from this
|
|
||||||
Agreement are offered by that Contributor alone and not by any other
|
|
||||||
party; and</p>
|
|
||||||
|
|
||||||
<p class="list">iv) states that source code for the Program is available
|
|
||||||
from such Contributor, and informs licensees how to obtain it in a
|
|
||||||
reasonable manner on or through a medium customarily used for software
|
|
||||||
exchange.</p>
|
|
||||||
|
|
||||||
<p>When the Program is made available in source code form:</p>
|
|
||||||
|
|
||||||
<p class="list">a) it must be made available under this Agreement; and</p>
|
|
||||||
|
|
||||||
<p class="list">b) a copy of this Agreement must be included with each
|
|
||||||
copy of the Program.</p>
|
|
||||||
|
|
||||||
<p>Contributors may not remove or alter any copyright notices contained
|
|
||||||
within the Program.</p>
|
|
||||||
|
|
||||||
<p>Each Contributor must identify itself as the originator of its
|
|
||||||
Contribution, if any, in a manner that reasonably allows subsequent
|
|
||||||
Recipients to identify the originator of the Contribution.</p>
|
|
||||||
|
|
||||||
<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
|
|
||||||
|
|
||||||
<p>Commercial distributors of software may accept certain
|
|
||||||
responsibilities with respect to end users, business partners and the
|
|
||||||
like. While this license is intended to facilitate the commercial use of
|
|
||||||
the Program, the Contributor who includes the Program in a commercial
|
|
||||||
product offering should do so in a manner which does not create
|
|
||||||
potential liability for other Contributors. Therefore, if a Contributor
|
|
||||||
includes the Program in a commercial product offering, such Contributor
|
|
||||||
("Commercial Contributor") hereby agrees to defend and
|
|
||||||
indemnify every other Contributor ("Indemnified Contributor")
|
|
||||||
against any losses, damages and costs (collectively "Losses")
|
|
||||||
arising from claims, lawsuits and other legal actions brought by a third
|
|
||||||
party against the Indemnified Contributor to the extent caused by the
|
|
||||||
acts or omissions of such Commercial Contributor in connection with its
|
|
||||||
distribution of the Program in a commercial product offering. The
|
|
||||||
obligations in this section do not apply to any claims or Losses
|
|
||||||
relating to any actual or alleged intellectual property infringement. In
|
|
||||||
order to qualify, an Indemnified Contributor must: a) promptly notify
|
|
||||||
the Commercial Contributor in writing of such claim, and b) allow the
|
|
||||||
Commercial Contributor to control, and cooperate with the Commercial
|
|
||||||
Contributor in, the defense and any related settlement negotiations. The
|
|
||||||
Indemnified Contributor may participate in any such claim at its own
|
|
||||||
expense.</p>
|
|
||||||
|
|
||||||
<p>For example, a Contributor might include the Program in a commercial
|
|
||||||
product offering, Product X. That Contributor is then a Commercial
|
|
||||||
Contributor. If that Commercial Contributor then makes performance
|
|
||||||
claims, or offers warranties related to Product X, those performance
|
|
||||||
claims and warranties are such Commercial Contributor's responsibility
|
|
||||||
alone. Under this section, the Commercial Contributor would have to
|
|
||||||
defend claims against the other Contributors related to those
|
|
||||||
performance claims and warranties, and if a court requires any other
|
|
||||||
Contributor to pay any damages as a result, the Commercial Contributor
|
|
||||||
must pay those damages.</p>
|
|
||||||
|
|
||||||
<p><b>5. NO WARRANTY</b></p>
|
|
||||||
|
|
||||||
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
|
|
||||||
PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
|
||||||
OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
|
|
||||||
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
|
|
||||||
OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
|
|
||||||
responsible for determining the appropriateness of using and
|
|
||||||
distributing the Program and assumes all risks associated with its
|
|
||||||
exercise of rights under this Agreement , including but not limited to
|
|
||||||
the risks and costs of program errors, compliance with applicable laws,
|
|
||||||
damage to or loss of data, programs or equipment, and unavailability or
|
|
||||||
interruption of operations.</p>
|
|
||||||
|
|
||||||
<p><b>6. DISCLAIMER OF LIABILITY</b></p>
|
|
||||||
|
|
||||||
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
|
|
||||||
NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
|
|
||||||
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
|
|
||||||
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
|
||||||
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
|
|
||||||
|
|
||||||
<p><b>7. GENERAL</b></p>
|
|
||||||
|
|
||||||
<p>If any provision of this Agreement is invalid or unenforceable under
|
|
||||||
applicable law, it shall not affect the validity or enforceability of
|
|
||||||
the remainder of the terms of this Agreement, and without further action
|
|
||||||
by the parties hereto, such provision shall be reformed to the minimum
|
|
||||||
extent necessary to make such provision valid and enforceable.</p>
|
|
||||||
|
|
||||||
<p>If Recipient institutes patent litigation against any entity
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
|
||||||
Program itself (excluding combinations of the Program with other
|
|
||||||
software or hardware) infringes such Recipient's patent(s), then such
|
|
||||||
Recipient's rights granted under Section 2(b) shall terminate as of the
|
|
||||||
date such litigation is filed.</p>
|
|
||||||
|
|
||||||
<p>All Recipient's rights under this Agreement shall terminate if it
|
|
||||||
fails to comply with any of the material terms or conditions of this
|
|
||||||
Agreement and does not cure such failure in a reasonable period of time
|
|
||||||
after becoming aware of such noncompliance. If all Recipient's rights
|
|
||||||
under this Agreement terminate, Recipient agrees to cease use and
|
|
||||||
distribution of the Program as soon as reasonably practicable. However,
|
|
||||||
Recipient's obligations under this Agreement and any licenses granted by
|
|
||||||
Recipient relating to the Program shall continue and survive.</p>
|
|
||||||
|
|
||||||
<p>Everyone is permitted to copy and distribute copies of this
|
|
||||||
Agreement, but in order to avoid inconsistency the Agreement is
|
|
||||||
copyrighted and may only be modified in the following manner. The
|
|
||||||
Agreement Steward reserves the right to publish new versions (including
|
|
||||||
revisions) of this Agreement from time to time. No one other than the
|
|
||||||
Agreement Steward has the right to modify this Agreement. The Eclipse
|
|
||||||
Foundation is the initial Agreement Steward. The Eclipse Foundation may
|
|
||||||
assign the responsibility to serve as the Agreement Steward to a
|
|
||||||
suitable separate entity. Each new version of the Agreement will be
|
|
||||||
given a distinguishing version number. The Program (including
|
|
||||||
Contributions) may always be distributed subject to the version of the
|
|
||||||
Agreement under which it was received. In addition, after a new version
|
|
||||||
of the Agreement is published, Contributor may elect to distribute the
|
|
||||||
Program (including its Contributions) under the new version. Except as
|
|
||||||
expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
|
|
||||||
rights or licenses to the intellectual property of any Contributor under
|
|
||||||
this Agreement, whether expressly, by implication, estoppel or
|
|
||||||
otherwise. All rights in the Program not expressly granted under this
|
|
||||||
Agreement are reserved.</p>
|
|
||||||
|
|
||||||
<p>This Agreement is governed by the laws of the State of New York and
|
|
||||||
the intellectual property laws of the United States of America. No party
|
|
||||||
to this Agreement will bring a legal action under this Agreement more
|
|
||||||
than one year after the cause of action arose. Each party waives its
|
|
||||||
rights to a jury trial in any resulting litigation.</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
58
project.clj
58
project.clj
|
|
@ -1,35 +1,51 @@
|
||||||
(defproject com.taoensso/nippy "2.6.0-alpha3"
|
(defproject com.taoensso/nippy "2.6.0-beta1"
|
||||||
|
:author "Peter Taoussanis <https://www.taoensso.com>"
|
||||||
:description "Clojure serialization library"
|
:description "Clojure serialization library"
|
||||||
:url "https://github.com/ptaoussanis/nippy"
|
:url "https://github.com/ptaoussanis/nippy"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"
|
||||||
:dependencies [[org.clojure/clojure "1.4.0"]
|
:distribution :repo
|
||||||
|
:comments "Same as Clojure"}
|
||||||
|
:min-lein-version "2.3.3"
|
||||||
|
:global-vars {*warn-on-reflection* true
|
||||||
|
*assert* true}
|
||||||
|
:dependencies
|
||||||
|
[[org.clojure/clojure "1.4.0"]
|
||||||
[org.clojure/tools.reader "0.8.3"]
|
[org.clojure/tools.reader "0.8.3"]
|
||||||
[org.iq80.snappy/snappy "0.3"]
|
[org.iq80.snappy/snappy "0.3"]
|
||||||
[org.tukaani/xz "1.4"]]
|
[org.tukaani/xz "1.4"]
|
||||||
:profiles {:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
|
[com.taoensso/encore "0.8.0"]]
|
||||||
|
|
||||||
|
:test-paths ["test" "src"]
|
||||||
|
:profiles
|
||||||
|
{:build {:hooks ^:replace []} ; Workaround to avoid :dev hooks during deploy
|
||||||
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
|
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
|
||||||
:1.6 {:dependencies [[org.clojure/clojure "1.6.0-beta1"]]}
|
:1.6 {:dependencies [[org.clojure/clojure "1.6.0-beta1"]]}
|
||||||
:dev {:dependencies []}
|
:test {:jvm-opts ["-Xms1024m" "-Xmx2048m"]
|
||||||
:test {:jvm-opts ["-Xms1024m" ; Initial heap size
|
|
||||||
"-Xmx2048m" ; Max heap size
|
|
||||||
]
|
|
||||||
:dependencies [[expectations "1.4.56"]
|
:dependencies [[expectations "1.4.56"]
|
||||||
[org.xerial.snappy/snappy-java "1.1.1-M1"]
|
|
||||||
[reiddraper/simple-check "0.5.6"]
|
[reiddraper/simple-check "0.5.6"]
|
||||||
[org.clojure/data.fressian "0.2.0"]]}
|
[org.xerial.snappy/snappy-java "1.1.1-M1"]
|
||||||
:bench {:dependencies [] :jvm-opts ^:replace ["-server"]}}
|
[org.clojure/data.fressian "0.2.0"]]
|
||||||
:aliases {"test-all" ["with-profile" "+test,+1.4:+test,+1.5:+test,+1.6" "expectations"]
|
|
||||||
"test-auto" ["with-profile" "+test" "autoexpect"]
|
|
||||||
"start-dev" ["with-profile" "+dev,+test,+bench" "repl" ":headless"]
|
|
||||||
"start-bench" ["trampoline" "start-dev"]
|
|
||||||
"codox" ["with-profile" "+test" "doc"]}
|
|
||||||
:plugins [[lein-expectations "0.0.8"]
|
:plugins [[lein-expectations "0.0.8"]
|
||||||
[lein-autoexpect "1.2.1"]
|
[lein-autoexpect "1.2.2"]]}
|
||||||
[lein-ancient "0.5.4"]
|
:dev
|
||||||
|
[:1.6 :test
|
||||||
|
{:jvm-opts ^:replace ["-server" "-Xms1024m" "-Xmx2048m"]
|
||||||
|
:hooks []
|
||||||
|
:dependencies []
|
||||||
|
:plugins []}]}
|
||||||
|
|
||||||
|
:plugins [[lein-ancient "0.5.4"]
|
||||||
[codox "0.6.7"]]
|
[codox "0.6.7"]]
|
||||||
:min-lein-version "2.0.0"
|
|
||||||
:global-vars {*warn-on-reflection* true}
|
;; :codox {:sources ["target/classes"]} ; For use with cljx
|
||||||
|
:aliases
|
||||||
|
{"test-all" ["with-profile" "+test:+1.5,+test:+1.6,+test" "expectations"]
|
||||||
|
"test-auto" ["with-profile" "+test" "autoexpect"]
|
||||||
|
"start-dev" ["with-profile" "+dev" "repl" ":headless"]
|
||||||
|
"codox" ["with-profile" "+test" "doc"]
|
||||||
|
"deploy-lib" ["with-profile" "+dev,+build" "do" "deploy" "clojars," "install"]}
|
||||||
|
|
||||||
:repositories
|
:repositories
|
||||||
{"sonatype"
|
{"sonatype"
|
||||||
{:url "http://oss.sonatype.org/content/repositories/releases"
|
{:url "http://oss.sonatype.org/content/repositories/releases"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
from Deep-Freeze."
|
from Deep-Freeze."
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [clojure.tools.reader.edn :as edn]
|
(:require [clojure.tools.reader.edn :as edn]
|
||||||
|
[taoensso.encore :as encore]
|
||||||
[taoensso.nippy
|
[taoensso.nippy
|
||||||
(utils :as utils)
|
(utils :as utils)
|
||||||
(compression :as compression :refer (snappy-compressor))
|
(compression :as compression :refer (snappy-compressor))
|
||||||
|
|
@ -302,8 +303,8 @@
|
||||||
|
|
||||||
(defn- wrap-header [data-ba metadata]
|
(defn- wrap-header [data-ba metadata]
|
||||||
(if-let [meta-id (head-meta-id (assoc metadata :version head-version))]
|
(if-let [meta-id (head-meta-id (assoc metadata :version head-version))]
|
||||||
(let [head-ba (utils/ba-concat head-sig (byte-array [meta-id]))]
|
(let [head-ba (encore/ba-concat head-sig (byte-array [meta-id]))]
|
||||||
(utils/ba-concat head-ba data-ba))
|
(encore/ba-concat head-ba data-ba))
|
||||||
(throw (Exception. (str "Unrecognized header metadata: " metadata)))))
|
(throw (Exception. (str "Unrecognized header metadata: " metadata)))))
|
||||||
|
|
||||||
(comment (wrap-header (.getBytes "foo") {:compressed? true
|
(comment (wrap-header (.getBytes "foo") {:compressed? true
|
||||||
|
|
@ -356,10 +357,10 @@
|
||||||
`(long (BigInteger. (read-bytes ~in :small))))
|
`(long (BigInteger. (read-bytes ~in :small))))
|
||||||
|
|
||||||
(defmacro ^:private read-coll [in coll]
|
(defmacro ^:private read-coll [in coll]
|
||||||
`(let [in# ~in] (utils/repeatedly-into ~coll (.readInt in#) (thaw-from-in in#))))
|
`(let [in# ~in] (encore/repeatedly-into* ~coll (.readInt in#) (thaw-from-in in#))))
|
||||||
|
|
||||||
(defmacro ^:private read-kvs [in coll]
|
(defmacro ^:private read-kvs [in coll]
|
||||||
`(let [in# ~in] (utils/repeatedly-into ~coll (/ (.readInt in#) 2)
|
`(let [in# ~in] (encore/repeatedly-into* ~coll (/ (.readInt in#) 2)
|
||||||
[(thaw-from-in in#) (thaw-from-in in#)])))
|
[(thaw-from-in in#) (thaw-from-in in#)])))
|
||||||
|
|
||||||
(declare ^:private custom-readers)
|
(declare ^:private custom-readers)
|
||||||
|
|
@ -371,7 +372,7 @@
|
||||||
(when-debug-mode
|
(when-debug-mode
|
||||||
(println (format "DEBUG - thawing type-id: %s" type-id)))
|
(println (format "DEBUG - thawing type-id: %s" type-id)))
|
||||||
|
|
||||||
(utils/case-eval type-id
|
(encore/case-eval type-id
|
||||||
|
|
||||||
id-reader
|
id-reader
|
||||||
(let [edn (read-utf8 in)]
|
(let [edn (read-utf8 in)]
|
||||||
|
|
@ -446,7 +447,7 @@
|
||||||
;;; DEPRECATED
|
;;; DEPRECATED
|
||||||
id-old-reader (edn/read-string (.readUTF in))
|
id-old-reader (edn/read-string (.readUTF in))
|
||||||
id-old-string (.readUTF in)
|
id-old-string (.readUTF in)
|
||||||
id-old-map (apply hash-map (utils/repeatedly-into []
|
id-old-map (apply hash-map (encore/repeatedly-into* []
|
||||||
(* 2 (.readInt in)) (thaw-from-in in)))
|
(* 2 (.readInt in)) (thaw-from-in in)))
|
||||||
id-old-keyword (keyword (.readUTF in))
|
id-old-keyword (keyword (.readUTF in))
|
||||||
|
|
||||||
|
|
@ -472,9 +473,9 @@
|
||||||
(thaw-from-in data-input))
|
(thaw-from-in data-input))
|
||||||
|
|
||||||
(defn- try-parse-header [ba]
|
(defn- try-parse-header [ba]
|
||||||
(when-let [[head-ba data-ba] (utils/ba-split ba 4)]
|
(when-let [[head-ba data-ba] (encore/ba-split ba 4)]
|
||||||
(let [[head-sig* [meta-id]] (utils/ba-split head-ba 3)]
|
(let [[head-sig* [meta-id]] (encore/ba-split head-ba 3)]
|
||||||
(when (utils/ba= head-sig* head-sig) ; Appears to be well-formed
|
(when (encore/ba= head-sig* head-sig) ; Appears to be well-formed
|
||||||
[data-ba (head-meta meta-id {:unrecognized-meta? true})]))))
|
[data-ba (head-meta meta-id {:unrecognized-meta? true})]))))
|
||||||
|
|
||||||
(defn thaw
|
(defn thaw
|
||||||
|
|
@ -699,16 +700,16 @@
|
||||||
|
|
||||||
;;;; Tools
|
;;;; Tools
|
||||||
|
|
||||||
(utils/defalias freezeable? utils/freezable?)
|
(encore/defalias freezeable? utils/freezable?)
|
||||||
|
|
||||||
(defn inspect-ba "Alpha - subject to change."
|
(defn inspect-ba "Alpha - subject to change."
|
||||||
[ba & [thaw-opts]]
|
[ba & [thaw-opts]]
|
||||||
(if-not (utils/bytes? ba) :not-ba
|
(if-not (encore/bytes? ba) :not-ba
|
||||||
(let [[first2bytes nextbytes] (utils/ba-split ba 2)
|
(let [[first2bytes nextbytes] (encore/ba-split ba 2)
|
||||||
known-wrapper
|
known-wrapper
|
||||||
(cond
|
(cond
|
||||||
(utils/ba= first2bytes (.getBytes "\u0000<" "UTF8")) :carmine/bin
|
(encore/ba= first2bytes (.getBytes "\u0000<" "UTF8")) :carmine/bin
|
||||||
(utils/ba= first2bytes (.getBytes "\u0000>" "UTF8")) :carmine/clj)
|
(encore/ba= first2bytes (.getBytes "\u0000>" "UTF8")) :carmine/clj)
|
||||||
|
|
||||||
unwrapped-ba (if known-wrapper nextbytes ba)
|
unwrapped-ba (if known-wrapper nextbytes ba)
|
||||||
[data-ba nippy-header] (or (try-parse-header unwrapped-ba)
|
[data-ba nippy-header] (or (try-parse-header unwrapped-ba)
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [clojure.tools.reader.edn :as edn]
|
(:require [clojure.tools.reader.edn :as edn]
|
||||||
[clojure.data.fressian :as fressian]
|
[clojure.data.fressian :as fressian]
|
||||||
|
[taoensso.encore :as encore]
|
||||||
[taoensso.nippy :as nippy :refer (freeze thaw)]
|
[taoensso.nippy :as nippy :refer (freeze thaw)]
|
||||||
[taoensso.nippy.compression :as compression]
|
[taoensso.nippy.compression :as compression]))
|
||||||
[taoensso.nippy.utils :as utils]))
|
|
||||||
|
|
||||||
(def data nippy/stress-data-benchable)
|
(def data nippy/stress-data-benchable)
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
(comment (fressian-thaw (fressian-freeze data)))
|
(comment (fressian-thaw (fressian-freeze data)))
|
||||||
|
|
||||||
(defmacro bench* [& body] `(utils/bench 10000 {:warmup-laps 20000} ~@body))
|
(defmacro bench* [& body] `(encore/bench 10000 {:warmup-laps 20000} ~@body))
|
||||||
(defn bench1 [freezer thawer & [sizer]]
|
(defn bench1 [freezer thawer & [sizer]]
|
||||||
(let [data-frozen (freezer data)
|
(let [data-frozen (freezer data)
|
||||||
time-freeze (bench* (freezer data))
|
time-freeze (bench* (freezer data))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
(ns taoensso.nippy.compression
|
(ns taoensso.nippy.compression
|
||||||
"Alpha - subject to change."
|
"Alpha - subject to change."
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [taoensso.nippy.utils :as utils])
|
|
||||||
(:import [java.io ByteArrayInputStream ByteArrayOutputStream DataInputStream
|
(:import [java.io ByteArrayInputStream ByteArrayOutputStream DataInputStream
|
||||||
DataOutputStream]))
|
DataOutputStream]))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Simple no-nonsense crypto with reasonable defaults. Because your Clojure data
|
Simple no-nonsense crypto with reasonable defaults. Because your Clojure data
|
||||||
deserves some privacy."
|
deserves some privacy."
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [taoensso.nippy.utils :as utils]))
|
(:require [taoensso.encore :as encore]))
|
||||||
|
|
||||||
;;;; Interface
|
;;;; Interface
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
(PBKDF2, bcrypt, scrypt, etc.). Decent security with multiple rounds."
|
(PBKDF2, bcrypt, scrypt, etc.). Decent security with multiple rounds."
|
||||||
[salt-ba ^String pwd]
|
[salt-ba ^String pwd]
|
||||||
(loop [^bytes ba (let [pwd-ba (.getBytes pwd "UTF-8")]
|
(loop [^bytes ba (let [pwd-ba (.getBytes pwd "UTF-8")]
|
||||||
(if salt-ba (utils/ba-concat salt-ba pwd-ba) pwd-ba))
|
(if salt-ba (encore/ba-concat salt-ba pwd-ba) pwd-ba))
|
||||||
n (* (int Short/MAX_VALUE) (if salt-ba 5 64))]
|
n (* (int Short/MAX_VALUE) (if salt-ba 5 64))]
|
||||||
(if-not (zero? n)
|
(if-not (zero? n)
|
||||||
(recur (.digest sha512-md ba) (dec n))
|
(recur (.digest sha512-md ba) (dec n))
|
||||||
|
|
@ -70,22 +70,22 @@
|
||||||
salt? (= type :salted)
|
salt? (= type :salted)
|
||||||
iv-ba (rand-bytes aes128-block-size)
|
iv-ba (rand-bytes aes128-block-size)
|
||||||
salt-ba (when salt? (rand-bytes salt-size))
|
salt-ba (when salt? (rand-bytes salt-size))
|
||||||
prefix-ba (if-not salt? iv-ba (utils/ba-concat iv-ba salt-ba))
|
prefix-ba (if-not salt? iv-ba (encore/ba-concat iv-ba salt-ba))
|
||||||
key (utils/memoized (when-not salt? (:key-cache this))
|
key (encore/memoized (when-not salt? (:key-cache this))
|
||||||
sha512-key salt-ba pwd)
|
sha512-key salt-ba pwd)
|
||||||
iv (javax.crypto.spec.IvParameterSpec. iv-ba)]
|
iv (javax.crypto.spec.IvParameterSpec. iv-ba)]
|
||||||
(.init aes128-cipher javax.crypto.Cipher/ENCRYPT_MODE
|
(.init aes128-cipher javax.crypto.Cipher/ENCRYPT_MODE
|
||||||
^javax.crypto.spec.SecretKeySpec key iv)
|
^javax.crypto.spec.SecretKeySpec key iv)
|
||||||
(utils/ba-concat prefix-ba (.doFinal aes128-cipher data-ba))))
|
(encore/ba-concat prefix-ba (.doFinal aes128-cipher data-ba))))
|
||||||
|
|
||||||
(decrypt [this typed-pwd ba]
|
(decrypt [this typed-pwd ba]
|
||||||
(let [[type pwd] (destructure-typed-pwd typed-pwd)
|
(let [[type pwd] (destructure-typed-pwd typed-pwd)
|
||||||
salt? (= type :salted)
|
salt? (= type :salted)
|
||||||
prefix-size (+ aes128-block-size (if salt? salt-size 0))
|
prefix-size (+ aes128-block-size (if salt? salt-size 0))
|
||||||
[prefix-ba data-ba] (utils/ba-split ba prefix-size)
|
[prefix-ba data-ba] (encore/ba-split ba prefix-size)
|
||||||
[iv-ba salt-ba] (if-not salt? [prefix-ba nil]
|
[iv-ba salt-ba] (if-not salt? [prefix-ba nil]
|
||||||
(utils/ba-split prefix-ba aes128-block-size))
|
(encore/ba-split prefix-ba aes128-block-size))
|
||||||
key (utils/memoized (when-not salt? (:key-cache this))
|
key (encore/memoized (when-not salt? (:key-cache this))
|
||||||
sha512-key salt-ba pwd)
|
sha512-key salt-ba pwd)
|
||||||
iv (javax.crypto.spec.IvParameterSpec. iv-ba)]
|
iv (javax.crypto.spec.IvParameterSpec. iv-ba)]
|
||||||
(.init aes128-cipher javax.crypto.Cipher/DECRYPT_MODE
|
(.init aes128-cipher javax.crypto.Cipher/DECRYPT_MODE
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
Utilities for third-party tools that want to add fully-user-configurable Nippy
|
Utilities for third-party tools that want to add fully-user-configurable Nippy
|
||||||
support. Used by Carmine and Faraday."
|
support. Used by Carmine and Faraday."
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [taoensso.nippy :as nippy]
|
(:require [taoensso.nippy :as nippy]))
|
||||||
[taoensso.nippy.utils :as utils]))
|
|
||||||
|
|
||||||
(defrecord WrappedForFreezing [value opts])
|
(defrecord WrappedForFreezing [value opts])
|
||||||
(defn wrapped-for-freezing? [x] (instance? WrappedForFreezing x))
|
(defn wrapped-for-freezing? [x] (instance? WrappedForFreezing x))
|
||||||
|
|
|
||||||
|
|
@ -5,110 +5,6 @@
|
||||||
(:import [java.io ByteArrayInputStream ByteArrayOutputStream Serializable
|
(:import [java.io ByteArrayInputStream ByteArrayOutputStream Serializable
|
||||||
ObjectOutputStream ObjectInputStream]))
|
ObjectOutputStream ObjectInputStream]))
|
||||||
|
|
||||||
(defmacro defalias
|
|
||||||
"Defines an alias for a var, preserving metadata. Adapted from
|
|
||||||
clojure.contrib/def.clj, Ref. http://goo.gl/xpjeH"
|
|
||||||
[name target & [doc]]
|
|
||||||
`(let [^clojure.lang.Var v# (var ~target)]
|
|
||||||
(alter-meta! (def ~name (.getRawRoot v#))
|
|
||||||
#(merge % (apply dissoc (meta v#) [:column :line :file :test :name])
|
|
||||||
(when-let [doc# ~doc] {:doc doc#})))
|
|
||||||
(var ~name)))
|
|
||||||
|
|
||||||
(defmacro case-eval
|
|
||||||
"Like `case` but evaluates test constants for their compile-time value."
|
|
||||||
[e & clauses]
|
|
||||||
(let [;; Don't evaluate default expression!
|
|
||||||
default (when (odd? (count clauses)) (last clauses))
|
|
||||||
clauses (if default (butlast clauses) clauses)]
|
|
||||||
`(case ~e
|
|
||||||
~@(map-indexed (fn [i# form#] (if (even? i#) (eval form#) form#))
|
|
||||||
clauses)
|
|
||||||
~(when default default))))
|
|
||||||
|
|
||||||
(defmacro repeatedly-into
|
|
||||||
"Like `repeatedly` but faster and `conj`s items into given collection."
|
|
||||||
[coll n & body]
|
|
||||||
`(let [coll# ~coll
|
|
||||||
n# ~n]
|
|
||||||
(if (instance? clojure.lang.IEditableCollection coll#)
|
|
||||||
(loop [v# (transient coll#) idx# 0]
|
|
||||||
(if (>= idx# n#)
|
|
||||||
(persistent! v#)
|
|
||||||
(recur (conj! v# ~@body)
|
|
||||||
(inc idx#))))
|
|
||||||
(loop [v# coll#
|
|
||||||
idx# 0]
|
|
||||||
(if (>= idx# n#)
|
|
||||||
v#
|
|
||||||
(recur (conj v# ~@body)
|
|
||||||
(inc idx#)))))))
|
|
||||||
|
|
||||||
(defmacro time-ns "Returns number of nanoseconds it takes to execute body."
|
|
||||||
[& body] `(let [t0# (System/nanoTime)] ~@body (- (System/nanoTime) t0#)))
|
|
||||||
|
|
||||||
(defmacro bench
|
|
||||||
"Repeatedly executes body and returns time taken to complete execution."
|
|
||||||
[nlaps {:keys [nlaps-warmup nthreads as-ns?]
|
|
||||||
:or {nlaps-warmup 0
|
|
||||||
nthreads 1}} & body]
|
|
||||||
`(let [nlaps# ~nlaps
|
|
||||||
nlaps-warmup# ~nlaps-warmup
|
|
||||||
nthreads# ~nthreads]
|
|
||||||
(try (dotimes [_# nlaps-warmup#] ~@body)
|
|
||||||
(let [nanosecs#
|
|
||||||
(if (= nthreads# 1)
|
|
||||||
(time-ns (dotimes [_# nlaps#] ~@body))
|
|
||||||
(let [nlaps-per-thread# (int (/ nlaps# nthreads#))]
|
|
||||||
(time-ns
|
|
||||||
(->> (fn [] (future (dotimes [_# nlaps-per-thread#] ~@body)))
|
|
||||||
(repeatedly nthreads#)
|
|
||||||
(doall)
|
|
||||||
(map deref)
|
|
||||||
(dorun)))))]
|
|
||||||
(if ~as-ns? nanosecs# (Math/round (/ nanosecs# 1000000.0))))
|
|
||||||
(catch Exception e# (format "DNF: %s" (.getMessage e#))))))
|
|
||||||
|
|
||||||
(defn memoized
|
|
||||||
"Like `(partial memoize* {})` but takes an explicit cache atom (possibly nil)
|
|
||||||
and immediately applies memoized f to given arguments."
|
|
||||||
[cache f & args]
|
|
||||||
(if-not cache
|
|
||||||
(apply f args)
|
|
||||||
(if-let [dv (@cache args)]
|
|
||||||
@dv
|
|
||||||
(locking cache ; For thread racing
|
|
||||||
(if-let [dv (@cache args)] ; Retry after lock acquisition!
|
|
||||||
@dv
|
|
||||||
(let [dv (delay (apply f args))]
|
|
||||||
(swap! cache assoc args dv)
|
|
||||||
@dv))))))
|
|
||||||
|
|
||||||
(comment (memoized nil +)
|
|
||||||
(memoized nil + 5 12))
|
|
||||||
|
|
||||||
(def ^:const bytes-class (Class/forName "[B"))
|
|
||||||
(defn bytes? [x] (instance? bytes-class x))
|
|
||||||
(defn ba= [^bytes x ^bytes y] (java.util.Arrays/equals x y))
|
|
||||||
|
|
||||||
(defn ba-concat ^bytes [^bytes ba1 ^bytes ba2]
|
|
||||||
(let [s1 (alength ba1)
|
|
||||||
s2 (alength ba2)
|
|
||||||
out (byte-array (+ s1 s2))]
|
|
||||||
(System/arraycopy ba1 0 out 0 s1)
|
|
||||||
(System/arraycopy ba2 0 out s1 s2)
|
|
||||||
out))
|
|
||||||
|
|
||||||
(defn ba-split [^bytes ba ^Integer idx]
|
|
||||||
(let [s (alength ba)]
|
|
||||||
(when (> s idx)
|
|
||||||
[(java.util.Arrays/copyOf ba idx)
|
|
||||||
(java.util.Arrays/copyOfRange ba idx s)])))
|
|
||||||
|
|
||||||
(comment (String. (ba-concat (.getBytes "foo") (.getBytes "bar")))
|
|
||||||
(let [[x y] (ba-split (.getBytes "foobar") 5)]
|
|
||||||
[(String. x) (String. y)]))
|
|
||||||
|
|
||||||
;;;; Fallback type tests
|
;;;; Fallback type tests
|
||||||
;; Unfortunately the only reliable way we can tell if something's
|
;; Unfortunately the only reliable way we can tell if something's
|
||||||
;; really serializable/readable is to actually try a full roundtrip.
|
;; really serializable/readable is to actually try a full roundtrip.
|
||||||
|
|
@ -224,4 +120,6 @@
|
||||||
(freezable? (.getBytes "foo"))
|
(freezable? (.getBytes "foo"))
|
||||||
(freezable? (java.util.Date.) {:allow-clojure-reader? true})
|
(freezable? (java.util.Date.) {:allow-clojure-reader? true})
|
||||||
(freezable? (Exception. "_") {:allow-clojure-reader? true})
|
(freezable? (Exception. "_") {:allow-clojure-reader? true})
|
||||||
(freezable? (Exception. "_") {:allow-java-serializable? true}))
|
(freezable? (Exception. "_") {:allow-java-serializable? true})
|
||||||
|
(freezable? (atom {}) {:allow-clojure-reader? true
|
||||||
|
:allow-java-serializable? true}))
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
[taoensso.nippy.compression :as compression]
|
[taoensso.nippy.compression :as compression]
|
||||||
[taoensso.nippy.benchmarks :as benchmarks]))
|
[taoensso.nippy.benchmarks :as benchmarks]))
|
||||||
|
|
||||||
|
(comment (test/run-tests '[taoensso.nippy.tests.main]))
|
||||||
|
|
||||||
(def test-data nippy/stress-data-comparable)
|
(def test-data nippy/stress-data-comparable)
|
||||||
(defn- before-run {:expectations-options :before-run} [])
|
(defn- before-run {:expectations-options :before-run} [])
|
||||||
(defn- after-run {:expectations-options :after-run} [])
|
(defn- after-run {:expectations-options :after-run} [])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue