Compare commits

...

636 Commits

Author SHA1 Message Date
Taro L. Saito
65e1ec3de1
Revert "feature: Add bit-shuffling interfaces for unshuffle with provided out…" (#640)
This reverts commit 4277fbcdc86a7f13f74053387075ecd232ac363f.
2025-02-03 21:31:50 -08:00
Rodrigo Molina
466d05f31f
Fix the scope of SnappyOutputStream.MIN_BLOCK_SIZE and SnappyOutputStream.DEFAULT_BLOCK_SIZE (#638) 2025-02-03 21:28:50 -08:00
Xing Qu
4277fbcdc8
feature: Add bit-shuffling interfaces for unshuffle with provided output array (#608) 2025-02-03 21:27:43 -08:00
PeterDubec
266126036c
Add support for IBM ppc 64 little endian (#628) 2025-02-03 21:20:59 -08:00
xerial-bot
b9a5d5f573
Update scalafmt-core to 3.8.6 (#636) 2025-02-03 21:17:20 -08:00
xerial-bot
42e5928a28
Update sbt-scalafmt to 2.5.4 (#633) 2025-02-03 21:17:03 -08:00
Antonio Muñoz
d258a4aaa0
Fixes native-image configuration: dll is called snappyjava.dll not libsnappy (#635)
Co-authored-by: Antonio Muñoz <antonio.munoz@clarity.ai>
2025-02-03 21:16:42 -08:00
xerial-bot
2abbbc7fbf
Update airframe-log to 2025.1.1 (#639) 2025-02-03 21:11:53 -08:00
xerial-bot
ec23d7c611
Update hadoop-common to 3.4.1 (#611) 2025-01-08 11:46:21 -08:00
xerial-bot
192e0ee286
Update sbt to 1.10.7 (#624) 2025-01-08 11:46:12 -08:00
xerial-bot
dfbf67a4cb
Update sbt-sonatype to 3.12.2 (#609) 2024-12-19 16:16:05 -08:00
xerial-bot
f6b188896c
Update sbt to 1.10.6 (#619) 2024-12-19 09:33:33 -08:00
xerial-bot
1fe7685ae7
Update sbt-pgp to 2.3.1 (#622) 2024-12-19 09:33:16 -08:00
xerial-bot
3b2138cc7c
Update airframe-log to 24.12.2 (#623) 2024-12-19 09:33:08 -08:00
xerial-bot
9c73c6e6a2
Update sbt-dynver to 5.1.0 (#610) 2024-11-15 12:15:29 -08:00
xerial-bot
595c6d4a11
Update airframe-log to 24.11.0 (#617) 2024-11-15 12:15:13 -08:00
xerial-bot
8a32b3c6cb
Update sbt to 1.10.5 (#615) 2024-11-12 20:40:30 -08:00
xerial-bot
85966bbb1b
Update sbt-pgp to 2.3.0 (#602) 2024-10-08 14:38:59 -07:00
xerial-bot
08c44a000f
Update airframe-log to 24.9.3 (#601) 2024-10-08 14:38:51 -07:00
xerial-bot
ac5d2cb3e1
Update sbt to 1.10.2 (#598) 2024-10-08 14:38:44 -07:00
xerial-bot
899b9b2cdb
Update sbt-sonatype to 3.11.3 (#592) 2024-09-10 12:22:59 -07:00
Brett Okken
da1af8b260
internal: let ByteBuffer read 4 bytes as int in single call (#594) 2024-09-10 12:22:47 -07:00
dependabot[bot]
1af05fee67
Bump peter-evans/create-pull-request from 6 to 7 (#596)
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6 to 7.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v6...v7)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-10 12:22:31 -07:00
xerial-bot
5290e26ad9
Update airframe-log to 24.9.0 (#597) 2024-09-10 12:22:22 -07:00
Brett Okken
01368fe0d5
internal: use LambdaMetafactory to generate java.util.zip.CRC32C instances (#595)
currently we have written a lambda (turns into anonymous class) which
invokes a MethodHandle for the java.util.zip.CRC32C constructor as the
Supplier<Checksum> implementation.

This has 2 layers of misdirection. The Supplier implementation spun up
by the jvm calls the anonymous lambda class, which then calls the
MethodHandle invoke. This leads to stack traces like:

use LambdaMetafactory to generate a Supplier<Checksum> which calls the
java.util.zip.CRC32C

Co-authored-by: bo8979 <bo8979@cerner.com>
2024-09-10 12:22:02 -07:00
xerial-bot
341377bfed
Update scalafmt-core to 3.8.3 (#588) 2024-08-07 13:07:30 -07:00
Tobias Soloschenko
04c68883a6
feat: add GraalVM support (#590) 2024-08-06 22:39:44 -07:00
xerial-bot
bad35791e1
Update airframe-log to 24.7.1 (#587) 2024-07-17 10:47:51 -07:00
xerial-bot
f3dc3cf88a
Update airframe-log to 24.7.0 (#586) 2024-07-16 13:24:19 -07:00
xerial-bot
5fc737773d
Update scalafmt-core to 3.8.2 (#582) 2024-07-16 10:18:31 -07:00
xerial-bot
98e9b432b8
Update airframe-log to 24.5.2 (#581) 2024-07-16 10:18:18 -07:00
xerial-bot
bfa55cb989
Update sbt to 1.10.1 (#585) 2024-07-16 10:18:04 -07:00
xerial-bot
26aa68b421
Update airframe-log to 24.5.0 (#578) 2024-05-13 11:32:28 -07:00
xerial-bot
3e829907d3
Update sbt to 1.10.0 (#577) 2024-05-13 11:32:21 -07:00
xerial-bot
fbcf0b2947
Update scalafmt-core to 3.8.1 (#571) 2024-04-29 23:05:00 -07:00
xerial-bot
709dc7bed0
Update airframe-log to 24.4.3 (#576) 2024-04-25 11:46:45 -07:00
Michael Osipov
2276a67375
Add up-to-date libraries for FreeBSD on amd64 and i386 archs (#570)
This fixes #556
2024-04-25 10:56:10 -07:00
xerial-bot
37fdbfa0b9
Update hadoop-common to 3.4.0 (#568)
* Update hadoop-common to 3.4.0

* Fix tests

* Fix for arm

---------

Co-authored-by: Taro L. Saito <leo@xerial.org>
2024-03-21 10:06:48 -07:00
xerial-bot
59bd3c6a00
Update airframe-log to 24.3.0 (#569) 2024-03-21 09:34:12 -07:00
xerial-bot
a63c11efe0
Update airframe-log to 24.2.3 (#566) 2024-03-18 22:33:25 -07:00
Adrian Woodhead
2e7b665b0f
doc: Fix javadoc links to new url for framing_format.txt (#565) 2024-02-27 10:43:34 -08:00
xerial-bot
4752b963a0
Update airframe-log to 24.2.2 (#564) 2024-02-26 11:50:46 -08:00
xerial-bot
bfb4b7fb6f
Update scalafmt-core to 3.8.0 (#560) 2024-02-26 11:50:39 -08:00
xerial-bot
ca38ae715c
Update sbt to 1.9.9 (#562) 2024-02-26 11:50:23 -08:00
xerial-bot
27d3b331a4
Update airframe-log to 24.2.0 (#561) 2024-02-21 09:20:35 -08:00
dependabot[bot]
296323110a
Bump jwlawson/actions-setup-cmake from 1.14 to 2.0 (#559)
Bumps [jwlawson/actions-setup-cmake](https://github.com/jwlawson/actions-setup-cmake) from 1.14 to 2.0.
- [Release notes](https://github.com/jwlawson/actions-setup-cmake/releases)
- [Commits](https://github.com/jwlawson/actions-setup-cmake/compare/v1.14...v2.0)

---
updated-dependencies:
- dependency-name: jwlawson/actions-setup-cmake
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 15:44:56 -08:00
dependabot[bot]
69dd99ae75
Bump peter-evans/create-pull-request from 5 to 6 (#558)
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v6)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 14:12:44 -08:00
dependabot[bot]
ea902cfb33
Bump release-drafter/release-drafter from 5 to 6 (#557)
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5 to 6.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](https://github.com/release-drafter/release-drafter/compare/v5...v6)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 14:12:36 -08:00
xerial-bot
7232cca1a1
Update sbt-osgi to 0.10.0 (#554) 2024-01-31 22:18:30 -08:00
xerial-bot
0fc566aa9a
Update airframe-log to 24.1.2 (#555) 2024-01-31 22:18:06 -08:00
xerial-bot
c76775fd6a
Update sbt-osgi to 0.9.11 (#553) 2024-01-26 00:59:32 -08:00
dependabot[bot]
98d4bafe42
Bump actions/cache from 3 to 4 (#552)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-26 00:59:25 -08:00
xerial-bot
ec801afc85
Update airframe-log to 24.1.1 (#551) 2024-01-18 12:33:47 -08:00
xerial-bot
a7fb7650e9
Update airframe-log to 24.1.0 (#550) 2024-01-16 19:47:52 -08:00
xerial-bot
ebfbdead18
Update sbt-osgi to 0.9.10 (#549) 2024-01-06 23:56:04 -08:00
xerial-bot
f54430e9d7
Update plexus-classworlds to 2.8.0 (#548) 2023-12-30 21:26:24 -08:00
xerial-bot
4b0900a835
Update airframe-log to 23.12.1 (#546) 2023-12-21 14:07:08 -08:00
xerial-bot
4e37150be6
Update airframe-log to 23.12.0 (#545) 2023-12-15 22:24:50 -08:00
xerial-bot
a13ad45c60
Update sbt to 1.9.8 (#544) 2023-12-15 22:24:42 -08:00
Leslie Zhai
bce1ff6c8d
[experimental] Add native lib for Linux loongarch64 (#526)
* Build on loongarch64

Signed-off-by: Leslie Zhai <zhaixiang@loongson.cn>

* Remove linux-loongarch64 dockcross

* Remove linux-loongarch64 from native-all

---------

Signed-off-by: Leslie Zhai <zhaixiang@loongson.cn>
2023-12-07 13:14:12 -08:00
dependabot[bot]
a072b39bb3
Bump actions/setup-java from 3 to 4 (#541)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-07 13:11:17 -08:00
xerial-bot
5e4442bd8b
Update scalafmt-core to 3.7.17 (#540) 2023-11-18 00:46:28 -08:00
xerial-bot
f43681045a
Update sbt-sonatype to 3.10.0 (#539) 2023-11-18 00:46:09 -08:00
xerial-bot
15ef8928c1
Update airframe-log to 23.11.3 (#538) 2023-11-15 21:10:55 -08:00
xerial-bot
b5f3246597
Update sbt-osgi to 0.9.9 (#534) 2023-11-02 14:12:16 -07:00
xerial-bot
5cce531e2d
Update airframe-log to 23.11.1 (#535) 2023-11-02 14:12:07 -07:00
xerial-bot
bb321e099a
Update scalafmt-core to 3.7.15 (#531) 2023-10-31 14:24:59 -07:00
xerial-bot
2ef01e39f5
Update airframe-log to 23.11.0 (#533) 2023-10-30 13:27:39 -07:00
xerial-bot
4b7c727018
Update sbt to 1.9.7 (#530) 2023-10-23 20:57:47 -07:00
xerial-bot
cc325aef28
Update airframe-log to 23.10.0 (#525) 2023-10-21 14:07:30 -07:00
xerial-bot
e62daac2d1
Update sbt-osgi to 0.9.8 (#529) 2023-10-21 14:06:34 -07:00
xerial-bot
d7356d5229
Update airframe-log to 23.9.3 (#524) 2023-09-30 21:48:37 -07:00
Łukasz Jernaś
cb30492b7a
Use matrix build for test workflow (#523)
Simplifies workflow file, by using a matrix build
instead of separate build jobs with same steps.
2023-09-30 21:48:13 -07:00
github-actions[bot]
08abfa4f85
Update native libraries for 4b2c1e89a42bc1fc715199974140f93cefe37d71 (#521)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-09-26 19:22:20 -07:00
Taro L. Saito
4b2c1e89a4
win-aarch64 (fix): Fix dll name (#520) 2023-09-26 18:06:29 -07:00
github-actions[bot]
0fff1ac8f5
Update native libraries for e6d1196bc68dd76d19e915ee0124c4d42b020ef2 (#519)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-09-26 13:34:23 -07:00
Taro L. Saito
e6d1196bc6
internal fix: Use Windows-aarch64 target name and compiler options (#518)
* internal fix: Use Windows-aarch64 target name

* Fix compiler

* Fix strip command

* Use the same compiler flags with other Windows
2023-09-26 11:08:32 -07:00
Taro L. Saito
3c67a7b51c
ppc64-le (Fix): Use an LTS-version of cross-compiler for Linux ppc64-le (#516)
* ppc64-le (Fix): Use an LTS-version of cross-compiler for Linux ppc64-le

* Update native libraries for 4764a47e75ed9cdccdf6959e7ade81770ff6f4dd (#517)

Co-authored-by: xerial <xerial@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-09-26 09:59:36 -07:00
dependabot[bot]
67f5d26981
Bump jwlawson/actions-setup-cmake from 1.13 to 1.14 (#514)
Bumps [jwlawson/actions-setup-cmake](https://github.com/jwlawson/actions-setup-cmake) from 1.13 to 1.14.
- [Release notes](https://github.com/jwlawson/actions-setup-cmake/releases)
- [Commits](https://github.com/jwlawson/actions-setup-cmake/compare/v1.13...v1.14)

---
updated-dependencies:
- dependency-name: jwlawson/actions-setup-cmake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-26 09:14:57 -07:00
Sudip Roy
ee96b64c7d
Feature: Add Windows arm64 support (#511)
* add arm64 support

* update Makefile
2023-09-26 09:14:40 -07:00
Vinesh Chemmala Paul
0016fed5b4
Fix GLIBC_2.32 not found error on IBM PowerPC LE RedHat 8.6 OS (required by /libsnappyjava.so) #512 (#515)
Co-authored-by: Vinesh Chemmala Paul <vpaul@cloudera.com>
2023-09-26 09:11:49 -07:00
Taro L. Saito
681b2e1b96
internal: Support JDK21 (#510)
* Test with JDK21

* Use setup-java

* fix test
2023-09-23 22:02:46 -07:00
BD
9f8c3cf742
Merge pull request from GHSA-55g7-9cwv-5qfv
* Validate chunk size to be within a configured maximum

* Add constructors to have max size configurable

* Code cleanup

* Use 512MB for consistency

---------

Co-authored-by: Taro L. Saito <leo@xerial.org>
2023-09-23 15:55:18 -07:00
xerial-bot
49d700175f
Update airframe-log to 23.9.2 (#509) 2023-09-23 15:10:34 -07:00
github-actions[bot]
1f07c3182c
Update native libraries for f2e97f27be0dc6c691369040ba8a673bface484c (#503)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-09-22 14:10:14 -07:00
xerial-bot
13f8db197c
Update sbt to 1.9.6 (#505) 2023-09-22 13:42:25 -07:00
Taro L. Saito
f2e97f27be
feature: Upgrade the internal snappy version to 1.1.10 (1.1.8 was wrongly used before) (#508)
* Upgrade to snappy 1.1.10 binary

* Use a specific snappy version

* Use cmake 3.16.x for mac-x86_64

* Add -ftemplate-depth for Mac x86_64 build
2023-09-22 13:41:36 -07:00
xerial-bot
98b22256fe
Update airframe-log to 23.9.1 (#504) 2023-09-12 09:31:07 -07:00
Sudip Roy
9f29b5c0f8
Update NOTICE (#492)
* Update NOTICE

Update Notice

* Update NOTICE
2023-09-12 09:30:32 -07:00
xerial-bot
55639b55de
Update sbt-scalafmt to 2.5.1 (#499)
Co-authored-by: Taro L. Saito <leo@xerial.org>
2023-09-11 23:56:17 -07:00
xerial-bot
a5d81a6589
Update airframe-log to 23.8.6 (#497) 2023-09-11 23:55:22 -07:00
xerial-bot
6495da1af2
Update scalafmt-core to 3.7.14 (#501) 2023-09-07 09:14:01 -07:00
xerial-bot
bc15373ad7
Update sbt-scalafmt to 2.5.2 (#500) 2023-09-05 07:24:37 -07:00
xerial-bot
bfda514819
Update sbt to 1.9.4 (#496) 2023-09-05 07:24:05 -07:00
dependabot[bot]
634e1a2dc4
Bump actions/checkout from 3 to 4 (#502)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 07:23:54 -07:00
xerial-bot
650587eb7b
Update airframe-log to 23.8.0 (#488) 2023-08-05 16:28:10 -07:00
xerial-bot
bfd480e696
Update scalafmt-core to 3.7.12 (#487) 2023-08-05 16:28:02 -07:00
xerial-bot
d4ca6e330b
Update airframe-log to 23.7.4 (#486) 2023-07-30 17:14:46 -07:00
xerial-bot
db7f7103ad
Update sbt to 1.9.3 (#483) 2023-07-30 17:14:38 -07:00
xerial-bot
b6c8227bf2
Update scalafmt-core to 3.7.11 (#485) 2023-07-30 17:14:31 -07:00
github-actions[bot]
25261c457e
Update native libraries for de674f6d73b534d89f2452aee190a0321356dceb (#482)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-07-21 10:31:50 -07:00
Kun Lu
de674f6d73
Fix the `GLIBC_2.32' not found issue on s390x (#481)
Signed-off-by: Kun-Lu <kun.lu@ibm.com>
2023-07-21 10:16:52 -07:00
xerial-bot
f3baef0707
Update scalafmt-core to 3.7.10 (#480) 2023-07-17 10:14:31 -07:00
xerial-bot
13b907da52
Update airframe-log to 23.7.2 (#479) 2023-07-13 09:06:46 -07:00
xerial-bot
589b5d36a5
Update sbt to 1.9.2 (#476) 2023-07-12 19:11:35 -07:00
xerial-bot
baa67e5d05
Update scalafmt-core to 3.7.9 (#478) 2023-07-12 19:11:19 -07:00
github-actions[bot]
119cf4ceed
Update native libraries for 33b6510b6bee303891d070ffc09a40bfc40bc71c (#475)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-07-11 10:06:06 -07:00
xerial-bot
67f8f8155b
Update airframe-log to 23.7.1 (#473) 2023-07-08 11:45:42 -07:00
xerial-bot
c8c8e1321b
Update scalafmt-core to 3.7.7 (#472) 2023-07-08 11:45:35 -07:00
Namrata Bhave
33b6510b6b
Update libsnappy.so for s390x (#474) 2023-07-08 11:44:08 -07:00
xerial-bot
f350a98189
Update airframe-log to 23.7.0 (#471) 2023-07-05 10:38:00 -07:00
xerial-bot
bfdb45e0e6
Update scalafmt-core to 3.7.6 (#470) 2023-07-05 10:37:53 -07:00
xerial-bot
d71e1584d0
Update sbt to 1.9.1 (#467) 2023-06-27 14:52:10 -07:00
xerial-bot
2c3b7005e1
Update airframe-log to 23.6.2 (#465) 2023-06-23 12:50:51 -07:00
xerial-bot
f8bc4cc078
Update airframe-log to 23.6.1 (#463) 2023-06-19 14:25:06 -07:00
xerial-bot
33441eec73
Update sbt-dynver to 5.0.1 (#461) 2023-06-16 14:55:43 -07:00
xerial-bot
8649a62eef
Update airframe-log to 23.6.0 (#460) 2023-06-14 16:53:52 -07:00
xerial-bot
60a0cad5cc
Update airframe-log to 23.5.7 (#458) 2023-06-14 16:39:19 -07:00
aidanchiu1112
737f3973ff
CI Fix to Prevent Checks Dealing with Large Array Sizes (#459)
* Fix spacing with comment

* Updated code

* Test: Added Assume catches for each failed tests

* Added and implemented separate method to check if System CI is false

* Added a null check to ensure assumingCIIsFalse() method runs locally as well

* Changed assumeTrue to assumeFalse
2023-06-14 14:51:14 -07:00
aidanchiu1112
d0042551e4
Merge pull request from GHSA-fjpj-2g6w-x25r
* Fixed integer overflow by checking if bytesize is bigger than input length, then throwing exception

* Fixed integer overflow by checking if bytesize is bigger than input length, then throwing exception

* Fixed integer overflow by checking if bytesize is bigger than input length, then throwing exception

* improved error messages by adding new error enum INPUT_TOO_LARGE in SnappyErrorCode.java, and added happy and sad cases in SnappyTest.java

* fixed mispelling: validArrayInputLength --> isInvalidArrayInputLength

* switched SnappyError into ILLEGAL_ARGUMENT in SnappyErrorCode.java and Snappy.java and fixed a typo in error comment

* Fix buffer size boundary tests

* Remove negative array size tests

* updated comments for unit test

---------

Co-authored-by: Taro L. Saito <leo@xerial.org>
2023-06-14 11:06:30 -07:00
aidanchiu1112
3bf67857fc
Merge pull request from GHSA-qcwq-55hx-v3vh
* asserted chunksize should be in the bounds of 0-java.outofmmeoryexception

* asserted chunksize should be in the bounds of 0-java.outofmmeoryexception

* https://github.com/xerial/snappy-java-ghsa-qcwq-55hx-v3vh/pull/2

* advisory-fix-3

* added and changed method name for happy and sad cases in SnappyTest.java

* removed expected error for happy case in unit testing

* added another unit test case in SnappyTest.java and fixed comments in SnappyInputStream.java

* switched SnappyError to INVALID_CHUNK_SIZE

* Updated unit tests

* Resolved conflicts with another PR merge
2023-06-14 10:49:52 -07:00
aidanchiu1112
820e2e074c
Merge pull request from GHSA-pqr6-cmr2-h8hf
* Fixed integer overflow by checking if multiplication result is smaller than original value

* Fixed integer overflow by checking if multiplication result is smaller than original value

* Fixed integer overflow by checking if multiplication result is smaller than original value

* imporved error messages and added happy and sad cases for unit test in SnappyTest.java

* switched SnappyError into ILLEGAL_ARGUMENT in SnappyErrorCode.java and Snappy.java

* wrote new and updated unit test methods

* updated comments in SnappyTest.java

* Fixed and updated unit tests in SnappyTest.java
2023-06-14 10:36:02 -07:00
aidanchiu1112
27e2ce0fb0
Fix typo (#457)
* Fix typo

* Fix spacing with comment
2023-06-06 11:58:45 -07:00
xerial-bot
f32d5b0d7c
Update sbt to 1.9.0 (#455)
* Update sbt to 1.9.0

* Run CI on sbt upgrade

---------

Co-authored-by: Taro L. Saito <leo@xerial.org>
2023-06-02 15:19:00 -07:00
xerial-bot
326f0b45ee
Update scalafmt-core to 3.7.4 (#454) 2023-06-02 10:46:56 -07:00
xerial-bot
b3895447ca
Update airframe-log to 23.5.6 (#453) 2023-06-02 10:46:45 -07:00
github-actions[bot]
256691eb1e
Update native libraries for 2737ea41c48e9ac12caf342191e4756626d31585 (#450)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-05-24 16:48:28 -07:00
Taro L. Saito
5c35a0ff12
intertnal: Fix CI watch target files (#451) 2023-05-24 23:46:16 +00:00
github-actions[bot]
2737ea41c4
Update native libraries for 38bf5689dc3286071570b1a5540e2c0326610cc3 (#445)
Co-authored-by: xerial <xerial@users.noreply.github.com>
2023-05-24 15:04:57 -07:00
Taro L. Saito
38bf5689dc
internal: Fix CI target branch (#449)
* internal: Run CI tests for update-native-libs branch

* Fix config

* Fix target branch
2023-05-24 21:43:00 +00:00
Taro L. Saito
b62a27f07a
internal: Run CI tests for update-native-libs branch (#448) 2023-05-24 21:40:07 +00:00
Taro L. Saito
20dd4675d7
internal: Fix commit message (#447) 2023-05-24 20:35:45 +00:00
Taro L. Saito
3bcc1c43e2
internal: Run CI tests on native file change (#446) 2023-05-24 20:28:20 +00:00
Sudip Roy
10f3b32d49
Trigger native lib build on PR (#444)
* trigger build native on PR and push

Signed-off-by: Sudip Roy <sudiproy1999@gmail.com>

* Add branch master

* Trigger native lib build only for PRs

* Test native lib build trigger

* Targetting the PR repo

* Add comment to trigger native lib build

* Fix syntax error

* Test with write permission

* Test with contents: write

* Test

* test

* Use gh pr checkout

* fix

* Add checkout phase

* test target repo:

* Try bot user

* clanup

* Use PAT

* Use different user

* simplify

* fix

* test

* Fix token

* revert

* Try push action

* use the same token

* fix tab

* Set ref

* Create a new PR for every master update

* fix

* fix indent

* Use native-all

---------

Signed-off-by: Sudip Roy <sudiproy1999@gmail.com>
Co-authored-by: Taro L. Saito <leo@xerial.org>
2023-05-24 20:08:53 +00:00
Taro L. Saito
d8c5b8e4b6
Add a note about creating new releases 2023-05-23 15:16:13 -07:00
Taro L. Saito
fd504023f1
Feature: Android arm64 support (#442)
* Feature: Support Linux android-arm64(aarch64)

* Add dockcross script

* Add native lib

* Add --no-cache for CI

* Revert "Add --no-cache for CI"

This reverts commit 0f2f05ba8eb88d178ed1e8a1a588b3419e58cd51.

* Add docker clean process

* Update native libraries

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-23 15:05:31 -07:00
Taro L. Saito
ad2e2d7378
Feature: Use LTS cross-compiler for Linux armv6/armv7 to use glibc 2.28 (#440)
* Feature: Use LTS cross-compiler for Linux armv6/armv7 to use glibc 2.28

* Use softfp for armv7

* Fix armv6 config

* Update native libraries

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-23 13:20:44 -07:00
xerial-bot
4faf2a3768
Update airframe-log to 23.5.5 (#441) 2023-05-23 13:16:24 -07:00
xerial-bot
d9b324ce43
Update airframe-log to 23.5.4 (#434) 2023-05-23 10:30:12 -07:00
Taro L. Saito
4181327265
Release snapshot versions when native libs are updated (#438) 2023-05-23 10:27:09 -07:00
Taro L. Saito
86ebb48261
Add a new native lib for Linux-arm (#436)
* use lts image for glibc compatibility

fixes #417

* Update dockcross-aarch64

* Update native libraries

---------

Co-authored-by: NersesAM <1935500+NersesAM@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-23 10:19:22 -07:00
Taro L. Saito
f92925a4ad
internal: Release note generation automation (#433) 2023-05-17 13:51:37 -07:00
xerial-bot
b780eae3a4
Update sbt-sonatype to 3.9.21 (#432) 2023-05-16 13:13:24 -07:00
Taro L. Saito
ccf61c1d06
Upgrade to Snappy 1.1.10 (#431)
* Upgrade to Snappy 1.1.10

* Update native libraries

* Add Mac silicon binary

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-16 11:44:01 -07:00
jzl
d72a2bc805
Fix: workaround io error 'stream closed' caused by bugs in URLClassloader (#412) 2023-05-16 11:06:13 -07:00
Sudip Roy
027c0c2703
add s390x support (#416) 2023-05-16 11:00:50 -07:00
xerial-bot
fba33f4eab
Update sbt to 1.8.3 (#430) 2023-05-16 11:00:33 -07:00
xerial-bot
0314c2501d
Update airframe-log to 23.5.3 (#428) 2023-05-09 16:55:25 -07:00
xerial-bot
bb51e7c8f2
Update sbt-sonatype to 3.9.20 (#427) 2023-05-09 16:55:18 -07:00
Taro L. Saito
e504c39559
Update SECURITY.md 2023-05-08 13:28:42 -07:00
Taro L. Saito
18c53d5311
Create SECURITY.md 2023-05-08 13:28:28 -07:00
xerial-bot
05c39b2ca9
Update airframe-log to 23.4.8 (#423) 2023-04-29 09:47:08 -07:00
xerial-bot
509fe727e6
Update airframe-log to 23.4.0 (#413) 2023-04-07 00:30:32 -07:00
xerial-bot
03fa8d0a83
Update airframe-log to 23.3.4 (#409) 2023-03-31 21:56:24 -07:00
xerial-bot
7f5cd56d65
Update scalafmt-core to 3.7.3 (#410) 2023-03-31 21:56:17 -07:00
xerial-bot
c5414ed458
Update airframe-log to 23.3.3 (#406) 2023-03-22 14:42:25 -07:00
xerial-bot
079725743f
Update airframe-log to 23.3.2 (#404) 2023-03-20 09:39:58 -07:00
xerial-bot
745d4c440f
Update sbt-sonatype to 3.9.18 (#402) 2023-03-09 23:19:12 -08:00
xerial-bot
180645b2ef
Update airframe-log to 23.3.0 (#401) 2023-03-09 23:19:05 -08:00
xerial-bot
e633200b11
Update airframe-log to 23.2.5 (#397) 2023-03-06 12:55:38 -08:00
xerial-bot
e2a4b5a596
Update scalafmt-core to 3.7.2 (#399)
* Update scalafmt-core to 3.7.2

* Reformat with scalafmt 3.7.2

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.7.2' to .git-blame-ignore-revs
2023-03-06 12:55:26 -08:00
dependabot[bot]
0957acd563
Bump olafurpg/setup-scala from 13 to 14 (#398)
Bumps [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) from 13 to 14.
- [Release notes](https://github.com/olafurpg/setup-scala/releases)
- [Commits](https://github.com/olafurpg/setup-scala/compare/v13...v14)

---
updated-dependencies:
- dependency-name: olafurpg/setup-scala
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 12:55:17 -08:00
Ludovic Henry
3c74e292ab
Add Linux-riscv64 support (#396) 2023-02-15 01:24:42 -08:00
xerial-bot
8845930790
Update airframe-log to 23.2.4 (#395) 2023-02-14 09:56:02 -08:00
xerial-bot
17aa698cdb
Update airframe-log to 23.2.0 (#391) 2023-02-03 16:21:32 -08:00
Taro L. Saito
39160ac5d2
Fix java8 compatibility (#390)
* ByteBuffer.limit() compiled with JDK9+ shows  java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer; error in JDK8
* Set --release 8 JDK option
* Do not use --release 8 option in JDK8
2023-01-31 10:35:03 -08:00
xerial-bot
5ad862e802
Update org.osgi.core to 6.0.0 (#387) 2023-01-29 19:21:23 -08:00
Taro L. Saito
8707c34446
Update Milestone.md 2023-01-28 18:25:16 -08:00
xerial-bot
1a82fe10b7
Update org.osgi.core to 4.3.1 (#315)
* Update org.osgi.core to 4.3.1

* Update org.osgi.core to 4.3.1

* Update org.osgi.core to 4.3.1

* Revert commit(s) 3c7e99c

* Update org.osgi.core to 4.3.1

* Revert commit(s) 3a0d82f

* Update org.osgi.core to 4.3.1

* Revert commit(s) db7539d

* Update org.osgi.core to 4.3.1

* Revert commit(s) a0551d9

* Update org.osgi.core to 4.3.1

* Revert commit(s) bcb986a

* Update org.osgi.core to 4.3.1

* Revert commit(s) 832ade4

* Update org.osgi.core to 4.3.1
2023-01-28 08:47:29 -08:00
Taro L. Saito
92b6c9e4d7
Remove snappy debug assertion with -DNDEBUG c++ flag (#386)
* Remoe snappy debug assertion with -DNDEBUG c++ flag

* Update native libraries

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-28 08:42:50 -08:00
Taro L. Saito
785d43066c
Update sbt script (#385) 2023-01-28 07:29:41 -08:00
xerial-bot
083827cf74
Update airframe-log to 23.1.4 (#383)
* Update airframe-log to 23.1.4

* Revert commit(s) 5f9eb46

* Update airframe-log to 23.1.4
2023-01-28 07:25:50 -08:00
Taro L. Saito
c515db5857
Add release automation workflow (#384) 2023-01-28 00:33:40 -08:00
Ashley Taylor
34fa6e9e65
Add uncompressDoubleArray that takes offset and length (#307) 2023-01-28 00:06:45 -08:00
Taro L. Saito
2bc841b5da
Remove pure-java support (#381)
* Remove pure-java snappy support

* Remove pure-java support description
2023-01-28 00:05:11 -08:00
Taro L. Saito
cecbb0d1e2
Build native library for Snappy 1.1.9 (#380)
* Fix dependency

* Add checkout step

* Remove tty option

* Fix compiler prefixes

* Fix arm compiler names

* Reorder for debug

* Fix

* Update dockcross-arm-android

* Remove system include

* Fix strip path

* Update native libraries

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-27 23:54:10 -08:00
Taro L. Saito
a794389cf2
Upgrade to snappy-1.1.9 (#379)
* Upgrade to snappy-1.1.9

* Add sbt-dynver

* Fix script so as not to requrie perl

* Upgrade bitshuffle to 0.5.1

* use bitshuffle 0.3.4, which can be compiled without errors

* Add native library build workflow
2023-01-27 22:33:12 -08:00
dependabot[bot]
ef87735ee9
Bump olafurpg/setup-scala from 10 to 13 (#375)
Bumps [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) from 10 to 13.
- [Release notes](https://github.com/olafurpg/setup-scala/releases)
- [Commits](https://github.com/olafurpg/setup-scala/compare/v10...v13)

---
updated-dependencies:
- dependency-name: olafurpg/setup-scala
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 20:47:38 -08:00
dependabot[bot]
608968912a
Bump actions/checkout from 2 to 3 (#376)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 20:39:42 -08:00
dependabot[bot]
e8dc8f387f
Bump actions/cache from 1 to 3 (#377)
Bumps [actions/cache](https://github.com/actions/cache) from 1 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 20:39:33 -08:00
Taro L. Saito
e030a78600
Add release drafter (#378) 2023-01-27 20:39:23 -08:00
Taro L. Saito
5a46383c4f
Add dependabot (#374) 2023-01-27 20:35:48 -08:00
Taro L. Saito
4dc5112a5a
Add scalafmt dialect (#373) 2023-01-27 20:34:03 -08:00
xerial-bot
e7be5b3c94
Update airframe-log to 22.12.6 (#372) 2023-01-27 20:30:46 -08:00
xerial-bot
21beeb5b54
Update hadoop-common to 2.10.2 (#371) 2023-01-27 20:30:37 -08:00
xerial-bot
5040e7c638
Update sbt-pgp to 2.2.1 (#361)
* Update sbt-pgp to 2.2.1

* Revert commit(s) d90c8ff

* Update sbt-pgp to 2.2.1

* Revert commit(s) 12e4f46

* Update sbt-pgp to 2.2.1
2023-01-27 20:30:28 -08:00
xerial-bot
f760098351
Update plexus-classworlds to 2.7.0 (#359) 2023-01-27 20:30:19 -08:00
xerial-bot
37623d64c3
Update scalafmt-core to 3.7.1 (#368)
* Update scalafmt-core to 3.7.1

* Revert commit(s) 9d02cdb

* Update scalafmt-core to 3.7.1
2023-01-27 20:30:02 -08:00
xerial-bot
1247939d22
Update airframe-log to 22.9.3 (#349) 2023-01-27 17:18:20 -08:00
xerial-bot
76f8ff902b
Update hadoop-common to 2.7.7 (#313)
* Update hadoop-common to 2.7.7

* Update hadoop-common to 2.7.7

* Revert commit(s) 93b35c0

* Update hadoop-common to 2.7.7
2023-01-27 17:18:12 -08:00
xerial-bot
d971f545f9
Update scalafmt-core to 3.5.9 (#344) 2023-01-27 17:17:59 -08:00
xerial-bot
60758d8353
Update sbt-scalafmt to 2.5.0 (#358) 2023-01-27 17:17:51 -08:00
xerial-bot
b4ef07f9c3
Update sbt to 1.8.2 (#366) 2023-01-27 17:17:33 -08:00
xerial-bot
448679cf77
Update sbt-sonatype to 3.9.17 (#370) 2023-01-27 17:17:26 -08:00
xerial-bot
be7958f6e3
Update sbt to 1.7.3 (#355) 2022-12-05 22:14:18 -08:00
xerial-bot
d74fcf63c2
Update sbt-sonatype to 3.9.15 (#360) 2022-12-05 22:14:09 -08:00
xerial-bot
169facb1a5
Update sbt-sonatype to 3.9.14 (#357) 2022-11-08 12:06:50 -08:00
valery1707
679b9b4b88
Fix links in Javadoc badge (#350) 2022-11-04 13:47:58 -07:00
valery1707
7b4564566a
Fix links into benchmark results (#351) 2022-11-04 13:47:32 -07:00
Yuming Wang
681da2d4ae
Add Java 17 build test to GitHub action (#346) 2022-10-11 10:16:45 -07:00
xerial-bot
3885fb05e8
Update airframe-log to 22.9.2 (#347) 2022-09-26 16:22:57 -07:00
xerial-bot
f4dd0a5f0f
Update scalafmt-core to 2.7.5 (#323) 2022-09-16 17:08:24 -07:00
xerial-bot
35de895018
Update sbt to 1.7.1 (#336) 2022-09-16 17:08:17 -07:00
xerial-bot
70ccd324da
Update airframe-log to 22.9.0 (#343) 2022-09-16 17:08:07 -07:00
lehnerj
8ecc597a0e
Fixes xerial/snappy-java#280 Typo - java.io.tmpdir not java.io.tempdir (#325)
Co-authored-by: Josef Lehner <josef1207@googlemail.com>
2022-06-21 20:19:42 +09:00
xerial-bot
e4fb87eabf
Update sbt-scalafmt to 2.4.6 (#317)
* Update sbt-scalafmt to 2.4.6

* Update sbt-scalafmt to 2.4.6
2022-06-03 13:46:49 -07:00
xerial-bot
5a6b5b29ec
Update scalafmt-core to 2.6.4 (#318)
* Update scalafmt-core to 2.6.4

* Reformat with scalafmt 2.6.4
2022-06-03 13:46:35 -07:00
xerial-bot
2b34d549aa
Update airframe-log to 21.12.1 (#319)
* Update airframe-log to 21.12.1

* Update airframe-log to 21.12.1
2022-06-03 13:46:24 -07:00
xerial-bot
0e659e947e
Update sbt-sonatype to 3.9.13 (#320)
* Update sbt-sonatype to 3.9.13

* Update sbt-sonatype to 3.9.13
2022-06-03 13:46:10 -07:00
xerial-bot
f281c0ac68
Update sbt to 1.6.2 (#321) 2022-06-03 13:46:03 -07:00
xerial-bot
0d074b838e
Update sbt to 1.5.8 (#316) 2022-06-01 23:39:55 -07:00
xerial-bot
e2dc50bb05
Update sbt-osgi to 0.9.6 (#312) 2022-06-01 23:39:36 -07:00
xerial-bot
a80d68d734
Update junit-interface to 0.13.3 (#311) 2022-06-01 23:39:25 -07:00
Mikhail Zhukov
78354b69c7
#302 Fixed running snappy-java as OSGi bundle on Apple Silicon (M1 Pro) (#303)
Co-authored-by: Mikhail Zhukov <zh.muxa@gmail.com>
2022-05-17 23:31:48 -07:00
Taro L. Saito
1d01f870a1
Upgrade sbt to 1.5.6 (#301) 2021-12-09 23:08:39 -08:00
Liang-Chi Hsieh
19cfc8d9a8
Use original compressed/uncompressed buffer's position. (#293) 2021-10-20 00:06:34 -07:00
Liang-Chi Hsieh
f3d7c11a02
Avoid explicit class name in throw_exception. (#291) 2021-10-20 00:06:01 -07:00
Attila Kocsis
2702f510e8
Small typo fix (#294) 2021-10-20 00:04:54 -07:00
Abhijit-Mane
a77381b794
Adding ppc64le support in Travis (#286)
Signed-off-by: Abhijit Mane <abhijman@in.ibm.com>
2021-08-05 22:15:33 -07:00
Alexander Zinovyev
3261bb1902
Added flags for riscv64 (#283) 2021-05-22 00:59:50 -07:00
Taro L. Saito
fd28fd029c
Setting version to 1.1.8.5-SNAPSHOT 2021-01-25 07:29:43 -08:00
Taro L. Saito
a795d6b84c
Setting version to 1.1.8.4 2021-01-25 07:25:23 -08:00
Taro L. Saito
75a03b54fd
Setting version to 1.1.8.4-SNAPSHOT 2021-01-20 11:57:25 -08:00
Taro L. Saito
f938b2cdd0
Setting version to 1.1.8.3 2021-01-20 11:52:39 -08:00
Taro L. Saito
44db30a72e
ADd 1.1.8.3 release notes 2021-01-20 11:51:39 -08:00
Brett Okken
822513dbe6
Prefer use of java.util.zip.CRC32C for Framed format (#269)
Co-authored-by: BO8979 <BO8979@W1971362.northamerica.cerner.net>
2021-01-20 11:30:19 -08:00
Brett Okken
110727ed69
Pool table instances to make PureJavaSnappy thread safe (#271)
https://github.com/xerial/snappy-java/issues/270

Co-authored-by: BO8979 <BO8979@W1971362.northamerica.cerner.net>
2021-01-20 11:20:22 -08:00
Taro L. Saito
7f47cf744a
1.1.8.2 release notes 2020-11-28 10:13:58 -08:00
Taro L. Saito
2191e85199
Setting version to 1.1.8.3-SNAPSHOT 2020-11-28 10:12:11 -08:00
Taro L. Saito
b38d6412ec
Setting version to 1.1.8.2 2020-11-28 10:10:35 -08:00
Taro L. Saito
a1f4fa3b10 Fix pure-java fallback 2020-11-28 09:46:07 -08:00
Taro L. Saito
585c6a135e Merge branch 'master' of github.com:xerial/snappy-java 2020-11-28 09:23:16 -08:00
Taro L. Saito
5c556b4964
Upgrade setup-scala to v10 2020-11-28 09:16:51 -08:00
Taro L. Saito
9471b0417e Ignore vscode releated files 2020-11-28 09:14:08 -08:00
Taro L. Saito
ab18bdb457
Add a binary for Apple Silicon (M1) (#268) 2020-11-28 09:12:41 -08:00
Taro L. Saito
47168b2f03
1.1.8.1 release notes 2020-11-09 09:04:42 -08:00
Taro L. Saito
a73e92aecc
Setting version to 1.1.8.2-SNAPSHOT 2020-11-09 09:02:06 -08:00
Taro L. Saito
9ceebb8c21
Setting version to 1.1.8.1 2020-11-09 08:57:28 -08:00
Taro L. Saito
84e68fe3c1
Rebuild mac64 binary 2020-11-09 08:55:32 -08:00
Benedict Jin
1c4a0e31e9
Fix Could not initialize class org.xerial.snappy.Snappy bug for MacOS 19.6.0 (#265)
* Fix `Could not initialize class org.xerial.snappy.Snappy` bug for MacOS

* Remove useless libsnappyjava.jnilib
2020-11-08 22:51:50 -08:00
Taro L. Saito
9532de9459
Fixes #257: Use a patched version of crossbuild Docker image for mac64 target (#264) 2020-10-22 14:28:39 -07:00
Taro L. Saito
5df2667f0e
Fix markdown 2020-10-20 21:47:43 -07:00
Taro L. Saito
126a1f4e2a
Fix readme 2020-10-20 21:46:49 -07:00
Taro L. Saito
d884e957a8
Setting version to 1.1.8.1-SNAPSHOT 2020-10-20 21:37:03 -07:00
Taro L. Saito
477b7c7e92
Setting version to 1.1.8 2020-10-20 21:35:45 -07:00
Taro L. Saito
a300c63060
Upgrade to snappy 1.1.8 (#258) 2020-10-20 21:34:28 -07:00
Taro L. Saito
f73bb7e1ed
Setting version to 1.1.7.9-SNAPSHOT 2020-10-20 21:05:34 -07:00
Taro L. Saito
56133ad7ec
Setting version to 1.1.7.8 2020-10-20 21:04:12 -07:00
Taro L. Saito
f30210faaa
snappy-java-1.1.7.8 release notes 2020-10-20 21:03:18 -07:00
Russell Shaw
f368c0c7b9
Add Big Endian support to Pure Java Snappy (#254)
* Add Big Endian support to Pure Java Snappy

* Support Big Endian. Separated Little and Big Endian methods for performance reasons

* Big Endian support - made a separate interface so no performance issues

* Big Endian support update - Remove trivial whitespace/tab changes which othewise come up in diff report

* Add newline to end of source for githib diff report

* Big Endian Support - simplified changes as peformance hit is not significant

* Big Endian Support - fix typo

* Fix typo

* Update SnappyLoader.java

Converted TAB char to spaces

* Revert back to original code

Co-authored-by: Russell Shaw <russell@Russells-MacBook-Pro.local>
2020-10-20 18:03:58 -07:00
Taro L. Saito
fd26e3914d Add a fix for android-arm 2020-10-20 17:52:53 -07:00
Taro L. Saito
015b8a17b3 Fix comment 2020-10-20 17:52:53 -07:00
Taro L. Saito
336dd795f3 Set the minimum maxosx version to 10.7 to resolve libc++ linker issue 2020-10-20 17:52:53 -07:00
Taro L. Saito
173832eda7 Fix native-all task 2020-10-20 17:52:53 -07:00
Taro L. Saito
c0e82b9a47 Rebuild armv7 native binary 2020-10-20 17:52:53 -07:00
Taro L. Saito
3d4fd649d0 Fix armv7 build 2020-10-20 17:52:53 -07:00
Taro L. Saito
1fba891de8 Fix arm64 build 2020-10-20 17:52:53 -07:00
Masatake Iwasaki
150083ca57
Using latest multiarch/crossbuild since we need cmake 3.1 or higher for building snappy 1.1.7. (#261) 2020-10-20 10:02:39 -07:00
Masatake Iwasaki
a1f6977faa
Add -static-libstdc++ on LINKFLAGS of aarch64. (#256) 2020-09-08 09:20:10 -07:00
Taro L. Saito
1d1af59c06
1.1.7.7 release notes 2020-08-25 21:16:01 -07:00
Taro L. Saito
3a9e115f9c
Setting version to 1.1.7.8-SNAPSHOT 2020-08-25 21:10:52 -07:00
Taro L. Saito
5f06afd242
Setting version to 1.1.7.7 2020-08-25 21:07:11 -07:00
Taro L. Saito
6cbc623c96
Try setting javacOptions scope 2020-08-25 21:06:38 -07:00
Taro L. Saito
0a7f5b3b4f
Update README.md 2020-06-26 01:08:32 -07:00
Taro L. Saito
bb1c668e96
Fix maven central link 2020-06-26 01:07:04 -07:00
Taro L. Saito
0ccff5c465
Setting version to 1.1.7.7-SNAPSHOT 2020-06-26 00:39:15 -07:00
Taro L. Saito
967d280f48
Setting version to 1.1.7.6 2020-06-26 00:35:10 -07:00
Taro L. Saito
caf0f35716
snappy-java 1.1.7.6 release notes 2020-06-26 00:34:34 -07:00
Taro L. Saito
a89a36bea1
Simplified build.sbt 2020-06-26 00:23:44 -07:00
Taro L. Saito
cc1a886cb6
Remove unnecessary settings 2020-06-26 00:13:32 -07:00
Taro L. Saito
eb341bf08f
remove unused import 2020-06-26 00:10:40 -07:00
Taro L. Saito
cbe9a091e7
Fix release steps 2020-06-26 00:01:36 -07:00
Taro L. Saito
1412036023
test snapshot release 2020-06-25 23:56:43 -07:00
Taro L. Saito
34f014de5e
Publish snapshots 2020-06-25 23:54:44 -07:00
Taro L. Saito
7082397d2d
Use GitHub Actions (#250)
* Use GitHub Actions
* Ignore SnappyHadoopComptibleOutputStreamTest
* Build only master branches
* Simplify travis build
* Remove jvm option, which doesn't work for s390x
2020-06-25 23:51:45 -07:00
Namrata Bhave
5a750503cd
Adding s390x support in Travis (#237)
* Adding s390x support

* Remove jdk8 test for s390x

* We need to use scala

* Updating java installation steps for s390x build

Co-authored-by: Taro L. Saito <leo@xerial.org>
2020-06-25 19:52:48 -07:00
Taro L. Saito
0c097c2e6a Enforce target to JDK7 2020-06-25 19:42:39 -07:00
Taro L. Saito
377d3577ca Reformat 2020-06-25 19:42:39 -07:00
Taro L. Saito
0c71fb5a90 Upgrade sbt and other sbt plugins 2020-06-25 19:42:39 -07:00
Taro L. Saito
594ca5fddb
Add pure-java Snappy implementation (#244)
* Add PureJavaSnappy
* Add more tests for pure-java snappy
* Add note on enabling pure-java mode
* Add org.xerial.snappy.pure to osgi bundle
2020-05-11 23:48:43 -07:00
Taro L. Saito
edc4ec28bd
1.1.7.5 relase notes 2020-05-06 10:30:52 -07:00
Taro L. Saito
30fc6f3a16
Setting version to 1.1.7.6-SNAPSHOT 2020-05-06 10:28:09 -07:00
Taro L. Saito
0f223298ba
#245: Include org.xerial.snappy.pool package 2020-05-06 10:26:51 -07:00
Taro L. Saito
c068574a2a
Setting version to 1.1.7.5 2020-05-06 10:22:56 -07:00
Taro L. Saito
13794eba53
Update Milestone.md 2020-05-05 11:20:44 -07:00
Taro L. Saito
bdf8ab10b4
Setting version to 1.1.7.5-SNAPSHOT 2020-05-05 09:45:27 -07:00
Taro L. Saito
38b5af815f
Setting version to 1.1.7.4 2020-05-05 09:44:05 -07:00
Taro L. Saito
f48aef4e4d
1.1.7.4 release notes 2020-05-05 09:42:26 -07:00
Brett Okken
e94001da2e
Pool byte[] and direct ByteBuffer (#234)
* https://github.com/xerial/snappy-java/issues/233

Pool byte[] and direct ByteBuffer instances for reuse by Framed
implementation.

* Remove use of google VisibleForTesting annotation

https://github.com/xerial/snappy-java/issues/233

* javadoc
2020-05-04 11:13:46 -07:00
Marshall Pierce
990f73398d Use javac -h instead of javah (#238)
This allows it to build on JDK10.
2019-12-13 14:58:28 -08:00
Josiah Samuel
8faa1d8171 update libsnappyjava.so for ppc64le to make it compat with rhel 7 (#236)
* update libsnappyjava.so for ppc64le to make it compat with rhel 7

* move linkflag to Makefile.common
2019-11-27 22:31:48 -08:00
Taro L. Saito
acaca7f9b1 Use LF for sbt script 2019-11-09 02:35:32 +00:00
Taro L. Saito
9df6ed7bbc
Upgrade to JDK11 including dependencies (#230) 2019-03-29 13:27:47 -07:00
Taro L. Saito
9ad35088c3
Add 1.1.7.3 release notes 2019-03-25 21:38:48 -07:00
Taro L. Saito
d8277970cc
Setting version to 1.1.7.4-SNAPSHOT 2019-03-25 21:30:35 -07:00
Taro L. Saito
f6aa5256a3
Setting version to 1.1.7.3 2019-03-25 21:27:35 -07:00
Neil
79697cf3d4 change snappyOutputStream writeHeader order to fix when outputStream… (#229)
* change snappyOutputStream  writeHeader order to fix when outputStream doest't write bytes, it will also generate a snappy header after closed
2019-03-25 20:59:24 -07:00
Taro L. Saito
de99182a82
Merge pull request #228 from bokken/master
java 9 valid direct byte buffer release
2019-03-21 15:10:46 -07:00
Brett Okken
26eb048c45 java 9 valid direct byte buffer release 2019-01-14 14:43:51 -06:00
Taro L. Saito
820038c974
Merge pull request #218 from TJC/docs-for-file-format-compat
Add README detail around file format compatibility
2018-08-06 19:39:58 -07:00
Toby Corkindale
b40dffc4b9 Add README detail around file format compatibility 2018-08-06 11:03:32 +10:00
Taro L. Saito
73c67c7030
Remove version eye badge 2018-05-25 09:38:52 -07:00
Taro L. Saito
fc7cc3c285 Add 1.1.7.2 release notes 2018-05-21 11:22:46 -07:00
Taro L. Saito
03c4273aa4 Setting version to 1.1.7.3-SNAPSHOT 2018-05-21 11:19:32 -07:00
Taro L. Saito
e9a6ad470e Setting version to 1.1.7.2 2018-05-21 11:18:49 -07:00
Taro L. Saito
0215276a14
Merge pull request #213 from ossdev07/snappy-java
Failure of snappy-java 1.1.7 test cases due to isValidCompressedBuffer() on AARCH64
2018-05-21 11:13:49 -07:00
ossdev
40ebc5a48e Failure of snappy-java 1.1.7 test cases due to isValidCompressedBuffer() on AARCH64 architecture 2018-05-14 19:23:04 +05:30
Taro L. Saito
a9a45d3cd0
Merge pull request #211 from tolbertam/issue/210
Add OSGi bundle metadata to manifest
2018-02-26 10:14:54 -08:00
Andrew Tolbert
6e35813580
[#210]: Add OSGi bundle metadata to manifest 2018-02-23 15:45:13 -06:00
Taro L. Saito
aed3843f8e
Merge pull request #206 from xuchuanyin/opt_output_doc
[DOC] Optimize SnappyOutputStream java doc
2018-01-23 01:30:17 -08:00
xuchuanyin
0bdda0f23d
Optimize SnappyOutputStream java doc
Add more information about output data format
2018-01-23 15:23:18 +08:00
Taro L. Saito
118aa3e6d2 Setting version to 1.1.7.2-SNAPSHOT 2017-12-07 11:51:26 -08:00
Taro L. Saito
454bb54306 Setting version to 1.1.7.1 2017-12-07 11:49:26 -08:00
Taro L. Saito
d1a6d037d9 Add 1.1.7.1 release notes 2017-12-07 11:48:38 -08:00
Taro L. Saito
705f94997b
Merge pull request #198 from xerial/fix-android-folder-name
#174: Fix folder name for android
2017-12-07 11:47:24 -08:00
Taro L. Saito
8a3538bc51 Remove unnecessary scala version setting 2017-12-01 16:26:13 -08:00
Taro L. Saito
1c527cb9e0 Rename 2017-12-01 16:15:22 -08:00
Taro L. Saito
cda5eb03e2 Fix deploy script so as not to push release version 2017-12-01 16:07:29 -08:00
Taro L. Saito
2f38b2eae6 Add makefile for building centos5 docker image 2017-12-01 14:10:24 -08:00
Taro L. Saito
4eaa9a269c Use 1.1.7.1-SNAPSHOT 2017-12-01 11:04:19 -08:00
Taro L. Saito
6514348da0 #174: Fix folder name for android 2017-12-01 11:03:06 -08:00
Taro L. Saito
8686318c2c
Update Milestone.md 2017-12-01 10:22:35 -08:00
Taro L. Saito
9c36cfa959
Update javadoc badge 2017-11-30 22:28:19 -08:00
Taro L. Saito
0ca520d245 Setting version to 1.1.8-SNAPSHOT 2017-11-30 17:00:32 -08:00
Taro L. Saito
0eac781725 Setting version to 1.1.7 2017-11-30 16:59:42 -08:00
Taro L. Saito
417ab3eefb Add 1.1.7 release notes 2017-11-30 16:56:28 -08:00
Taro L. Saito
a468d08bca Resolve android type first 2017-11-30 16:43:25 -08:00
Taro L. Saito
039082d8f8 Add cmake result headers for Linux centos5 build 2017-11-30 16:43:16 -08:00
Taro L. Saito
6b2384d65c centos5 cannot use cmake3, so provide pre-configured header files instead 2017-11-30 16:39:16 -08:00
Taro L. Saito
64e9238f6c Need to have C++11 supported g++ to build cmake 2017-11-30 15:00:12 -08:00
Taro L. Saito
abb3700425 fBuild the latest cmake-3.10 for linux docker image 2017-11-30 14:51:46 -08:00
Taro L. Saito
1351428198 centos5 is nor EOL. Update Dockerfile to use a new mirror and add cmake to build linux binaries 2017-11-30 14:43:57 -08:00
Taro L. Saito
0587ad5bdb Rebuild arm binaries 2017-11-30 14:29:14 -08:00
Taro L. Saito
8ea939adea Rebuild mac binary 2017-11-30 14:27:21 -08:00
Taro L. Saito
d2ed365d98 Rebuild win binaries 2017-11-30 14:26:25 -08:00
Taro L. Saito
ff246c935e
Merge pull request #197 from odaira/snappy-1.1.7-Linux-ppc64
Update Linux/ppc64/libsnappyjava.so and add Linux/ppc/libsnappyjava.so
2017-11-30 13:32:57 -08:00
Rei Odaira
544a05f7aa Update Linux/ppc64/libsnappyjava.so and add Linux/ppc/libsnappyjava.so 2017-11-30 01:51:32 +00:00
Taro L. Saito
411639cfd2
Merge pull request #196 from odaira/snappy-1.1.7-AIX-ppc
Update AIX/ppc/libsnappyjava.a and AIX/ppc64/libsnappyjava.a
2017-11-29 00:01:13 -08:00
Rei Odaira
319bc402d0 Update AIX/ppc/libsnappyjava.a and AIX/ppc64/libsnappyjava.a 2017-11-28 18:46:42 -08:00
Taro L. Saito
2f190db71d
Merge pull request #195 from odaira/snappy-1.1.7-Linux-s390x
Update Linux/s390x/libsnappyjava.so
2017-11-28 14:07:32 -08:00
Rei Odaira
93e6478a2a Update Linux/s390x/libsnappyjava.so 2017-11-27 19:07:13 -05:00
Taro L. Saito
d5c089e8ea
Merge pull request #194 from odaira/clean-up-build-process
Use config.h and snappy-stubs-public.h generated by cmake
2017-11-26 16:52:14 -08:00
Rei Odaira
23cca45a0f Use config.h and snappy-stubs-public.h generated by cmake on any platform 2017-11-23 23:02:49 -06:00
Taro L. Saito
ba3810299c
Merge pull request #192 from odaira/snappy-1.1.7-Linux-ppc64le
Update Linux/ppc64le/libsnappyjava.so
2017-11-16 11:27:59 -08:00
Rei Odaira
13299c1fda Update Linux/ppc64le/libsnappyjava.so 2017-11-16 13:15:41 -06:00
Taro L. Saito
8679292703
Merge pull request #191 from odaira/run-snappy-header
Run snappy-header target to generate snappy-stubs-public.h
2017-11-16 09:20:41 -08:00
Rei Odaira
6a6ea45c4f Run snappy-header target to generate snappy-stubs-public.h 2017-11-16 11:02:46 -06:00
Taro L. Saito
a450805eeb Optimize for aarch64 big-endian 2017-11-15 19:08:47 -08:00
Taro L. Saito
1b7cc6444d
Merge pull request #190 from winston-zillow/compatibility-matrix-hadoop
Update compatiblity matrix for hadoop output steeam
2017-11-15 17:42:33 -08:00
winstonq
dcdcc473b8 Update compatiblity matrix for hadoop output steeam 2017-11-15 17:33:01 -08:00
Taro L. Saito
1ce0d34f27
Merge pull request #189 from xerial/winston-zillow-master
Add Hadoop compatible Snappyt output stream
2017-11-15 15:06:55 -08:00
Taro L. Saito
a00267a687 Add guard for the other OSes 2017-11-15 15:01:41 -08:00
Taro L. Saito
f8327ae087 Add Hadoop compatible Snappyt output stream 2017-11-15 14:56:29 -08:00
Taro L. Saito
5ed8f91449
Merge pull request #188 from xerial/revert-187-winston-zillow-master
Revert "Follow-up of #176"
2017-11-15 14:44:03 -08:00
Taro L. Saito
fd4adf0931
Revert "Follow-up of #176" 2017-11-15 14:43:49 -08:00
Taro L. Saito
300e7eac4e
Merge pull request #187 from xerial/winston-zillow-master
Follow-up of #176
2017-11-15 14:42:39 -08:00
Taro L. Saito
9511da379d Add guard for the other OSes 2017-11-15 14:30:05 -08:00
Taro L. Saito
f80b3f0041 Merge master 2017-11-15 14:21:43 -08:00
Taro L. Saito
a5de996866
Merge pull request #185 from xerial/snappy-1.1.7
Upgrade to snappy 1.1.7
2017-11-15 13:17:22 -08:00
Taro L. Saito
fb51d60017 Ad aarch64 library 2017-11-15 13:14:28 -08:00
Taro L. Saito
1cf9516cd1 Remove jdk7 target, which doesn't work in Travis + sbt1.0 2017-11-15 13:03:46 -08:00
Taro L. Saito
989e714bad Run cmake only for Windows 2017-11-15 12:31:07 -08:00
Taro L. Saito
b90841e676 Run cmake first to create snappy-stubs-public.h for windows 2017-11-15 12:16:41 -08:00
Taro L. Saito
5427c222a1 Use airframe-log for Scala 2.12 2017-11-14 12:48:03 -08:00
Taro L. Saito
1695a7f365 Use Scala 2.12 for building{ 2017-11-14 12:00:05 -08:00
Taro L. Saito
51711eee17 Apply scalafmt 2017-11-14 11:55:03 -08:00
Taro L. Saito
64d2274d30 Upgrade to sbt-1.0.3 2017-11-14 11:54:11 -08:00
Taro L. Saito
4ff7447abf Add native libs excpet win and freebsd 2017-11-14 11:37:04 -08:00
Taro L. Saito
3c570c9081 Upgrade to snappy 1.1.7 2017-11-14 00:18:27 -08:00
Taro L. Saito
7133ff6168 Update release notes 2017-05-22 09:12:27 -07:00
Taro L. Saito
73262d37e0 Update release notes 2017-05-22 09:11:42 -07:00
Taro L. Saito
b0a242aac0 Setting version to 1.1.5-SNAPSHOT 2017-05-22 09:05:26 -07:00
Taro L. Saito
952fc5ec41 Setting version to 1.1.4 2017-05-22 09:03:15 -07:00
Taro L. Saito
1aeaf20c8d Add release note for 1.1.4 2017-05-22 09:02:45 -07:00
Taro L. Saito
a9aa74e316 Merge pull request #172 from lbergelson/lb_fix_typos_in_milestone
fix typos in Milestone.md
2017-03-26 21:29:28 -07:00
Louis Bergelson
c2478c8cf4 fix typos in Milestone.md
fixed a few misspellings in Milestone.md
2017-03-24 14:37:08 -04:00
xerial
cccc33cb05 Setting version to 1.1.4-SNAPSHOT 2017-02-16 10:19:39 -08:00
xerial
9f9241a4ab Setting version to 1.1.4-M3 2017-02-16 10:19:01 -08:00
xerial
b2901ee3fd Add release notes for 1.1.4-M3 2017-02-16 10:18:14 -08:00
Taro L. Saito
b6a1dea6ff Merge pull request #170 from odaira/linux-ppc64-support
Updated Linux/ppc64/libsnappyjava.so
2017-02-16 10:15:08 -08:00
Rei Odaira
b0a4d47ab7 Updated Linux/ppc64/libsnappyjava.so 2017-02-16 05:55:35 +00:00
Taro L. Saito
6699b66367 Merge pull request #169 from xerial/ppc64le-fix
Fix ppc64/ppc64 libraries
2017-02-15 14:57:23 -08:00
Taro L. Saito
e20494cfb2 Remove ppc64. Rebuild ppc64le 2017-02-14 22:26:06 -08:00
Taro L. Saito
3497e732ce #168: Add ppc64 target 2017-02-14 08:20:08 -08:00
Taro L. Saito
ee4d27b16b #168: Rename dockcross script name 2017-02-14 07:48:33 -08:00
Taro L. Saito
2a6e0c3040 #168: Rename to ppc64le (little-endian) 2017-02-14 07:46:30 -08:00
xerial
9cf04cdd6e Setting version to 1.1.4-SNAPSHOT 2017-02-13 11:41:57 -08:00
xerial
32060010ea Setting version to 1.1.4-M2 2017-02-13 11:41:34 -08:00
xerial
6b11e40607 Add 1.1.4-M2 release note 2017-02-13 11:40:38 -08:00
Taro L. Saito
361d5ed4ba Merge pull request #167 from odaira/aix_ppc_support
Updated libsnappyjava and Makefile for AIX
2017-02-13 11:36:57 -08:00
Rei Odaira
0c73a857a2 Updated libsnappyjava and Makefile for AIX 2017-02-13 07:35:12 -08:00
Taro L. Saito
0ab9de29cb Merge pull request #165 from odaira/s390x_support
Updated Linux/s390x/libsnappyjava.so
2017-02-12 21:26:48 -08:00
Rei Odaira
cfaa5825a2 Updated Linux/s390x/libsnappyjava.so 2017-02-11 10:49:02 -05:00
xerial
384b51dd94 Setting version to 1.1.4-SNAPSHOT 2017-02-10 17:07:13 -08:00
xerial
ba5a2530ca Setting version to 1.1.4-M1 2017-02-10 17:06:53 -08:00
xerial
56536a8c37 Add release notes for 1.1.4-M1 2017-02-10 17:06:27 -08:00
Taro L. Saito
c794c99671 Merge pull request #164 from xerial/maropu-UpgradeBitShuffleTo0.3.1
Upgrade bit shuffle to 0.3.2
2017-02-10 17:03:18 -08:00
xerial
7977821eec #163: Build native libraries for bitshuffle 0.3.2 2017-02-10 16:53:20 -08:00
xerial
d3dfa2f2eb Merge branch 'UpgradeBitShuffleTo0.3.1' of https://github.com/maropu/snappy-java into maropu-UpgradeBitShuffleTo0.3.1 2017-02-10 16:51:28 -08:00
Takeshi Yamamuro
4f644cc13e Upgrade bitshuffle to v0.3.2 2017-02-10 06:19:49 -05:00
Taro L. Saito
c20e36ce3f Add reference badge 2017-02-09 14:06:52 -08:00
xerial
2ba15eb0d8 Merge branch 'UpgradeBitShuffleTo0.3.1' of https://github.com/maropu/snappy-java into maropu-UpgradeBitShuffleTo0.3.1 2017-02-07 10:43:40 -08:00
Taro L. Saito
7c6bc8334e Add note on snappy 1.1.4 2017-02-06 23:04:13 -08:00
Takeshi Yamamuro
a31ada5a69 Upgrade bitshuffle to v0.3.1 2017-02-07 15:58:52 +09:00
Taro L. Saito
76667420ec Merge pull request #162 from xerial/1.1.4
Upgrade to snappy-1.1.4
2017-02-06 22:46:31 -08:00
xerial
f3bc28ece4 Upgrade to snappy-1.1.4 2017-02-06 14:40:09 -08:00
Taro L. Saito
18d429e646 Merge pull request #159 from odaira/myWork
Update the expected binary size for big-endian platforms
2017-01-27 14:28:50 -08:00
Rei Odaira
1afcb41368 Update the expected binary size for big-endian platforms 2017-01-27 13:41:36 -06:00
Taro L. Saito
2c2d1a0f93 Add more Maven badge for convenience 2017-01-26 08:55:35 -08:00
Taro L. Saito
ed8852874f Setting version to 1.1.3-SNAPSHOT 2017-01-25 22:47:55 -08:00
Taro L. Saito
2421cda7e2 Setting version to 1.1.3-M2 2017-01-25 22:47:21 -08:00
Taro L. Saito
61d95282a8 Add 1.1.3-M2 release notes 2017-01-25 22:46:42 -08:00
Taro L. Saito
1cb0d1ad1b Add re-compiled native libraries 2017-01-25 22:45:23 -08:00
Taro L. Saito
40b37ab343 Merge pull request #157 from maropu/ISSUE-155
Implement ByteBuffer-based APIs for BitShuffle
2017-01-25 22:43:39 -08:00
Takeshi YAMAMURO
eebcd4fc2d Update a native binary for linux x86_64 2017-01-26 14:58:36 +09:00
Takeshi YAMAMURO
4f28bb679a Update README.md 2017-01-26 14:58:23 +09:00
Takeshi YAMAMURO
8b038c8ed4 Rename bit-shuffing routines 2017-01-26 14:47:44 +09:00
Takeshi YAMAMURO
9d5bb7b8e5 Update a native binary for linux x86_64 2017-01-26 14:37:02 +09:00
Takeshi YAMAMURO
6f798c6a9d Fix wrong comments 2017-01-26 14:37:02 +09:00
Takeshi YAMAMURO
23f528095c Implement ByteBuffer-based APIs for BitShuffle (#155) 2017-01-26 14:37:02 +09:00
Taro L. Saito
d127ab601a Merge pull request #158 from maropu/FixBugInMakefile
Add a missing entry in Makefile
2017-01-25 12:49:38 -08:00
Takeshi YAMAMURO
e2efc5b8d8 Add a missing entry 2017-01-25 23:35:18 +09:00
Taro L. Saito
ecf1352e99 Update README.md 2017-01-24 11:09:29 -08:00
xerial
def87d8101 Fix wording 2017-01-24 10:54:12 -08:00
Takeshi YAMAMURO
7c34e63fbb Apply comments 2017-01-24 10:22:53 +09:00
Takeshi YAMAMURO
ebabccc829 Update README.md 2017-01-23 23:15:09 +09:00
Taro L. Saito
eb25832561 Update Milestone.md 2017-01-20 16:55:58 -08:00
Taro L. Saito
e5b2c65c93 Add release plan for 1.1.3 (Early 2017) 2017-01-20 16:53:01 -08:00
Taro L. Saito
4ed4f5394b Add javadoc badge 2017-01-20 00:31:59 -08:00
Taro L. Saito
b12fa23bc8 Update README.md 2017-01-20 00:30:08 -08:00
Taro L. Saito
ec2c1d5903 Add Travis and Maven badges 2017-01-20 00:29:36 -08:00
Taro L. Saito
fb99f2dd10 Update Milestone.md 2017-01-20 00:24:43 -08:00
Taro L. Saito
92bcbb514e Update Milestone.md 2017-01-20 00:24:24 -08:00
xerial
381469d886 Setting version to 1.1.3-SNAPSHOT 2017-01-20 00:12:31 -08:00
xerial
8b907e0cae Setting version to 1.1.3-M1 2017-01-20 00:12:08 -08:00
xerial
5c3e66c4bd Add release notes for 1.1.3-M1 2017-01-19 23:41:22 -08:00
Taro L. Saito
8427461ece Merge pull request #151 from xerial/cross-build
Cross building snappy-java using docker
2017-01-19 23:33:20 -08:00
xerial
e329283744 Fix markdown 2017-01-19 23:33:08 -08:00
xerial
b7f25dd022 Fix layout 2017-01-19 23:30:55 -08:00
xerial
5898066ebd Fix doc 2017-01-19 23:29:17 -08:00
xerial
9c89e5c3af Give up using Travis for docker build 2017-01-19 22:50:04 -08:00
xerial
0c00a0cd6a Use privileged mode 2017-01-19 22:35:44 -08:00
xerial
dc33aaf564 Just use make native for PR build 2017-01-19 22:25:56 -08:00
Taro L. Saito
937470e098 Add more clean phase 2017-01-19 21:54:09 -08:00
Taro L. Saito
524242ec85 Add clean phase 2017-01-19 21:53:38 -08:00
Taro L. Saito
fabfc98b8a Use sbt-coursier plugin to accelerate jar download 2017-01-19 21:38:42 -08:00
Taro L. Saito
57c5576151 Specify sbt scala version 2017-01-19 21:35:19 -08:00
Taro L. Saito
803a46fd7f Fix mac binary 2017-01-19 21:34:05 -08:00
Taro L. Saito
c88e150282 Build jni-header first 2017-01-19 21:09:37 -08:00
Taro L. Saito
549e971765 Remove obsolete google code upload script 2017-01-19 21:07:31 -08:00
Taro L. Saito
05cb366fd2 Set credentail only when SONTAYPE_USERNAME/PASSWORD are set 2017-01-19 20:53:09 -08:00
Taro L. Saito
5fdd82cdb5 Update sbt script 2017-01-19 20:40:55 -08:00
Taro L. Saito
300fc8e1ea Drop jdk6 build 2017-01-19 19:45:25 -08:00
Taro L. Saito
3e650b17b7 Download bitshuffle code in advance 2017-01-19 19:23:45 -08:00
xerial
47c05acd8a Install curl inside the docker image 2017-01-19 18:37:44 -08:00
xerial
ef5f1cb0df Skip native library build for other than jdk8 2017-01-19 18:34:44 -08:00
xerial
0325e172f8 Use addons 2017-01-19 18:21:12 -08:00
xerial
6e2af03387 Install curl 2017-01-19 18:20:42 -08:00
xerial
6e1d9eb9ca Publish snapshot version to sonatype 2017-01-19 18:16:05 -08:00
xerial
7dc0ad5401 Fix OSGi config 2017-01-19 18:08:13 -08:00
xerial
9ab5620220 Update the expected binary size for snappy-1.1.3 2017-01-19 18:00:37 -08:00
xerial
c597ac2d45 Update OSInfo 2017-01-19 17:57:42 -08:00
xerial
a419c0795b Use Java 1.7 2017-01-19 17:55:31 -08:00
xerial
6b4cb2c89d Fix Travis config 2017-01-19 17:52:15 -08:00
xerial
a2c09ecc3b Fix Travis config 2017-01-19 17:50:34 -08:00
xerial
d732857979 Run docker cross compiler on Travis CI 2017-01-19 17:49:28 -08:00
xerial
cdc1c7408a Add linux x86 binaries 2017-01-19 17:33:12 -08:00
xerial
fc1de99c3a Add linu32 linu64 targets 2017-01-19 16:48:28 -08:00
xerial
21adc98015 Add make native-all 2017-01-19 14:28:06 -08:00
Taro L. Saito
f72229f913 Merge pull request #153 from xerial/revert-152-revert-137-SupportBitShuffle
Revert "Revert "[WIP] Add bit-shuffling interfaces to improve LZ performance""
2017-01-19 14:19:36 -08:00
Taro L. Saito
0fcee27d59 Revert "Revert "[WIP] Add bit-shuffling interfaces to improve LZ performance"" 2017-01-19 14:19:21 -08:00
xerial
7e8346ba3c Rebuilt windows images 2017-01-19 14:15:59 -08:00
xerial
fb530fd0fb Add arm support 2017-01-19 11:28:50 -08:00
xerial
c365c444a5 Add aarch64 2017-01-19 11:14:34 -08:00
xerial
a0a02e3170 Add ppc64 2017-01-19 11:09:03 -08:00
xerial
d5a30c0fe8 Build mac lib using cross compiler 2017-01-19 11:06:28 -08:00
xerial
fb7553c319 Fix native dll build 2017-01-19 11:05:46 -08:00
Taro L. Saito
d197df096c Merge pull request #152 from xerial/revert-137-SupportBitShuffle
Revert "[WIP] Add bit-shuffling interfaces to improve LZ performance"
2017-01-19 10:57:34 -08:00
Taro L. Saito
e08d784358 Revert "[WIP] Add bit-shuffling interfaces to improve LZ performance" 2017-01-19 10:57:04 -08:00
xerial
f9ec0da1cb Add dokerfile template for g++ for linux 2017-01-19 10:52:20 -08:00
xerial
7d9da23d40 Fix build scripts 2017-01-19 10:51:35 -08:00
xerial
3c5878e70b Add win binaries 2017-01-19 10:25:00 -08:00
xerial
229e51eb68 Fix win32, win64 target 2017-01-19 10:22:36 -08:00
xerial
a1e701c8fa Add win cross compiler 2017-01-19 10:12:34 -08:00
Taro L. Saito
fa67fcbc3d Fix Makefile for Mac OS X 2017-01-19 10:02:38 -08:00
Taro L. Saito
8c1d4b0245 Use the latest version of snappy 1.1.3 2017-01-19 10:02:38 -08:00
Taro L. Saito
1ef5cce1b5 Merge pull request #137 from maropu/SupportBitShuffle
[WIP] Add bit-shuffling interfaces to improve LZ performance
2017-01-19 10:02:07 -08:00
Taro L. Saito
7352efda48 Merge pull request #148 from mnd999/master
Build freebsd64 native library
2017-01-19 09:23:29 -08:00
Mark Dixon
a3a3f2a464 Build freebsd64 native library 2016-09-15 18:29:06 +01:00
Taro L. Saito
7650aa29fb Merge pull request #145 from mhurne/patch-1
Fix typo; improve wording while we're at it
2016-07-06 16:56:37 -07:00
Matt Hurne
32505c396c Fix typo; improve wording while we're at it 2016-06-30 17:03:31 -04:00
Taro L. Saito
1541bc9b91 Fix travis ci build branches 2016-06-02 10:51:17 -07:00
Taro L. Saito
f2ae38deab Fix release note 2016-06-02 10:43:01 -07:00
Taro L. Saito
78c7823024 1.1.2.5 2016-06-02 10:38:37 -07:00
Taro L. Saito
187f749fb1 Add release notes for 1.1.2.5 2016-06-02 10:37:53 -07:00
Taro L. Saito
1f54055894 Merge pull request #143 from xerial/fix-header-check
#142: Fix reading stream that happens to have MAGIC_HEADER[0]
2016-06-02 10:35:07 -07:00
Taro L. Saito
60cc0c2e1d #142: Fix reading stream that happens to have MAGIC_HEADER[0] 2016-06-02 10:27:20 -07:00
Takeshi YAMAMURO
3a8e8c8f77 Update README.md for showing how to enable SSE2/AVX2 2016-04-14 14:04:09 +09:00
Takeshi YAMAMURO
d39b23f35b Update Makefile to support SSE2 only in linux/x86_64 2016-04-14 14:03:46 +09:00
Takeshi YAMAMURO
eeb5a811b4 Fix bugs to load a native binary in SnappyLoader 2016-04-02 23:57:09 +09:00
Takeshi YAMAMURO
f94765b939 Revert the changes of native binaries 2016-04-02 15:10:54 +09:00
Takeshi YAMAMURO
7a96d1fee9 Remove the TODO comment in SnappyLoader 2016-04-02 15:03:32 +09:00
Takeshi YAMAMURO
ba55390f79 Put the bitshuffle version in resources/.../VERSION 2016-04-01 10:08:48 +09:00
Takeshi YAMAMURO
6a894340fc Upgrade bitshuffle to stable version 2016-04-01 10:00:36 +09:00
Takeshi YAMAMURO
f9520f9d19 Separate a source file for BitShuffleNative 2016-04-01 09:58:22 +09:00
Takeshi YAMAMURO
4fbfa72ebd Add a macro to turn sse2/avx2 on/off in Makefile 2016-04-01 09:58:05 +09:00
Takeshi YAMAMURO
f89a30c741 Add more tests for BitShuffle 2016-04-01 09:58:05 +09:00
Takeshi YAMAMURO
695af1b189 Fix Makefile to generate a platform-independent binary 2016-04-01 09:58:05 +09:00
Takeshi YAMAMURO
0df5e90422 Add BitShuffleNative for the JNI interfaces of bitshuffle 2016-04-01 09:57:38 +09:00
Takeshi YAMAMURO
b695e378b1 Put bitshuffle functions in a new class file 2016-04-01 09:53:24 +09:00
Takeshi YAMAMURO
87c11d9034 Update executable binaries for mac environments 2016-04-01 09:53:24 +09:00
Takeshi YAMAMURO
99b297cfcd Implement bit-shuffling interfaces to improve LZ performance 2016-04-01 09:53:10 +09:00
Taro L. Saito
8c04209b55 Use google/snappy GitHub as the default download source 2016-03-30 22:49:43 -07:00
Taro L. Saito
738d88a86d merge 2016-03-30 20:55:21 -07:00
Taro L. Saito
00f53c49e4 Use non-JNI method for read(byte[]) 2016-03-30 20:54:21 -07:00
Taro L. Saito
29bfc49473 Use System.arraycopy for write(byte[]) apache/spark#12074 2016-03-30 20:53:53 -07:00
Taro L. Saito
3a183de4f0 Add release note for 1.1.2.4 2016-03-30 20:52:10 -07:00
Taro L. Saito
7d384a6fd6 Update sbt version 2016-03-30 18:15:41 -07:00
Taro L. Saito
789278d2c7 Update Travis config 2016-03-30 18:14:56 -07:00
Taro L. Saito
3ac8e1e7e7 Add release note for 1.1.2.3 2016-03-30 18:12:24 -07:00
Taro L. Saito
b51c414b55 Add release notes for 1.1.2.2 2016-03-29 14:22:14 -07:00
Taro L. Saito
c975c27495 Merge pull request #133 from smola/arm64
Add Linux aarch64 support.
2016-03-10 13:54:56 +09:00
Santiago M. Mola
cfb114f92f Add Linux aarch64 support. 2016-03-07 21:15:47 +01:00
Taro L. Saito
fd07ae7afe Merge branch 'develop' 2016-02-16 08:26:22 -08:00
Taro L. Saito
fae5091f6a Merge pull request #132 from xuwei-k/patch-1
fix markdown syntax
2016-01-22 23:34:24 +09:00
kenji yoshida
752cb02786 fix markdown syntax 2016-01-22 19:40:47 +09:00
Taro L. Saito
3ba45d5a36 Update plugins 2016-01-22 18:48:34 +09:00
Taro L. Saito
e3d9fb48e9 Fix version 2016-01-22 18:42:37 +09:00
Taro L. Saito
82adf0aee2 Update readme 2016-01-22 18:42:12 +09:00
Taro L. Saito
e029c0e560 #131: Close version file stream 2016-01-22 18:38:57 +09:00
Taro L. Saito
1198363176 Merge pull request #129 from maciej/dead_googlecode_links
README.md: fix dead Google Code links
2015-12-02 12:44:07 -08:00
Maciej Bilas
b372a8152c README.md: fix dead Google Code links
Update links to `framing_format.txt` to Google's snappy GitHub project
2015-12-02 12:37:18 +01:00
Taro L. Saito
0812a50c13 Merge pull request #125 from linux-on-ibm-z/develop
Update snappy to 1.1.3 and use new download URL
2015-11-22 16:58:19 -08:00
Taro L. Saito
b7359e8c23 Merge pull request #128 from thanhdowisc/develop
Replace jni.h with the latest from Oracle.
2015-11-16 11:17:00 -08:00
Thanh Do
292e114e59 Replace jni.h with the latest from Oracle. 2015-11-16 10:37:18 -06:00
Bryan Chan
8dd2ebacf5 Update 32-bit AIX native library to 1.1.3 2015-11-11 23:58:52 -05:00
Bryan Chan
caf548321d Merge branch 'develop' of https://github.com/xerial/snappy-java into develop
Conflicts:
	version.sbt
2015-11-11 22:33:45 -05:00
Taro L. Saito
7a5ddff89d Setting version to 1.1.3-SNAPSHOT 2015-09-22 13:32:46 -07:00
Taro L. Saito
eaac67b703 Setting version to 1.1.2 2015-09-22 13:32:13 -07:00
Taro L. Saito
63b31b4098 Release notes on 1.1.2 2015-09-22 13:31:33 -07:00
Bryan Chan
e8beabfa8d Update snappy to 1.1.3 and use new download URL 2015-09-22 14:33:44 -04:00
Taro L. Saito
737b2ea56b Merge pull request #124 from linux-on-ibm-z/develop
Support 32-bit AIX
2015-09-22 11:03:07 -07:00
Bryan Chan
ee5cb32463 Add OSGi configuration for 32-bit AIX 2015-09-22 09:51:41 -04:00
Bryan Chan
3d4bd9ae9c Add AIX-ppc to list of known platforms; add missing GCC option 2015-09-19 16:18:15 -04:00
Bryan Chan
8c1383719a Strip 32-bit AIX native library 2015-09-19 15:58:30 -04:00
Bryan Chan
785eb80484 Support 32-bit AIX 2015-09-19 15:21:08 -04:00
Taro L. Saito
b1308103ed Merge pull request #122 from steven-aerts/patch-1
Fix small typo in pom project url
2015-08-10 18:10:47 -07:00
Steven Aerts
a41143b5d8 Fix small typo in pom project url 2015-08-10 12:05:29 +02:00
Taro L. Saito
a180570fbc Merge pull request #121 from linux-on-ibm-z/develop-s390x
Upgrade sbt script; the old version could no longer download SBT properly
2015-08-01 10:23:26 -07:00
Bryan Chan
251e6196ab Upgrade sbt script; the old version could no longer download SBT properly 2015-08-01 12:43:07 -04:00
Taro L. Saito
f38b91f18c Merge pull request #120 from linux-on-ibm-z/develop-s390x
Fix SnappyOutputStreamTest for big-endian platforms
2015-06-30 10:41:59 +09:00
Bryan Chan
08b4f6ae60 Detect the native byte order and use the correct expected value 2015-06-29 15:53:10 -04:00
Bryan Chan
d8600ed65e Fix SnappyOutputStreamTest for big-endian platforms 2015-06-29 14:50:27 -04:00
Taro L. Saito
6b4e2a1df6 Merge pull request #118 from linux-on-ibm-z/develop-s390x
Support Linux on IBM z Systems
2015-06-19 23:29:29 +09:00
Bryan Chan
73fa77bc4e Add native library for s390x 2015-06-18 12:35:34 -04:00
Bryan Chan
ddac8ded5c Support Linux on IBM z Systems 2015-06-17 11:01:59 -04:00
Bryan Chan
3113ffb074 Merge branch 'develop' into develop-s390x 2015-06-16 13:30:54 -04:00
Taro L. Saito
2902c04ecc Fix version 2015-06-16 12:59:04 +09:00
Taro L. Saito
68e1973d3d Setting version to 1.1.2-SNAPSHOT 2015-06-16 12:57:15 +09:00
Taro L. Saito
b8d4fdeead Setting version to 1.1.2-RC3 2015-06-16 12:56:58 +09:00
Taro L. Saito
8a12982532 Merge pull request #117 from avianey/amd64-alias
Support amd64 arch under windows & linux
2015-06-16 12:54:49 +09:00
Antoine Vianey
6feccf255e #116 support amd64 arch under windows & linux
x86_64 might be recognise as x64 or amd64 on some servers... osgi the fails to load native dependencies!
2015-06-15 16:49:27 +02:00
Taro L. Saito
7fb7185916 Merge pull request #114 from xerial/revert-112-develop
Revert "SunOS/sparcv9/libsnappyjava.so"
2015-05-21 17:59:02 +09:00
Taro L. Saito
71f1fd8b39 Revert "SunOS/sparcv9/libsnappyjava.so" 2015-05-21 15:26:16 +09:00
Taro L. Saito
078b4c5085 Merge pull request #112 from openam-org-ru/develop
SunOS/sparcv9/libsnappyjava.so
2015-05-20 12:22:35 +09:00
vharseko
14a82e8dac src/main/resources/org/xerial/snappy/native/SunOS/sparcv9/libsnappyjava.so: ELF 64-bit MSB shared object, SPARC V9, total store ordering, version 1 (SYSV), dynamically linked, stripped 2015-05-20 00:23:11 +03:00
Taro L. Saito
e5abaaccaa Setting version to 1.1.2-RC3-SNAPSHOT 2015-05-18 18:31:35 +09:00
Taro L. Saito
38aa42aa03 Setting version to 1.1.2-RC2 2015-05-18 18:30:55 +09:00
Taro L. Saito
9215b09cc5 #107: Add release note for 1.1.2-RC2 2015-05-18 18:30:24 +09:00
Taro L. Saito
50930c8c3b Merge pull request #111 from xerial/refactoring
Refactoring
2015-05-18 18:27:54 +09:00
Taro L. Saito
ac168dfdce Simlify incomplete header handling 2015-05-18 18:13:49 +09:00
Taro L. Saito
67e7cb57fd Add test code for reading Snappy.compress result with SnappyInputStream 2015-05-18 18:13:25 +09:00
Taro L. Saito
58016fd78d Remove findbugs reported problems 2015-05-18 18:08:31 +09:00
Taro L. Saito
efd802162f Upgrade findbugs4sbt plugin version 2015-05-18 18:03:41 +09:00
Taro L. Saito
272604b3b0 Add note on setting loglevel 2015-05-18 18:03:41 +09:00
Taro L. Saito
c8842a0603 Added findbugs and jacoco (coverage report) settings 2015-05-18 18:03:41 +09:00
Taro L. Saito
aee2b85253 Removed unused variable 2015-05-18 18:03:41 +09:00
Taro L. Saito
de3ad7bb52 Merge pull request #110 from xerial/check-style
Apply airlift checkstyle
2015-05-18 17:00:44 +09:00
Taro L. Saito
66115a49ad Applied the same style with https://github.com/airlift/codestyle 2015-05-18 16:51:53 +09:00
Taro L. Saito
02c14db79e Add sbt checkstyle plugin 2015-05-18 16:44:49 +09:00
Taro L. Saito
d6908244a7 Merge pull request #109 from xerial/fix-newline
Use LF as newline
2015-05-18 15:53:47 +09:00
Taro L. Saito
3cf34325d7 Use LF as newline 2015-05-18 15:36:06 +09:00
Taro L. Saito
6b4df5a5f8 1.1.2-RC2-SNAPSHOT 2015-05-18 15:32:13 +09:00
Taro L. Saito
5bd06f4526 Merge pull request #108 from JoshRosen/close-should-be-idempotent
Make SnappyOutputStream.close() idempotent; guard against writing to closed stream
2015-05-15 05:25:08 +09:00
Josh Rosen
38ec9fd03b Null buffer refs when closing SnappyOutputStream. 2015-05-14 11:22:34 -07:00
Josh Rosen
dcdada2ed4 Throw IOException when writing to / flushing closed SnappyOutputStreams. 2015-05-14 10:59:16 -07:00
Josh Rosen
2b6c8dc896 Make close() idempotent (fixes #107). 2015-05-14 00:36:00 -07:00
Josh Rosen
c5a3b102bc Add failing regression test for #107 2015-05-14 00:30:53 -07:00
Taro L. Saito
70ff167f6f Fix javadoc link 2015-05-13 11:34:20 +09:00
Taro L. Saito
50afc2cc9b Fix broken link 2015-05-13 11:33:24 +09:00
Taro L. Saito
3ae91f1cd8 Remove eclipse settings 2015-05-13 11:31:20 +09:00
Taro L. Saito
16010e791c Setting version to 1.1.2-SNAPSHOT 2015-05-13 11:15:15 +09:00
Taro L. Saito
39606e5c4e Setting version to 1.1.2-RC1 2015-05-13 11:10:53 +09:00
Taro L. Saito
e5d86ee61e Merge branch 'develop' 2015-05-13 11:06:11 +09:00
Taro L. Saito
09827ad9fe Fix release tag name 2015-05-13 11:05:49 +09:00
Taro L. Saito
195310f3d4 Setting version to 1.1.2-SNAPSHOT 2015-05-13 11:02:01 +09:00
Taro L. Saito
7010fb0e41 Setting version to 1.1.2-M1 2015-05-13 11:01:39 +09:00
Taro L. Saito
de6864edeb Upgrade sbt script 2015-05-13 11:00:19 +09:00
Taro L. Saito
50e67d710e Add 1.1.2-RC1 release notes 2015-05-13 10:59:43 +09:00
Taro L. Saito
d1745ebfcb Merge pull request #104 from xerial/chunked-input
Concatenated input support
2015-05-13 10:51:37 +09:00
Taro L. Saito
0efe115bad Merge pull request #105 from alexeydergunov/fix-file-not-found
Fix FileNotFoundException while writing the library file
2015-05-13 10:33:58 +09:00
Aleksey Dergunov
708752efa5 Fix FileNotFoundException while writing the library file 2015-05-12 20:01:48 +04:00
Taro L. Saito
62fe335057 Fix javdoc 2015-05-12 09:57:35 +09:00
Taro L. Saito
b1b827695c #103: Embed /org/xerial/snappy/VERSION properly 2015-05-12 09:57:03 +09:00
Taro L. Saito
1c702ba366 #103: Support reading concatenated streams in SnappyInputStream 2015-05-12 01:43:23 +09:00
Taro L. Saito
81536ea146 Upgrade Scala and sbt plugin versions 2015-05-12 01:41:57 +09:00
Taro L. Saito
75cb0e5213 New snapshot version 2015-04-14 16:05:14 +09:00
Taro L. Saito
c4b3b0293a 1.1.1.7 2015-04-14 16:04:32 +09:00
Taro L. Saito
98955b14a1 Fix for running with java8 2015-04-14 16:03:27 +09:00
Taro L. Saito
f2e54dce56 Add release note 2015-04-14 16:00:23 +09:00
Taro L. Saito
dc2dd27f85 Merge pull request #102 from xerial/fix-output-size
Stabilize compressed data size of SnappyOutputStream
2015-04-14 15:58:22 +09:00
Taro L. Saito
6d9925ba36 Fixes for #100 2015-04-14 15:43:50 +09:00
Taro L. Saito
3fe32512e4 Use specified block size instead of MIN_BLOCK_SIZE 2015-04-14 15:22:20 +09:00
Josh Rosen
a6eb0a605d Add failing regression test for #100. 2015-04-13 12:47:13 -07:00
Bryan Chan
61691b8fe6 Support Linux on IBM z Systems 2015-03-14 20:46:40 -04:00
Taro L. Saito
0dd3f488f6 Merge pull request #98 from zeldin/ppc32
Add native library for ppc (32 bit)
2015-02-16 11:50:16 +09:00
Marcus Comstedt
d9294241a8 Add native library for ppc (32 bit) 2015-02-15 13:14:01 +01:00
Taro L. Saito
93e100005f Merge pull request #97 from zlim/aarch64
Add aarch64 target
2015-01-17 17:45:39 +09:00
Zi Shen Lim
2681311aa5 Add aarch64 target 2015-01-16 14:42:17 -08:00
Taro L. Saito
6136702f0a Update README.md 2014-12-26 11:21:02 +09:00
Taro L. Saito
fb8b14bc30 Update README.md 2014-12-26 11:17:12 +09:00
Taro L. Saito
6a66a08845 Merge pull request #94 from xerial/rapsberry
Raspberry PI support
2014-12-24 12:16:51 +09:00
Taro L. Saito
aacd802ee6 snapshot vesion 2014-11-27 15:33:47 +09:00
Taro L. Saito
f446a39a00 Fixes #37: Native library for raspberry-pi 2014-11-27 06:28:22 +00:00
Taro L. Saito
622a1d71b1 Update README.md 2014-11-01 17:15:55 +09:00
Taro L. Saito
b55d2a40dc Update README.md 2014-11-01 17:14:58 +09:00
Taro L. Saito
bd8476bf84 Update README.md 2014-11-01 17:12:41 +09:00
Taro L. Saito
0ecdb4d568 Fixes #92 and released 1.1.1.6 2014-10-26 20:47:16 +09:00
Taro L. Saito
71a02f950b 1.1.1.6 release notes 2014-10-26 20:45:54 +09:00
Taro L. Saito
0521877d9a Release 1.1.1.6 2014-10-26 20:44:57 +09:00
Taro L. Saito
be0f2dd5d3 Merge pull request #92 from davies/fix_leak
fix memory leak in SnappyOutputStream
2014-10-26 20:40:02 +09:00
Davies Liu
f48a29c4ae fix memory leak in SnappyOutputStream 2014-10-26 01:06:20 -07:00
Taro L. Saito
2d5db6d830 snapshot version 2014-10-24 09:55:18 +09:00
Taro L. Saito
08fbe52c23 Merge branch 'develop' 2014-07-04 14:11:54 +09:00
Taro L. Saito
fec7847f12 Merge branch 'master' of github.com:xerial/snappy-java 2013-10-17 11:13:33 +09:00
Taro L. Saito
baabd37418 Merge branch 'release/1.1.0-M4' 2013-08-20 14:23:52 +09:00
139 changed files with 13093 additions and 5748 deletions

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.7.2
2b37d1ce0bbed3d8d03a66292e7d90dcde805624

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
sbt text eol=lf

9
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

55
.github/release-drafter.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🔥 Breaking Changes'
labels:
- 'breaking'
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '👋 Deprecated'
labels:
- 'deprecation'
- title: '🔗 Dependency Updates'
labels:
- 'library-update'
- 'dependencies'
- title: '🛠 Internal Updates'
labels:
- 'internal'
- 'kaizen'
- 'test-library-update'
- 'sbt-plugin-update'
- title: '📚 Docs'
labels:
- 'doc'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## What's Changed
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
autolabeler:
- label: 'doc'
files:
- '*.md'
- label: 'feature'
title:
- '/(support|feature)/i'
- label: 'bug'
title:
- '/fix/i'
- label: 'internal'
title:
- '/internal/i'
- label: 'deprecation'
title:
- '/deprecate/i'

31
.github/release.yml vendored Normal file
View File

@ -0,0 +1,31 @@
changelog:
categories:
- title: '🔥 Breaking Changes'
labels:
- 'breaking'
- title: '👋 Deprecated'
labels:
- 'deprecation'
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '🔗 Dependency Updates'
labels:
- 'library-update'
- 'dependencies'
- title: '🛠 Internal Updates'
labels:
- 'internal'
- 'kaizen'
- 'test-library-update'
- 'sbt-plugin-update'
- title: '📚 Docs'
labels:
- 'doc'
- title: Other Changes
labels:
- "*"

48
.github/workflows/build-native.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Build Native
on:
workflow_dispatch:
push:
branches:
- master
- main
paths:
- 'src/main/resources/org/xerial/snappy/VERSION'
- 'Makefile'
- 'Makefile.common'
- '**/*.h'
- '**/*.cpp'
- .github/workflows/build-native.yml
pull_request:
paths:
- 'src/main/resources/org/xerial/snappy/VERSION'
- 'Makefile'
- 'Makefile.common'
- '**/*.h'
- '**/*.cpp'
jobs:
build:
permissions:
contents: write
pull-requests: write
name: Build native libraries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2.0
with:
cmake-version: '3.16.x'
- name: Build native libraries
run: make clean-native native-all
env:
OCI_EXE: docker
- name: Create Pull Request
if: ${{ github.event_name != 'pull_request' }}
uses: peter-evans/create-pull-request@v7
with:
title: Update native libraries
commit-message: Update native libraries for ${{ github.sha }}
branch: update-native-libs
labels: library-update

27
.github/workflows/release-drafter.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Release Drafter
on:
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
update_PR_labels:
permissions:
contents: read
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Runs only pull-request labeler
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

18
.github/workflows/release-note.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Release Note
on:
push:
tags:
- v*
workflow_dispatch:
jobs:
release:
name: Create a new release note
runs-on: ubuntu-latest
steps:
- name: Create a release note
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$GITHUB_REF_NAME" --repo="$GITHUB_REPOSITORY" --generate-notes

37
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Release
on:
push:
tags:
- v*
workflow_dispatch:
jobs:
publish_jvm:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10000
# Fetch all tags so that sbt-dynver can find the previous release version
- run: git fetch --tags -f
# Install OpenJDK 11
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
- name: Setup GPG
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
run: echo $PGP_SECRET | base64 --decode | gpg --import --batch --yes
- name: Build bundle
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
./sbt publishSigned
- name: Release to Sonatype
env:
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
run: ./sbt sonatypeBundleRelease

39
.github/workflows/snapshot.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Snapshot Release
on:
push:
branches:
- master
paths:
- '**.scala'
- '**.java'
- '**.sbt'
- 'src/main/resources/org/xerial/snappy/native/**'
- '.github/workflows/snapshot.yml'
tag:
- '!*'
workflow_dispatch:
jobs:
publish_snapshots:
name: Publish snapshots
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10000
# Fetch all tags so that sbt-dynver can find the previous release version
- run: git fetch --tags
- uses: olafurpg/setup-scala@v14
with:
java-version: adopt@1.11
- uses: actions/cache@v4
with:
path: ~/.cache
key: ${{ runner.os }}-snapshot-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-snapshot-
- name: Publish snapshots
env:
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
run: ./sbt publish

52
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: CI
on:
pull_request:
paths:
- '**.scala'
- '**.java'
- '**.sbt'
- '.github/workflows/*.yml'
- '**.so'
- '**.dll'
- 'src/main/resources/**'
- 'project/build.properties'
push:
branches:
- master
- main
paths:
- '**.scala'
- '**.java'
- '**.sbt'
- '.github/workflows/*.yml'
- 'src/main/resources/org/xerial/snappy/**'
- 'project/build.properties'
jobs:
code_format:
name: code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: scalafmt test
run: ./sbt scalafmtCheckAll
test-jdk:
strategy:
matrix:
version: [ '8', '11', '17', '21' ]
name: test jdk${{ matrix.version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.version }}
- uses: actions/cache@v4
with:
path: ~/.cache
key: ${{ runner.os }}-jdk${{ matrix.version }}-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-jdk${{ matrix.version }}-
- name: Test
run: ./sbt test

5
.gitignore vendored
View File

@ -17,9 +17,14 @@ lib_managed/
src_managed/
project/boot/
project/plugins/project/
.bsp
# Scala-IDE specific
.scala_dependencies
atlassian-ide-plugin.xml
src/main/java/**/*.h
.metals
.vscode
.bloop

5
.scalafmt.conf Normal file
View File

@ -0,0 +1,5 @@
version = 3.8.6
runner.dialect = scala213source3
maxColumn = 180
style = defaultWithAlign
optIn.breaksInsideChains = true

View File

@ -1,6 +0,0 @@
#Tue Mar 29 16:49:37 JST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

File diff suppressed because one or more lines are too long

View File

@ -1,9 +0,0 @@
#Tue Mar 29 16:49:37 JST 2011
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1

View File

@ -1,15 +1,19 @@
language: scala
scala:
- 2.11.1
jdk:
- openjdk6
- openjdk7
- oraclejdk7
branches:
only:
- master
- develop
- master
script: ./sbt test
language: java
jdk:
- openjdk11
os: linux
arch:
- s390x
- ppc64le
script:
# - sudo apt-get install -y openjdk-11-jdk;
# - export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-s390x && export PATH=$JAVA_HOME/bin:$PATH;
- ./sbt test

119
BUILD.md Executable file
View File

@ -0,0 +1,119 @@
# Notes for building snappy-java
snappy-java supports Windows, Mac OS X, Linux (x86, x86_64, arm, etc...). If your platform is not supported, you need to build native libraries by yourself.
## Requited Tools
- Java 7 or higher
- Maven3 (mvn)
- GNU make, autotools
## Building snappy-java
To build jar file of snappy-java, type:
```
$ make
```
A native library for your machine environment and a jar package target/snappy-java-(version).jar are produced in the target folder.
### Rebuild the native library for your platform
```
$ make clean-native native
```
## Platform specific tips
After snappy-java 1.1.3, we are using docker images of cross compilers. So no longer need to build native libraries by actually running the target OS.
The following notes are obsolete, but preserved here for future references.
### Windows (32/64-bit)
* GNU make
* And also tar, curl, cp, rm, grep commands are needed. (I use Cygwin and MinGW for building snappy-java in Windows)
### Windows (32-bit only)
* Install MinGW http://www.mingw.org/
* Set PATH to the following command in MinGW package
- mingw32-g++
- strip
To build x86 (32bit) dll under 64-bit Windows, use "make win32" target.
### Windows (64-bit only)
* Download MinGW-w64 http://sourceforge.net/projects/mingw-w64/
* Set PATH to the following commands in the downloaded archive:
- x86_64-w64-mingw32-g++
- x86_64-w64-mingw32-strip
NOTICE: Do not use the Cygwin version of MinGW-w64. It fails to build assemblies for 64bit environment.
### Linux (32/64-bit)
* gcc-4.5.x or higher is necessary because snappy-java uses -static-libstdc++ option. It is possible to use gcc-4.3.x but a dependency to libstdc++ remains in the generated jar file; That means if another version of libstdc++ is used, snappy-java might not work correctly.
* You can build 32-bit native library with 64-bit Linux machine (do make linux32)
### Mac
* Install gcc, make, etc. included in Mac OS X install disk. (X Code). And also intall libtool:
```
$ brew install libtool
```
## Building Linux x86\_64 binary
(obsolete: snappy-java now uses a docker image `xerial/centos5-linux-x86_86-pic` which contains g++ built with `-fPIC` option. )
snappy-java tries to static link libstdc++ to increase the availability for various Linux versions. However, standard distributions of 64-bit Linux OS rarely provide libstdc++ compiled with `-fPIC` option. I currently uses custom g++, compiled as follows:
```
$ cd work
$ wget (gcc-4.8.3 source)
$ tar xvfz (gcc-4.8.3.tar.gz)
$ cd gcc-4.8.3
$ ./contrib/download_prerequisites
$ cd ..
$ mkdir objdir
$ cd objdir
$ ../gcc-4.8.3/configure --prefix=$HOME/local/gcc-4.8.3 CXXFLAGS=-fPIC CFLAGS=-fPIC --enable-languages=c,c++
$ make
$ make install
```
This g++ build enables static linking of libstdc++. For more infomation on building GCC, see GCC's home page.
## Building Linux s390/s390x binaries
Older snapshots of snappy contain a buggy config.h.in that does not work properly on some big-endian platforms like Linux on IBM z (s390/s390x). Building snappy-java on s390/s390x requires fetching the snappy source from GitHub, and processing the source with autoconf to obtain a usable config.h. On a RHEL s390x system, these steps produced a working 64-bit snappy-java build (the process should be similar for other distributions):
$ sudo yum install java-1.7.1-ibm-devel libstdc++-static-devel
$ export JAVA_HOME=/usr/lib/jvm/java-1.7.1-ibm-1.7.1.2.10-1jpp.3.el7_0.s390x
$ make USE_GIT=1 GIT_REPO_URL=https://github.com/google/snappy.git GIT_SNAPPY_BRANCH=master IBM_JDK_7=1
## Activating SSE2/AVX2 instructions in BitShuffle
The most of the native libraries that snappy-java contains disable SSE2/AVX2 instructions in terms of portability (SSE2 is enabled only in Linux/x86_64 platforms). To enable AVX2 instructions, you need to compile as follows:
$ make CXXFLAGS_BITSHUFFLE=-mavx2 # -msse2 for SSE2 instructions
## Cross-compiling for other platforms (obsolete)
The Makefile contains rules for cross-compiling the native library for other platforms so that the snappy-java JAR can support multiple platforms. For example, to build the native libraries for x86 Linux, x86 and x86-64 Windows, and soft- and hard-float ARM:
$ make linux32 win32 win64 linux-arm linux-armhf linux-aarch64
If you append `snappy` to the line above, it will also build the native library for the current platform and then build the snappy-java JAR (containing all native libraries built so far).
Of course, you must first have the necessary cross-compilers and development libraries installed for each target CPU and OS. For example, on Ubuntu 12.04 for x86-64, install the following packages for each target:
* linux32: `sudo apt-get install g++-multilib libc6-dev-i386 lib32stdc++6`
* win32: `sudo apt-get install g++-mingw-w64-i686`
* win64: `sudo apt-get install g++-mingw-w64-x86-64`
* arm: `sudo apt-get install g++-arm-linux-gnueabi`
* armhf: `sudo apt-get install g++-arm-linux-gnueabihf`
* aarch64: `sudo apt-get install g++-aarch64-linux`
Unfortunately, cross-compiling for Mac OS X is not currently possible; you must compile within OS X.
If you are using Mac and openjdk7 (or higher), use the following option:
$ make native LIBNAME=libsnappyjava.dylib

78
INSTALL
View File

@ -1,78 +0,0 @@
[Installation note of snappy-java]
If your OS platform is one of the Windows/Linux/Mac OS X (32/64 bit Intel CPUs), the installation process described here is unnecessary. Simply put snappy-java-(version).jar to your Java classpath. If your OS is not listed above, create your own snappy-java-(version).jar file as follows.
= Required tools for building snappy-java =
[For all platforms]
* Java 6 (JDK1.6) http://java.sun.com/
- set JAVA_HOME environment variable to the Java installation folder (e.g. JAVA_HOME=C:/Program Files/Java/jdk1.6.0_24 in Windows)
* Maven 3.x http://maven.apache.org/
- Check mvn command can be used from your command line.
[Windows (32/64-bit)]
* GNU make
* And also tar, curl, cp, rm, grep commands are needed. (I use Cygwin and MinGW for building snappy-java in Windows)
[Windows (32-bit only)]
* Install MinGW http://www.mingw.org/
* Set PATH to the following command in MinGW package
- mingw32-g++
- strip
To build x86 (32bit) dll under 64-bit Windows, use "make win32" target.
[Windows (64-bit only)]
* Download MinGW-w64 http://sourceforge.net/projects/mingw-w64/
* Set PATH to the following commands in the downloaded archive:
- x86_64-w64-mingw32-g++
- x86_64-w64-mingw32-strip
NOTICE: Do not use the Cygwin version of MinGW-w64. It fails to build assemblies for 64bit environment.
[Linux (32/64-bit)]
* gcc-4.5.x or higher is necessary because snappy-java uses -static-libstdc++ option. It is possible to use gcc-4.3.x but a dependency to libstdc++ remains in the generated jar file; That means if another version of libstdc++ is used, snappy-java might not work correctly.
* You can build 32-bit native library with 64-bit Linux machine (do make linux32)
[Mac]
* Install gcc, make, etc. included in Mac OS X install disk. (X Code)
* Install mercurial using Mac Ports http://www.macports.org/
= Building snappy-java =
To build jar file of snappy-java, type:
$ make
A native library for your machine environment and a jar package target/snappy-java-(version).jar are produced in the target folder.
= Building only the native library =
$ make native
= Rebuild the native library for your platform =
$ make clean-native native
= Using system installed libsnappyjava (or snappyjava.dll) =
Set org.xerial.snappy.use.systemlib system property to true:
java -Djava.library.path=(path to the installed snappyjava lib) -Dorg.xerial.snappy.use.systemlib=true ...
With this setting snappy-java does not use bundled native libraries. Insted it tries to load native library installed at the path specified in java.library.path.
= Configure snappy-java using property file =
Prepare org-xerial-snappy.properties file (under the root path of your library) in Java's property file format.
Here is a list of the available properties:
* org.xerial.snappy.lib.path (directory containing a snappyjava's native library)
* org.xerial.snappy.lib.name (library file name)
* org.xerial.snappy.tempdir (temporary directory to extract a native library bundled in snappy-java)
* org.xerial.snappy.use.systemlib (if this value is true, use system installed libsnappyjava.so looking the path specified by java.library.path)

248
Makefile
View File

@ -1,83 +1,138 @@
include Makefile.common
$(info OS_NAME:$(OS_NAME), OS_ARCH:$(OS_ARCH))
MVN:=mvn
SBT:=./sbt
all: snappy
SNAPPY_OUT:=$(TARGET)/$(snappy)-$(os_arch)
SNAPPY_ARCHIVE:=$(TARGET)/snappy-$(VERSION).tar.gz
SNAPPY_CC:=snappy-sinksource.cc snappy-stubs-internal.cc snappy.cc
SNAPPY_SRC_DIR:=$(TARGET)/snappy-$(VERSION)
SNAPPY_OUT:=$(TARGET)/snappy-$(SNAPPY_VERSION)-$(os_arch)
SNAPPY_ARCHIVE:=$(TARGET)/snappy-$(SNAPPY_VERSION).tar.gz
SNAPPY_CC:=snappy-sinksource.cc snappy-stubs-internal.cc snappy-c.cc snappy.cc
SNAPPY_SRC_DIR:=$(TARGET)/snappy-$(SNAPPY_VERSION)
SNAPPY_SRC:=$(addprefix $(SNAPPY_SRC_DIR)/,$(SNAPPY_CC))
SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/,$(patsubst %.cc,%.o,$(SNAPPY_CC)) SnappyNative.o)
SNAPPY_GIT_REPO_URL:=https://github.com/google/snappy
# Change this variable to use a specific git commit
SNAPPY_GIT_REV:=$(SNAPPY_VERSION)
SNAPPY_UNPACKED:=$(TARGET)/snappy-extracted.log
SNAPPY_GIT_UNPACKED:=$(TARGET)/snappy-git-extracted.log
SNAPPY_CMAKE_CACHE=$(SNAPPY_OUT)/CMakeCache.txt
ifdef USE_GIT
ifndef GIT_REPO_URL
$(warning GIT_REPO_URL is not set when using git)
endif
ifndef GIT_SNAPPY_BRANCH
$(warning GIT_SNAPPY_BRANCH is not set when using git)
BITSHUFFLE_ARCHIVE:=$(TARGET)/bitshuffle-$(BITSHUFFLE_VERSION).tar.gz
BITSHUFFLE_C:=bitshuffle_core.c iochain.c
BITSHUFFLE_SRC_DIR:=$(TARGET)/bitshuffle-$(BITSHUFFLE_VERSION)/src
BITSHUFFLE_SRC:=$(addprefix $(BITSHUFFLE_SRC_DIR)/,$(BITSHUFFLE_C))
BITSHUFFLE_UNPACKED:=$(TARGET)/bitshuffle-extracted.log
$(BITSHUFFLE_ARCHIVE):
@mkdir -p $(@D)
curl -L -o$@ https://github.com/kiyo-masui/bitshuffle/archive/$(BITSHUFFLE_VERSION).tar.gz
$(BITSHUFFLE_UNPACKED): $(BITSHUFFLE_ARCHIVE)
$(TAR) xvfz $< -C $(TARGET)
touch $@
$(BITSHUFFLE_SRC): $(BITSHUFFLE_UNPACKED)
$(SNAPPY_OUT)/%.o: $(BITSHUFFLE_SRC_DIR)/%.c
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(CXXFLAGS_BITSHUFFLE) -c $< -o $@
SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/,$(patsubst %.cc,%.o,$(SNAPPY_CC)) $(patsubst %.c,%.o,$(BITSHUFFLE_C)) SnappyNative.o BitShuffleNative.o)
CXXFLAGS:=$(CXXFLAGS) -I$(SNAPPY_SRC_DIR) -I$(SNAPPY_OUT) -I$(BITSHUFFLE_SRC_DIR)
ifndef CXXFLAGS_BITSHUFFLE
ifeq ($(OS_NAME)-$(OS_ARCH),Linux-x86_64)
# SSE2 is supported in all the x86_64 platforms and AVX2 is only supported
# in the small part of them. gcc in linux/x86_64 typically enables SSE2 by default though,
# we explicitly set flags below to make this precondition clearer.
CXXFLAGS_BITSHUFFLE:=-U__AVX2__ -msse2
else
# Undefined macros to generate a platform-independent binary
CXXFLAGS_BITSHUFFLE:=-U__AVX2__ -U__SSE2__
endif
endif
CXXFLAGS:=$(CXXFLAGS) -I$(SNAPPY_SRC_DIR)
ifeq ($(OS_NAME),SunOS)
TAR:= gtar
else
ifeq ($(OS_NAME),AIX)
TAR:= gtar
else
TAR:= tar
endif
endif
$(SNAPPY_ARCHIVE):
@mkdir -p $(@D)
curl -o$@ http://snappy.googlecode.com/files/snappy-$(VERSION).tar.gz
curl -L -o$@ https://github.com/google/snappy/releases/download/$(SNAPPY_VERSION)/snappy-$(SNAPPY_VERSION).tar.gz
$(SNAPPY_UNPACKED): $(SNAPPY_ARCHIVE)
$(TAR) xvfz $< -C $(TARGET)
$(TAR) xvfz $< -C $(TARGET)
touch $@
cd $(SNAPPY_SRC_DIR) && ./configure
$(SNAPPY_GIT_UNPACKED):
@mkdir -p $(SNAPPY_OUT)
rm -rf $(SNAPPY_SRC_DIR)
@mkdir -p $(SNAPPY_SRC_DIR)
git clone $(GIT_REPO_URL) $(SNAPPY_SRC_DIR)
git --git-dir=$(SNAPPY_SRC_DIR)/.git --work-tree=$(SNAPPY_SRC_DIR) checkout -b local/snappy-$(GIT_SNAPPY_BRANCH) $(GIT_SNAPPY_BRANCH)
git clone $(SNAPPY_GIT_REPO_URL) $(SNAPPY_SRC_DIR)
git --git-dir=$(SNAPPY_SRC_DIR)/.git --work-tree=$(SNAPPY_SRC_DIR) checkout -b local/snappy-$(SNAPPY_VERSION) $(SNAPPY_GIT_REV)
cd $(SNAPPY_SRC_DIR) && git submodule update --init
touch $@
cd $(SNAPPY_SRC_DIR) && ./configure
jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h
$(SNAPPY_CMAKE_CACHE): $(SNAPPY_GIT_UNPACKED)
@mkdir -p $(SNAPPY_OUT)
cd $(SNAPPY_OUT) && cmake $(SNAPPY_CMAKE_OPTS) ../../$(SNAPPY_SRC_DIR)
touch $@
$(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class : $(SRC)/org/xerial/snappy/SnappyNative.java
jni-header: $(SNAPPY_GIT_UNPACKED) $(BITSHUFFLE_UNPACKED) $(SRC)/org/xerial/snappy/SnappyNative.h $(SRC)/org/xerial/snappy/BitShuffleNative.h
snappy-header: $(SNAPPY_CMAKE_CACHE)
$(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class: $(SRC)/org/xerial/snappy/SnappyNative.java
@mkdir -p $(TARGET)/jni-classes
$(JAVAC) -source 1.6 -target 1.6 -d $(TARGET)/jni-classes -sourcepath $(SRC) $<
$(JAVAC) -source 1.7 -target 1.7 -h $(SRC)/org/xerial/snappy/ -d $(TARGET)/jni-classes -sourcepath $(SRC) $<
$(SRC)/org/xerial/snappy/SnappyNative.h: $(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class
$(JAVAH) -force -classpath $(TARGET)/jni-classes -o $@ org.xerial.snappy.SnappyNative
ifndef USE_GIT
$(SNAPPY_SRC): $(SNAPPY_UNPACKED)
else
$(SNAPPY_SRC): $(SNAPPY_GIT_UNPACKED)
$(TARGET)/jni-classes/org/xerial/snappy/BitShuffleNative.class: $(SRC)/org/xerial/snappy/BitShuffleNative.java
@mkdir -p $(TARGET)/jni-classes
$(JAVAC) -source 1.7 -target 1.7 -h $(SRC)/org/xerial/snappy/ -d $(TARGET)/jni-classes -sourcepath $(SRC) $<
$(SRC)/org/xerial/snappy/BitShuffleNative.h: $(TARGET)/jni-classes/org/xerial/snappy/BitShuffleNative.class
$(SNAPPY_SRC): $(SNAPPY_GIT_UNPACKED)
# aarch64 can use big-endian optimzied code
ifeq ($(OS_ARCH),aarch64)
ifeq ($(ENDIANESS),$(BIG_ENDIAN))
SNAPPY_CXX_OPTS:=-DSNAPPY_IS_BIG_ENDIAN
endif
endif
$(SNAPPY_OUT)/%.o : $(SNAPPY_SRC_DIR)/%.cc
$(SNAPPY_OUT)/%.o: $(SNAPPY_SRC_DIR)/%.cc
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(CXX) $(SNAPPY_CXX_OPTS) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/SnappyNative.o : $(SRC)/org/xerial/snappy/SnappyNative.cpp $(SRC)/org/xerial/snappy/SnappyNative.h
$(SNAPPY_OUT)/SnappyNative.o: $(SRC)/org/xerial/snappy/SnappyNative.cpp $(SRC)/org/xerial/snappy/SnappyNative.h
@mkdir -p $(@D)
$(CXX) $(SNAPPY_CXX_OPTS) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/BitShuffleNative.o: $(SRC)/org/xerial/snappy/BitShuffleNative.cpp $(SRC)/org/xerial/snappy/BitShuffleNative.h
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(SNAPPY_OUT)/$(LIBNAME): $(SNAPPY_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $+ $(LINKFLAGS)
$(STRIP) $@
$(CXX) $(CXXFLAGS) -o $@ $+ $(LINKFLAGS)
# Workaround for strip Protocol error when using VirtualBox on Mac
cp $@ /tmp/$(@F)
$(STRIP) /tmp/$(@F)
cp /tmp/$(@F) $@
clean-native:
clean-native:
rm -rf $(SNAPPY_OUT)
clean:
@ -87,79 +142,106 @@ NATIVE_DIR:=src/main/resources/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)
snappy-jar-version:=snappy-java-$(shell perl -npe "s/version in ThisBuild\s+:=\s+\"(.*)\"/\1/" version.sbt | sed -e "/^$$/d")
snappy-jar-version:=snappy-java-$(shell ./script/dynver.sh | cut -d'=' -f2 | sed 's/[ \"]//g')
ifndef USE_GIT
native: $(SNAPPY_UNPACKED) $(NATIVE_DLL)
else
native: $(SNAPPY_GIT_UNPACKED) $(NATIVE_DLL)
endif
jar-version:
echo $(snappy-jar-version)
native: jni-header snappy-header $(NATIVE_DLL)
native-nocmake: jni-header $(NATIVE_DLL)
snappy: native $(TARGET)/$(snappy-jar-version).jar
$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $< $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)
native-all: native native-arm clean-docker mac64 win32 win64 linux32 linux64 linux-ppc64le linux-riscv64 linux-s390x
ifdef CI
# Clean docker images within CI to avoid no space left error
DOCKER_POST_PROCESS:=docker system prune --all --force --volumes
else
DOCKER_POST_PROCESS:=
endif
clean-docker:
$(DOCKER_POST_PROCESS)
$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $(SNAPPY_OUT)/$(LIBNAME) $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $(SNAPPY_OUT)/$(LIBNAME) $(NATIVE_TARGET_DIR)/$(LIBNAME)
package: $(TARGET)/$(snappy-jar-version).jar
$(TARGET)/$(snappy-jar-version).jar:
$(SBT) package
$(TARGET)/$(snappy-jar-version).jar:
$(SBT) package
test: $(NATIVE_DLL)
$(SBT) test
win32:
$(MAKE) native CROSS_PREFIX=i686-w64-mingw32- OS_NAME=Windows OS_ARCH=x86
DOCKER_RUN_OPTS:=--rm
# for cross-compilation on Ubuntu, install the g++-mingw-w64-x86-64 package
win64:
$(MAKE) native CROSS_PREFIX=x86_64-w64-mingw32- OS_NAME=Windows OS_ARCH=x86_64
mac32:
win32: jni-header
./docker/dockcross-windows-x86 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native snappy-header native CROSS_PREFIX=i686-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86 SNAPPY_CMAKE_OPTS="-DHAVE_SYS_UIO_H=0"'
win64: jni-header
./docker/dockcross-windows-x64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native snappy-header native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64 SNAPPY_CMAKE_OPTS="-DHAVE_SYS_UIO_H=0"'
# deprecated
mac32: jni-header
$(MAKE) native OS_NAME=Mac OS_ARCH=x86
linux32:
$(MAKE) native OS_NAME=Linux OS_ARCH=x86
mac64: jni-header
docker run -i $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64
linux32: jni-header
docker run $(DOCKER_RUN_OPTS) -i -v $$PWD:/work xerial/centos5-linux-x86_64-pic bash -c 'make clean-native native-nocmake OS_NAME=Linux OS_ARCH=x86'
linux64: jni-header
docker run $(DOCKER_RUN_OPTS) -i -v $$PWD:/work xerial/centos5-linux-x86_64-pic bash -c 'make clean-native native-nocmake OS_NAME=Linux OS_ARCH=x86_64'
freebsd64:
$(MAKE) native OS_NAME=FreeBSD OS_ARCH=x86_64
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
linux-arm:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
# For ARM
native-arm: linux-arm64 linux-android-arm linux-android-aarch64 linux-arm linux-armv6 linux-armv7 windows-aarch64
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabihf package
linux-armhf:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armhf
clean-native-linux32:
$(MAKE) clean-native OS_NAME=Linux OS_ARCH=x86
# TODO: CROSS_PREFIX can be replaced with ${CROSS_ROOT}/bin/${CROSS_TRIPLE}- in Makefile.common
linux-arm: jni-header
./docker/dockcross-armv5 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/armv5-unknown-linux-gnueabi/bin//armv5-unknown-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm'
clean-native-win32:
$(MAKE) clean-native OS_NAME=Windows OS_ARCH=x86
linux-armv6: jni-header
./docker/dockcross-armv6 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=armv6'
linux-armv7: jni-header
./docker/dockcross-armv7 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=armv7'
linux-android-arm: jni-header
./docker/dockcross-android-arm -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/arm-linux-androideabi/bin/arm-linux-androideabi- OS_NAME=Linux OS_ARCH=android-arm'
linux-android-aarch64: jni-header
./docker/dockcross-android-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=android-aarch64'
linux-ppc64le: jni-header
./docker/dockcross-ppc64le -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64le'
linux-ppc64: jni-header
./docker/dockcross-ppc64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64'
linux-arm64: jni-header
./docker/dockcross-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64'
linux-riscv64: jni-header
./docker/dockcross-riscv64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=riscv64'
linux-s390x: jni-header
./docker/dockcross-s390x -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu- OS_NAME=Linux OS_ARCH=s390x'
windows-aarch64: jni-header
./docker/dockcross-windows-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/aarch64-w64-mingw32-cross/bin/aarch64-w64-mingw32- OS_NAME=Windows OS_ARCH=aarch64'
javadoc:
$(SBT) doc
install-m2:
$(SBT) publishM2
googlecode-upload: googlecode-lib-upload googlecode-src-upload
googlecode-lib-upload: $(TARGET)/snappy-java-$(VERSION)-lib.upload
googlecode-src-upload: $(TARGET)/snappy-java-$(VERSION)-src.upload
GOOGLECODE_USER:=leo@xerial.org
$(TARGET)/snappy-java-$(VERSION)-lib.upload:
./googlecode_upload.py -s "library for all platforms" -p snappy-java -l "Type-Executable,Featured,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).jar
touch $@
$(TARGET)/snappy-java-$(VERSION)-src.upload:
./googlecode_upload.py -s "source code archive" -p snappy-java -l "Type-Source,OpSys-All" -u "$(GOOGLECODE_USER)" target/snappy-java-$(VERSION).tar.gz
touch $@

View File

@ -1,20 +1,22 @@
TARGET:=target
SRC:=src/main/java
include $(SRC)/org/xerial/snappy/VERSION
include src/main/resources/org/xerial/snappy/VERSION
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
$(warning Set JAVA_HOME environment variable)
endif
JAVA := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"
LITTLE_ENDIAN := "Little Endian"
BIG_ENDIAN := "Big Endian"
OSINFO_CLASS := org.xerial.snappy.OSInfo
OSINFO_PROG := lib/org/xerial/snappy/OSInfo.class
## building OSInfo.java
## building OSInfo.java
#$(info compiling OSInfo.java)
#$(shell mkdir -p lib)
#$(shell $(JAVAC) src/main/java/org/xerial/snappy/OSInfo.java -d lib)
@ -24,6 +26,12 @@ OS_ARCH := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --arch)
LIB_FOLDER := $(shell $(JAVA) -cp lib $(OSINFO_CLASS))
IBM_JDK_LIB := lib/inc_ibm
ifeq ($(OS_NAME),Mac)
ENDIANESS:="Little Endian"
else
ENDIANESS:=$(shell lscpu | grep "Byte Order" |cut -d ":" -f2)
endif
# Windows uses different path separators
ifeq ($(OS_NAME),Windows)
sep := ;
@ -31,7 +39,7 @@ else
sep := :
endif
snappy := snappy-$(VERSION)
snappy := snappy-$(SNAPPY_VERSION)
jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h | head -1)
@ -42,7 +50,8 @@ endif
# os=Default is meant to be generic unix/linux
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armhf Linux-ppc64 Mac-x86 Mac-x86_64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc64
# To support new CPU architecture, add a new target name here
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 Windows-aarch64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64 Linux-loongarch Linux-loongarch64
os_arch := $(OS_NAME)-$(OS_ARCH)
IBM_JDK_7 := $(findstring IBM, $(shell $(JAVA) -version 2>&1 | grep IBM | grep "JRE 1.7"))
@ -67,68 +76,124 @@ CROSS_PREFIX :=
Default_CXX := $(CROSS_PREFIX)g++
Default_STRIP := $(CROSS_PREFIX)strip
Default_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
Default_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -std=c++11
Default_LINKFLAGS := -shared -static
Default_LIBNAME := libsnappyjava.so
Default_SNAPPY_FLAGS :=
Default_SNAPPY_FLAGS :=
Linux-x86_CXX := $(CROSS_PREFIX)g++
Linux-x86_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m32
Linux-x86_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m32 -U__SSE2__ -std=c++11
else
Linux-x86_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m32
Linux-x86_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m32 -U__SSE2__ -std=c++11
endif
Linux-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-x86_LIBNAME := libsnappyjava.so
Linux-x86_SNAPPY_FLAGS:=
Linux-x86_SNAPPY_FLAGS:=
Linux-x86_64_CXX := $(CROSS_PREFIX)g++
Linux-x86_64_CXX := $(CROSS_PREFIX)g++
Linux-x86_64_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-x86_64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
Linux-x86_64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
else
Linux-x86_64_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
Linux-x86_64_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
endif
Linux-x86_64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-x86_64_LIBNAME := libsnappyjava.so
Linux-x86_64_SNAPPY_FLAGS :=
Linux-x86_64_SNAPPY_FLAGS :=
Linux-ppc64_CXX := g++
Linux-ppc64_STRIP := strip
Linux-ppc_CXX := g++
Linux-ppc_STRIP := strip
ifeq ($(IBM_JDK_7),)
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
Linux-ppc_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m32 -std=c++11
else
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC
Linux-ppc_CXXFLAGS := -include lib/inc_linux/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC -m32 -std=c++11
endif
Linux-ppc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-ppc_LIBNAME := libsnappyjava.so
Linux-ppc_SNAPPY_FLAGS :=
Linux-ppc64le_CXX := $(CROSS_PREFIX)g++
Linux-ppc64le_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-ppc64le_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
else
Linux-ppc64le_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC -m64 -std=c++11
endif
# ppcle64 GLIBC is at 2.17; so disable __tls_get_addr_opt which is dependent on 2.22;
Linux-ppc64le_LINKFLAGS := -shared -static-libgcc -static-libstdc++ -Wl,--no-tls-optimize,--no-tls-get-addr-optimize
Linux-ppc64le_LIBNAME := libsnappyjava.so
Linux-ppc64le_SNAPPY_FLAGS :=
Linux-ppc64_CXX := $(CROSS_PREFIX)g++
Linux-ppc64_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-ppc64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
else
Linux-ppc64_CXXFLAGS := -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC -m64 -std=c++11
endif
Linux-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-ppc64_LIBNAME := libsnappyjava.so
Linux-ppc64_SNAPPY_FLAGS :=
AIX-ppc_CXX := g++
AIX-ppc_STRIP := strip
AIX-ppc_LIBNAME := libsnappyjava.a
ifeq ($(IBM_JDK_7),)
AIX-ppc_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -maix32 -std=c++11
else
AIX-ppc_CXXFLAGS := -I$(JAVA_HOME)/include/aix -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -maix32 -std=c++11
endif
AIX-ppc_LINKFLAGS := -shared -static-libgcc -static-libstdc++ -lcrypt
AIX-ppc_SNAPPY_FLAGS :=
AIX-ppc64_CXX := g++
AIX-ppc64_STRIP := strip -X64
AIX-ppc64_LIBNAME := libsnappyjava.a
ifeq ($(IBM_JDK_7),)
AIX-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
AIX-ppc64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -maix64 -std=c++11
else
AIX-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -I$(JAVA_HOME)/include/aix -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -maix64
AIX-ppc64_CXXFLAGS := -I$(JAVA_HOME)/include/aix -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -maix64 -std=c++11
endif
AIX-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++ -lcrypt
AIX-ppc64_SNAPPY_FLAGS :=
SunOS-x86_CXX := g++
Linux-s390_CXX := g++
Linux-s390_STRIP := strip
ifeq ($(IBM_JDK_7),)
Linux-s390_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m31 -std=c++11
else
Linux-s390_CXXFLAGS := -I$(JAVA_HOME)/include/linux -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -m31 -std=c++11
endif
Linux-s390_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-s390_LIBNAME := libsnappyjava.so
Linux-s390_SNAPPY_FLAGS :=
Linux-s390x_CXX := $(CROSS_PREFIX)g++
Linux-s390x_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-s390x_CXXFLAGS := -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
else
Linux-s390x_CXXFLAGS := -I$(JAVA_HOME)/include/linux -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -m64 -std=c++11
endif
Linux-s390x_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-s390x_LIBNAME := libsnappyjava.so
Linux-s390x_SNAPPY_FLAGS :=
SunOS-x86_CXX := g++
SunOS-x86_STRIP := strip
SunOS-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden
SunOS-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
SunOS-x86_LIBNAME := libsnappyjava.so
SunOS-x86_SNAPPY_FLAGS :=
SunOS-x86_SNAPPY_FLAGS :=
SunOS-sparc_CXX := g++
SunOS-sparc_CXX := g++
SunOS-sparc_STRIP := strip
SunOS-sparc_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden
SunOS-sparc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
SunOS-sparc_LIBNAME := libsnappyjava.so
SunOS-sparc_SNAPPY_FLAGS :=
SunOS-sparc_SNAPPY_FLAGS :=
SunOS-x86_64_CXX := g++
SunOS-x86_64_STRIP := strip
@ -144,66 +209,133 @@ SunOS-x86_64_SNAPPY_FLAGS :=
Linux-arm_CXX := $(CROSS_PREFIX)g++
Linux-arm_STRIP := $(CROSS_PREFIX)strip
Linux-arm_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp
Linux-arm_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp -std=c++11
Linux-arm_LINKFLAGS := -shared -static-libgcc
Linux-arm_LIBNAME := libsnappyjava.so
Linux-arm_SNAPPY_FLAGS:=
Linux-arm_SNAPPY_FLAGS:=
Linux-armhf_CXX := $(CROSS_PREFIX)g++
Linux-armhf_STRIP := $(CROSS_PREFIX)strip
Linux-armhf_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=hard
Linux-armhf_LINKFLAGS := -shared -static-libgcc
Linux-armhf_LIBNAME := libsnappyjava.so
Linux-armhf_SNAPPY_FLAGS:=
Linux-armv6_CXX := ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++
Linux-armv6_STRIP := ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip
Linux-armv6_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=hard -std=c++11
Linux-armv6_LINKFLAGS := -shared -static-libgcc -std=c++11
Linux-armv6_LIBNAME := libsnappyjava.so
Linux-armv6_SNAPPY_FLAGS:=
Linux-armv7_CXX := ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++
Linux-armv7_STRIP := ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-strip
Linux-armv7_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp -std=c++11
Linux-armv7_LINKFLAGS := -shared -static-libgcc
Linux-armv7_LIBNAME := libsnappyjava.so
Linux-armv7_SNAPPY_FLAGS:=
Linux-android-arm_CXX := $(CROSS_PREFIX)g++
Linux-android-arm_STRIP := $(CROSS_ROOT)/bin/llvm-strip
Linux-android-arm_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-android-arm_LINKFLAGS := -shared -static-libgcc
Linux-android-arm_LIBNAME := libsnappyjava.so
Linux-android-arm_SNAPPY_FLAGS:=
Linux-android-aarch64_CXX := ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++
Linux-android-aarch64_STRIP := ${CROSS_ROOT}/bin/llvm-strip
Linux-android-aarch64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-android-aarch64_LINKFLAGS := -shared -static-libgcc
Linux-android-aarch64_LIBNAME := libsnappyjava.so
Linux-android-aarch64_SNAPPY_FLAGS:=
Linux-aarch64_CXX := $(CROSS_PREFIX)g++
Linux-aarch64_STRIP := $(CROSS_PREFIX)strip
Linux-aarch64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-aarch64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-aarch64_LIBNAME := libsnappyjava.so
Linux-aarch64_SNAPPY_FLAGS:=
Mac-x86_CXX := g++ -arch i386
Mac-x86_STRIP := strip -x
Mac-x86_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden
Mac-x86_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden -std=c++11
Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc
Mac-x86_LIBNAME := libsnappyjava.jnilib
Mac-x86_LIBNAME := libsnappyjava.dylib
Mac-x86_SNAPPY_FLAGS :=
Mac-x86_64_CXX := g++ -arch $(OS_ARCH)
Mac-x86_64_CXX := c++ -arch $(OS_ARCH)
Mac-x86_64_STRIP := strip -x
Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5 -fvisibility=hidden
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libsnappyjava.jnilib
Mac-x86_64_SNAPPY_FLAGS :=
Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.7 -fvisibility=hidden -stdlib=libc++ -std=c++11 -ftemplate-depth=1024
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libsnappyjava.dylib
Mac-x86_64_SNAPPY_FLAGS :=
Mac-aarch64_CXX := c++ -arch arm64
Mac-aarch64_STRIP := strip -x
Mac-aarch64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.7 -fvisibility=hidden -stdlib=libc++ -std=c++11
Mac-aarch64_LINKFLAGS := -dynamiclib
Mac-aarch64_LIBNAME := libsnappyjava.dylib
FreeBSD-x86_64_CXX := $(CROSS_PREFIX)g++
FreeBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_64_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
FreeBSD-x86_64_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -std=c++11
FreeBSD-x86_64_LINKFLAGS := -shared -static-libgcc
FreeBSD-x86_64_LIBNAME := libsnappyjava.so
FreeBSD-x86_64_SNAPPY_FLAGS :=
FreeBSD-x86_64_SNAPPY_FLAGS :=
Windows-x86_CXX := $(CROSS_PREFIX)g++
Windows-x86_STRIP := $(CROSS_PREFIX)strip
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2 -std=c++11
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_LIBNAME := snappyjava.dll
Windows-x86_SNAPPY_FLAGS :=
Windows-x86_SNAPPY_FLAGS :=
Windows-x86_64_CXX := $(CROSS_PREFIX)g++
Windows-x86_64_STRIP := $(CROSS_PREFIX)strip
Windows-x86_64_CXXFLAGS := -Ilib/inc_win -O2
Windows-x86_64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_64_CXXFLAGS := -Ilib/inc_win -O2 -std=c++11
Windows-x86_64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_64_LIBNAME := snappyjava.dll
Windows-x86_64_SNAPPY_FLAGS :=
Windows-x86_64_SNAPPY_FLAGS :=
Linux-riscv_CXX := $(CROSS_PREFIX)g++
Linux-riscv_STRIP := $(CROSS_PREFIX)strip
Linux-riscv_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-riscv_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-riscv_LIBNAME := libsnappyjava.so
Linux-riscv_SNAPPY_FLAGS:=
Linux-riscv64_CXX := $(CROSS_PREFIX)g++
Linux-riscv64_STRIP := $(CROSS_PREFIX)strip
Linux-riscv64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-riscv64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-riscv64_LIBNAME := libsnappyjava.so
Linux-riscv64_SNAPPY_FLAGS:=
Windows-aarch64_CXX := $(CROSS_PREFIX)g++
Windows-aarch64_STRIP := $(CROSS_PREFIX)strip
Windows-aarch64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -march=armv8-a -fvisibility=hidden -D_WIN32 -DNOMINMAX -std=c++11
Windows-aarch64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-aarch64_LIBNAME := snappyjava.dll
Linux-loongarch_CXX := $(CROSS_PREFIX)g++
Linux-loongarch_STRIP := $(CROSS_PREFIX)strip
Linux-loongarch_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-loongarch_LINKFLAGS := -shared
Linux-loongarch_LIBNAME := libsnappyjava.so
Linux-loongarch_SNAPPY_FLAGS:=
Linux-loongarch64_CXX := $(CROSS_PREFIX)g++
Linux-loongarch64_STRIP := $(CROSS_PREFIX)strip
Linux-loongarch64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-loongarch64_LINKFLAGS := -shared
Linux-loongarch64_LIBNAME := libsnappyjava.so
Linux-loongarch64_SNAPPY_FLAGS:=
CXX := $($(os_arch)_CXX)
STRIP := $($(os_arch)_STRIP)
CXXFLAGS := $($(os_arch)_CXXFLAGS)
LINKFLAGS := $($(os_arch)_LINKFLAGS)
CXXFLAGS := $($(os_arch)_CXXFLAGS)
LINKFLAGS := $($(os_arch)_LINKFLAGS)
LIBNAME := $($(os_arch)_LIBNAME)
SNAPPY_FLAGS := $($(os_arch)_SNAPPY_FLAGS)
CXXFLAGS := $(CXXFLAGS) -Ilib/include
CXXFLAGS := $(CXXFLAGS) -DHAVE_CONFIG_H -DNDEBUG
ifneq ($(jni_include),)
CXXFLAGS := $(CXXFLAGS) -I"$(jni_include)"
endif

View File

@ -28,8 +28,8 @@ DLL_DIR=src/main/resources/org/xerial/snappy/native
DLL_WIN=$(DLL_DIR)/Windows/x86/snappyjava.dll
DLL_WIN64=$(DLL_DIR)/Windows/amd64/snappyjava.dll
DLL_MAC=$(DLL_DIR)/Mac/x86_64/libsnappyjava.jnilib
DLL_TIGER_MAC=$(DLL_DIR)/Mac/i386/libsnappyjava.jnilib
DLL_MAC=$(DLL_DIR)/Mac/x86_64/libsnappyjava.dylib
DLL_TIGER_MAC=$(DLL_DIR)/Mac/i386/libsnappyjava.dylib
DLL_LINUX=$(DLL_DIR)/Linux/i386/libsnappyjava.so
DLL_AMD64=$(DLL_DIR)/Linux/amd64/libsnappyjava.so

View File

@ -1,11 +1,128 @@
## Features under consideration
* `SnappyIndexer` for parallel compression/decompression
* CUI commands (snap/unsnap)
Since vesion 1.1.0.x, Java 6 (1.6) or higher is required.
Since snappy-java 1.1.9.0, release notes will be available in the GitHub releases page https://github.com/xerial/snappy-java/releases
## snappy-java-1.1.1.4 (23 Oct 2014)
* Fixes #88 and #89
Since version 1.1.0.x, Java 6 (1.6) or higher is required.
## snappy-java-1.1.8.3 (2021-01-20)
* Make pure-java Snappy thread-safe [#271](https://github.com/xerial/snappy-java/pull/271)
* Improved SnappyFramedInput/OutputStream performance by using java.util.zip.CRC32C [#269](https://github.com/xerial/snappy-java/pull/269)
## snappy-java-1.1.8.2 (2020-11-28)
* Support Apple Silicon (M1, Mac-aarch64)
* Fixed the pure-java Snappy fallback logic when no native library for your platform is found.
## snappy-java-1.1.8.1 (2020-11-09)
* Fixed an initialization issue when using a recent Mac OS X version [#265](https://github.com/xerial/snappy-java/pull/265)
## snappy-java-1.1.8 (2020-10-20)
* Upgrade to [Snappy 1.1.8](https://github.com/google/snappy/releases/tag/1.1.8) with small performance improvements.
## snappy-java-1.1.7.8 (2020-10-20)
* Big-endian support for pure-java Snappy implementation
* linux-aarch64 (arm64) binary embeds libstdc++ for portability
* internal: Fix make native-all target to support the latest version of dockcross
## snappy-java-1.1.7.7 (2020-08-25)
* Built snappy-java with jdk8 to resolve #251 (java.lang.NoSuchMethodError)
## snappy-java-1.1.7.6 (2020-06-26)
* Added an experimental support of pure-java Snappy https://github.com/xerial/snappy-java#using-pure-java-snappy-implementation
* Pure-java snappy doesn't support Snappy.isValidCompressedBuffer methods, but the other methods, Snappy.compress, uncompress, SnappyInput/OutputStream, SnappyFramedInput/OutputStream, etc., should work as expected.
* Changed the minimum JVM requirement to JDK 1.8
## snappy-java-1.1.7.5 (2020-05-06)
* Fixes java.lang.NoClassDefFoundError: org/xerial/snappy/pool/DefaultPoolFactory in 1.1.7.4
## snapy-java-1.1.7.4 (2020-05-05)
* __DO NOT USE THIS VERSION__ 1.1.7.4 misses a package for using SnappyFramed streams.
* Caching internal buffers for SnappyFramed streams [#234](https://github.com/xerial/snappy-java/pull/234)
* Fixed the native lib for ppc64le to work with glibc 2.17 (Previously it depended on 2.22)
## snappy-java-1.1.7.3 (2019-03-25)
* Minor release
* Output the snappy header even for the empty input to address Spark's [issue](https://issues.apache.org/jira/browse/SPARK-27267)
* Fixed SnappyFramed stream to support Java 9
## snappy-java-1.1.7.2 (2018-05-21)
* Fix for aarch64 endian issue
## snappy-java-1.1.7.1 (2017-12-07)
* Fix for Android. No need to upgrade to this version if you are not using Android
## snappy-java-1.1.7 (2017-11-30)
* Upgrade to [snappy-1.1.7](https://github.com/google/snappy/releases/tag/1.1.7)
* Improved performance for big-endian architecture
* The other performance improvement in [snappy-1.1.5](https://github.com/google/snappy/releases/tag/1.1.5)
* (internal) Changed to use docker + cmake for building native libraries
* Fix android architecture resolution
* Add hadoop compatible SnappyHadoopCompatibleOutputStream
## snappy-java-1.1.4 (2017-05-22)
* Upgrade to [snappy-1.1.4](https://github.com/google/snappy/releases/tag/1.1.4)
* Improved performance compression (5%), decompression (20%)
* Added BitShuffle API for fast and better integer and floating-point value compresssion
* Added native libraries for s390x, AIX/Linux ppc64/ppc64le
* Added prelimirary support Linux armv5, armv6, armv7, android-arm, aarch64
* Using docker for cross-compiling native libraries for various platforms
* Note: snappy-java for FreeBSD, SunOS are still using snappy 1.1.2. Your contributions of native libraries are welcome. Please send a pull request that contains the changes after running `make native test` in your platform.
## snappy-java-1.1.4-M3 (2017-02-16)
* Fix native libraries for ppc64 (bigendian) and ppc64le (little endian)
## snappy-java-1.1.4-M2 (2017-02-13)
* Added s390x and AIX ppc/ppc64 support.
## snappy-java-1.1.4-M1 (2017-02-10)
* A preview release for 1.1.4
## snappy-java-1.1.3-M2 (2017-01-25)
* Rename to BitShuffle.shuffle/unshuffle
* Add ByteBuffer based APIs for bitshffle
## snappy-java-1.1.3-M1 (2017-01-19)
* This is a preview release. Appreciate your feedback.
* Upgraded to snappy 1.1.3 (Minor compression performance improvement)
* Added support for armv5, armv6, armv7, android-arm, aarch64, ppc64
* Added BitShuffle (<https://github.com/kiyo-masui/bitshuffle>) class for better primitive array compression
* Using docker-based cross compilers for building native libraries
* AIX, FreeBSD, SunOS, IBM s390x are still using snappy 1.1.2. Your contributions of native libraries are welcome. Please send a pull request that contains the changes after running `make native` in your platform.
## snappy-java-1.1.2.6 (2016-06-02)
* Fix a bug in SnappyInputStream when reading compressed data that happened to have the same first byte with the stream magic header (#142)
* Never use 1.1.2.5 (This is a broken build)
## snappy-java-1.1.2.4 (2016-03-30)
* Improved `SnappyOutputStream.write(byte[], off, len)` performance.
## snappy-java-1.1.2.3 (2016-03-30)
* Improved `SnappyInputStream.read(byte[], off, len)` performance.
## snappy-java-1.1.2.2 (2016-03-29)
* Add AArch64 support
## snappy-java-1.1.2.1 (2016-01-22)
* Fixed #131
## snappy-java-1.1.2 (22 September 2015)
* This is a backward compatible release for 1.1.x.
* Add AIX (32-bit) support.
* There is no upgrade for the native libraries of the other platforms.
* A major change since 1.1.1 is a support for reading concatenated results of SnappyOutputStream(s)
## snappy-java-1.1.2-RC2 (18 May 2015)
* Fix #107: SnappyOutputStream.close() is not idempotent
## snappy-java-1.1.2-RC1 (13 May 2015)
* SnappyInputStream now supports reading concatenated compressed results of SnappyOutputStream
* There has been no compressed format change since 1.0.5.x. So You can read the compressed results interchangeably between these versions.
* Fixes a problem when java.io.tmpdir does not exist.
## snappy-java-1.1.1.7 (14 Apr 2015)
* Fixes #100
## snappy-java-1.1.1.6 (26 Oct 2014)
* Fixes #88, #89, #90 and #91
* Fixed the broken build of 1.1.1.4 and memory leak bug 1.1.1.5 (so never use these versions)
## snappy-java-1.0.5.4 (12 September 2014)
* Embedded libstdc++ for Linux/amd64 native library (hotfix to 1.0.5.x series)
@ -27,7 +144,7 @@ Since vesion 1.1.0.x, Java 6 (1.6) or higher is required.
* Building with sbt
# snappy-java-1.0.5.2 (25 June 2014)
* Maintanance release
* Maintenance release
* Add PowerPC support ppc64le, ppc64 (big-endian)
# snappy-java-1.1.1-M2 (12 June 2014)
@ -81,7 +198,7 @@ Since vesion 1.1.0.x, Java 6 (1.6) or higher is required.
## snappy-java-1.0.3.2 (August 23rd, 2011)
* Upgrade from the previous release is optional
* Add system properites to switch sytem installed native library or bundled
* Add system properties to switch system installed native library or bundled
library (issue 20, issue 26)
* source code tar ball (issue 25)
* primitive array read/write support (issue 24)
@ -92,7 +209,7 @@ Since vesion 1.1.0.x, Java 6 (1.6) or higher is required.
* Rebuild win32 binary
## snappy-java-1.0.3 (July 11st, 2011)
* Deprected SnappyException. Instead snappy-java uses IOException to issue
* Deprecated SnappyException. Instead snappy-java uses IOException to issue
errors. This change is necessary to support JNI code injection to a parent
class loader.

9
NOTICE
View File

@ -5,8 +5,8 @@ This product includes software developed by Apache
PureJavaCrc32C from apache-hadoop-common http://hadoop.apache.org/
(Apache 2.0 license)
This library containd statically linked libstdc++. This inclusion is allowed by
"GCC RUntime Library Exception"
This library contains statically linked libstdc++. This inclusion is allowed by
"GCC Runtime Library Exception"
http://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html
== Contributors ==
@ -15,3 +15,8 @@ http://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html
* Alec Wysoker
* Performance and memory usage improvement
Third-Party Notices and Licenses:
- Hadoop: Apache Hadoop is used as a dependency
License: Apache License 2.0
Source/Reference: https://github.com/apache/hadoop/blob/trunk/NOTICE.txt

260
README.md
View File

@ -1,77 +1,47 @@
The snappy-java is a Java port of the snappy
<http://code.google.com/p/snappy/>, a fast C++ compresser/decompresser developed by Google.
snappy-java
[![Build Status](https://travis-ci.org/xerial/snappy-java.svg?branch=master)](https://travis-ci.org/xerial/snappy-java)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/)
[![Javadoc](https://javadoc.io/badge2/org.xerial.snappy/snappy-java/javadoc.svg)](https://javadoc.io/doc/org.xerial.snappy/snappy-java)
===
snappy-java is a Java port of the [snappy](https://github.com/google/snappy), a fast C++ compresser/decompresser developed by Google.
## Features
* Fast compression/decompression tailored to 64-bit CPU architecture.
* JNI-based implementation to achieve comparable performance to the native C++ version.
## Features
* Fast compression/decompression around 200~400MB/sec.
* Less memory usage. SnappyOutputStream uses only 32KB+ in default.
* JNI-based implementation to achieve comparable performance to the native C++ version.
* Although snappy-java uses JNI, it can be used safely with multiple class loaders (e.g. Tomcat, etc.).
* Supporting compression/decompression of Java primitive arrays (`float[]`, `double[]`, `int[]`, `short[]`, `long[]`, etc.)
* Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux (64-bit). snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in `org.xerial.snappy.Snappy`.
* [Framing-format support](http://snappy.googlecode.com/svn/trunk/framing_format.txt) (Since 1.1.0 version)
* Compression/decompression of Java primitive arrays (`float[]`, `double[]`, `int[]`, `short[]`, `long[]`, etc.)
* To improve the compression ratios of these arrays, you can use a fast data-rearrangement implementation ([`BitShuffle`](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.8/snappy-java-1.1.8-javadoc.jar/!/org/xerial/snappy/BitShuffle.html)) before compression
* Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux, etc. snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in `org.xerial.snappy.Snappy`.
* [Framing-format support](https://github.com/google/snappy/blob/master/framing_format.txt) (Since 1.1.0 version)
* OSGi support
* [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Free for both commercial and non-commercial use.
## Performance
## Performance
* Snappy's main target is very high-speed compression/decompression with reasonable compression size. So the compression ratio of snappy-java is modest and about the same as `LZF` (ranging 20%-100% according to the dataset).
* Here are some [benchmark results](https://github.com/ning/jvm-compressor-benchmark/wiki), comparing
snappy-java and the other compressors
`LZO-java`/`LZF`/`QuickLZ`/`Gzip`/`Bzip2`. Thanks [Tatu Saloranta @cotowncoder](http://twitter.com/#!/cowtowncoder) for providing the benchmark suite.
* The benchmark result indicates snappy-java is the fastest compreesor/decompressor in Java
* <http://ning.github.com/jvm-compressor-benchmark/results/canterbury-roundtrip-2011-07-28/index.html>
* The decompression speed is twice as fast as the others:
* <http://ning.github.com/jvm-compressor-benchmark/results/canterbury-uncompress-2011-07-28/index.html>
`LZO-java`/`LZF`/`QuickLZ`/`Gzip`/`Bzip2`. Thanks [Tatu Saloranta @cotowncoder](http://twitter.com/#!/cowtowncoder) for providing the benchmark suite.
* The benchmark result indicates snappy-java is the fastest compressor/decompressor in Java: https://ning.github.io/jvm-compressor-benchmark/results/canterbury-roundtrip-2011-07-28/index.html
* The decompression speed is twice as fast as the others: https://ning.github.io/jvm-compressor-benchmark/results/canterbury-uncompress-2011-07-28/index.html
## Download
## Download
* [Release Notes](Milestone.md)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.xerial.snappy/snappy-java/)
[![Javadoc](https://javadoc.io/badge2/org.xerial.snappy/snappy-java/javadoc.svg)](https://javadoc.io/doc/org.xerial.snappy/snappy-java)
* [Release Notes](Milestone.md)
The current stable version is available from here:
* Release version: http://central.maven.org/maven2/org/xerial/snappy/snappy-java/
* Release version: https://repo1.maven.org/maven2/org/xerial/snappy/snappy-java/
* Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/org/xerial/snappy/snappy-java/
For Maven user, see [pom.xml example](#using-with-maven).
## Usage
First, import `org.xerial.snapy.Snappy` in your Java code:
```java
import org.xerial.snappy.Snappy;
```
Then use `Snappy.compress(byte[])` and `Snappy.uncompress(byte[])`:
```java
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
```
In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(float[] ..)` etc. ) and low-level ones (e.g. `Snappy.rawCompress(.. )`, `Snappy.rawUncompress(..)`, etc.), which minimize memory copies, can be used.
### Stream-based API
Stream-based compressor/decompressor `SnappyFramedOutputStream`/`SnappyFramedInputStream` are also available for reading/writing large data sets.
* See also [Javadoc API](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.0/snappy-java-1.1.0-javadoc.jar/!/index.html)
### Setting classpath
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:
$ javac -classpath ".;snappy-java-(VERSION).jar" Sample.java # in Windows
or
$ javac -classpath ".:snappy-java-(VERSION).jar" Sample.java # in Mac or Linux
### Using with Maven
* Snappy-java is available from Maven's central repository: <http://repo1.maven.org/maven2/org/xerial/snappy/snappy-java>
Add the following dependency to your pom.xml:
Snappy-java is available from Maven's central repository. Add the following dependency to your pom.xml:
<dependency>
<groupId>org.xerial.snappy</groupId>
@ -88,65 +58,84 @@ libraryDependencies += "org.xerial.snappy" % "snappy-java" % "(version)"
```
## Usage
First, import `org.xerial.snapy.Snappy` in your Java code:
```java
import org.xerial.snappy.Snappy;
```
Then use `Snappy.compress(byte[])` and `Snappy.uncompress(byte[])`:
```java
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
```
In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(float[] ..)` etc. ) and low-level ones (e.g. `Snappy.rawCompress(.. )`, `Snappy.rawUncompress(..)`, etc.), which minimize memory copies, can be used.
### Stream-based API
Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets. `SnappyFramedOutputStream`/`SnappyFramedInputStream` can be used for the [framing format](https://github.com/google/snappy/blob/master/framing_format.txt).
* See also [Javadoc API](https://oss.sonatype.org/service/local/repositories/releases/archive/org/xerial/snappy/snappy-java/1.1.3-M1/snappy-java-1.1.3-M1-javadoc.jar/!/index.html)
#### Compatibility Notes
The original Snappy format definition did not define a file format. It later added
a "framing" format to define a file format, but by this point major software was
already using an industry standard instead -- represented in this library by the
`SnappyOutputStream` and `SnappyInputStream` methods.
For interoperability with other libraries, check that compatible formats are used.
Note that not all libraries support all variants.
* `SnappyOutputStream` and `SnappyInputStream` use `[magic header:16 bytes]([block size:int32][compressed data:byte array])*` format. You can read the result of `Snappy.compress` with `SnappyInputStream`, but you cannot read the compressed data generated by `SnappyOutputStream` with `Snappy.uncompress`.
* `SnappyHadoopCompatibleOutputStream` does not emit a file header but write out the current block size as a preemble to each block
#### Data format compatibility matrix:
| Write\Read | `Snappy.uncompress` | `SnappyInputStream` | `SnappyFramedInputStream` | `org.apache.hadoop.io.compress.SnappyCodec` |
| --------------- |:-------------------:|:------------------:|:-----------------------:|:-------------------------------------------:|
| `Snappy.compress` | ok | ok | x | x |
| `SnappyOutputStream` | x | ok | x | x |
| `SnappyFramedOutputStream` | x | x | ok | x |
| `SnappyHadoopCompatibleOutputStream` | x | x | x | ok |
### BitShuffle API (Since 1.1.3-M2)
BitShuffle is an algorithm that reorders data bits (shuffle) for efficient compression (e.g., a sequence of integers, float values, etc.). To use BitShuffle routines, import `org.xerial.snapy.BitShuffle`:
```java
import org.xerial.snappy.BitShuffle;
int[] data = new int[] {1, 3, 34, 43, 34};
byte[] shuffledByteArray = BitShuffle.shuffle(data);
byte[] compressed = Snappy.compress(shuffledByteArray);
byte[] uncompressed = Snappy.uncompress(compressed);
int[] result = BitShuffle.unshuffleIntArray(uncompress);
System.out.println(result);
```
Shuffling and unshuffling of primitive arrays (e.g., `short[]`, `long[]`, `float[]`, `double[]`, etc.) are supported. See [Javadoc](http://static.javadoc.io/org.xerial.snappy/snappy-java/1.1.3-M1/org/xerial/snappy/BitShuffle.html) for the details.
### Setting classpath
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:
$ javac -classpath ".;snappy-java-(VERSION).jar" Sample.java # in Windows
or
$ javac -classpath ".:snappy-java-(VERSION).jar" Sample.java # in Mac or Linux
## Public discussion group
Post bug reports or feature request to the Issue Tracker: <https://github.com/xerial/snappy-java/issues>
Public discussion forum is here: <http://groups.google.com/group/xerial?hl=en Xerial Public Discussion Group>
## Building from the source code
See the [installation instruction](https://github.com/xerial/snappy-java/blob/develop/INSTALL). Building from the source code is an option when your OS platform and CPU architecture is not supported. To build snappy-java, you need Git, JDK (1.6 or higher), g++ compiler (mingw in Windows) etc.
$ git clone https://github.com/xerial/snappy-java.git
$ cd snappy-java
$ make
When building on Solaris use
$ gmake
A file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.
## Building linux x86_64 binary
snappy-java tries to static link libstdc++ to increase the availability for various Linux versions. However, standard distributions of 64-bit Linux OS rarely provide libstdc++ compiled with `-fPIC` option. I currently uses custom g++, compiled as follows:
```
$ cd work
$ wget (gcc-4.8.3 source)
$ tar xvfz (gcc-4.8.3.tar.gz)
$ cd gcc-4.8.3
$ ./contrib/download_prerequisites
$ cd ..
$ mkdir objdir
$ cd objdir
$ ../gcc-4.8.3/configure --prefix=$HOME/local/gcc-4.8.3 CXXFLAGS=-fPIC CFLAGS=-fPIC --enable-languages=c,c++
$ make
$ make install
```
This g++ build enables static linking of libstdc++. For more infomation on building GCC, see GCC's home page.
## Cross-compiling for other platforms
The Makefile contains rules for cross-compiling the native library for other platforms so that the snappy-java JAR can support multiple platforms. For example, to build the native libraries for x86 Linux, x86 and x86-64 Windows, and soft- and hard-float ARM:
$ make linux32 win32 win64 linux-arm linux-armhf
If you append `snappy` to the line above, it will also build the native library for the current platform and then build the snappy-java JAR (containing all native libraries built so far).
Of course, you must first have the necessary cross-compilers and development libraries installed for each target CPU and OS. For example, on Ubuntu 12.04 for x86-64, install the following packages for each target:
* linux32: `sudo apt-get install g++-multilib libc6-dev-i386 lib32stdc++6`
* win32: `sudo apt-get install g++-mingw-w64-i686`
* win64: `sudo apt-get install g++-mingw-w64-x86-64`
* arm: `sudo apt-get install g++-arm-linux-gnueabi`
* armhf: `sudo apt-get install g++-arm-linux-gnueabihf`
Unfortunately, cross-compiling for Mac OS X is not currently possible; you must compile within OS X.
If you are using Mac and openjdk7 (or higher), use the following option:
$ make native LIBNAME=libsnappyjava.dylib
Public discussion forum is here: [Xerial Public Discussion Group](http://groups.google.com/group/xerial?hl=en)
## For developers
@ -154,16 +143,55 @@ snappy-java uses sbt (simple build tool for Scala) as a build tool. Here is a si
$ ./sbt # enter sbt console
> ~test # run tests upon source code change
> ~test-only * # run tests that matches a given name pattern
> ~testOnly # run tests that matches a given name pattern
> publishM2 # publish jar to $HOME/.m2/repository
> package # create jar file
> findbugs # Produce findbugs report in target/findbugs
> jacoco:cover # Report the code coverage of tests to target/jacoco folder
If you need to see detailed debug messages, launch sbt with `-Dloglevel=debug` option:
```
$ ./sbt -Dloglevel=debug
```
For the details of sbt usage, see my blog post: [Building Java Projects with sbt](http://xerial.org/blog/2014/03/24/sbt/)
### Building from the source code
See the [build instruction](https://github.com/xerial/snappy-java/blob/master/BUILD.md). Building from the source code is an option when your OS platform and CPU architecture is not supported. To build snappy-java, you need Git, JDK (1.6 or higher), g++ compiler (mingw in Windows) etc.
$ git clone https://github.com/xerial/snappy-java.git
$ cd snappy-java
$ make
When building on Solaris, use `gmake`:
$ gmake
A file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.
### Creating a new release
GitHub action [https://github.com/xerial/snappy-java/blob/master/.github/workflows/release.yml] will publish a new relase to Maven Central (Sonatype) when a new tag vX.Y.Z is pushed.
## Miscellaneous Notes
### Using snappy-java with Tomcat 6 (or higher) Web Server
Simply put the snappy-java's jar to WEB-INF/lib folder of your web application. Usual JNI-library specific problem no longer exists since snappy-java version 1.0.3 or higher can be loaded by multiple class loaders.
Simply put the snappy-java's jar to WEB-INF/lib folder of your web application. Usual JNI-library specific problem no longer exists since snappy-java version 1.0.3 or higher can be loaded by multiple class loaders.
### Configure snappy-java using property file
Prepare org-xerial-snappy.properties file (under the root path of your library) in Java's property file format.
Here is a list of the available properties:
* org.xerial.snappy.lib.path (directory containing a snappyjava's native library)
* org.xerial.snappy.lib.name (library file name)
* org.xerial.snappy.tempdir (temporary directory to extract a native library bundled in snappy-java)
* org.xerial.snappy.use.systemlib (if this value is true, use system installed libsnappyjava.so looking the path specified by java.library.path)
----
Snappy-java is developed by [Taro L. Saito](http://www.xerial.org/leo). Twitter [@taroleo](http://twitter.com/#!/taroleo)

12
SECURITY.md Normal file
View File

@ -0,0 +1,12 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.1.9.x | :white_check_mark: |
| < 1.1.8.x | :x: |
## Reporting a Vulnerability
https://github.com/xerial/snappy-java/security/advisories

185
build.sbt
View File

@ -1,107 +1,124 @@
import SonatypeKeys._
sonatypeSettings
name := "snappy-java"
organization := "org.xerial.snappy"
Global / onChangedBuildSource := ReloadOnSourceChanges
name := "snappy-java"
organization := "org.xerial.snappy"
organizationName := "xerial.org"
description := "snappy-java: A fast compression/decompression library"
description := "snappy-java: A fast compression/decompression library"
sonatypeProfileName := "org.xerial"
ThisBuild / publishTo := sonatypePublishToBundle.value
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html"))
homepage := Some(url("https://github.com/xerial/snappy-java"))
scmInfo := Some(
ScmInfo(
browseUrl = url("https://github.com/xerial/snappy-java"),
connection = "scm:git@github.com:xerial/snappy-java.git"
)
)
developers := List(
Developer(id = "leo", name = "Taro L. Saito", email = "leo@xerial.org", url = url("http://xerial.org/leo"))
)
profileName := "org.xerial"
// Use dynamic snapshot version strings for non tagged versions
ThisBuild / dynverSonatypeSnapshots := true
// Use coursier friendly version separator
ThisBuild / dynverSeparator := "-"
pomExtra := {
<url>https://github.comm/xerial/snappy-java</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>leo</id>
<name>Taro L. Saito</name>
<email>leo@xerial.org</email>
<organization>Xerial Project</organization>
<roles>
<role>Architect</role>
<role>Project Manager</role>
<role>Chief Developer</role>
</roles>
<timezone>+9</timezone>
</developer>
</developers>
<issueManagement>
<system>GitHub</system>
<url>http://github.com/xerial/snappy-java/issues/list</url>
</issueManagement>
<inceptionYear>2011</inceptionYear>
<scm>
<connection>scm:git@github.com:xerial/snappy-java.git</connection>
<developerConnection>scm:git:git@github.com:xerial/snappy-java.git</developerConnection>
<url>git@github.com:xerial/snappy-java.git</url>
</scm>
ThisBuild / scalaVersion := "2.12.11"
// For building jars for JDK8
ThisBuild / javacOptions ++= {
if (scala.util.Properties.isJavaAtLeast("9")) {
// --release 8 option is not available in JDK8
Seq("--release", "8")
} else {
Seq.empty
}
}
Compile / compile / javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation")
doc / javacOptions := {
val opts = Seq("-source", "1.8")
if (scala.util.Properties.isJavaAtLeast("1.8"))
opts ++ Seq("-Xdoclint:none")
else
opts
}
scalaVersion := "2.11.1"
// Configuration for SnappyHadoopCompatibleOutputStream testing
Test / fork := true
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6")
val libTemp = {
val path = s"${System.getProperty("java.io.tmpdir")}/snappy_test_${System.currentTimeMillis()}"
// certain older Linux systems (debian/trusty in Travis CI) requires the libsnappy.so, loaded by
// libhadoop.so, be copied to the temp path before the child JVM is forked.
// because of that, cannot define as an additional task in Test scope
IO.copyFile(file("src/test/resources/lib/Linux/libsnappy.so"), file(s"$path/libsnappy.so"))
IO.copyFile(file("src/test/resources/lib/Linux/libsnappy.so"), file(s"$path/libsnappy.so.1"))
path
}
val macOSXLibPath = s"$libTemp:${System.getenv("DYLD_LIBRARY_PATH")}"
val linuxLibPath = s"$libTemp:${System.getenv("LD_LIBRARY_PATH")}"
// have to add to system dynamic library path since hadoop native library indirectly load libsnappy.1
// can't use javaOptions in Test because it causes the expression to eval twice yielding different temp path values
Test / envVars := Map("XERIAL_SNAPPY_LIB" -> libTemp, "DYLD_LIBRARY_PATH" -> macOSXLibPath, "LD_LIBRARY_PATH" -> linuxLibPath)
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
Test / parallelExecution := false
autoScalaLibrary := false
crossPaths := false
logBuffered in Test := false
incOptions := incOptions.value.withNameHashing(true)
crossPaths := false
libraryDependencies ++= Seq(
"junit" % "junit" % "4.8.2" % "test",
"org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test",
"org.xerial.java" % "xerial-core" % "2.1" % "test",
"org.xerial" % "xerial-core" % "3.2.3" % "test",
"org.scalatest" % "scalatest_2.11" % "2.2.0" % "test",
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
"com.novocode" % "junit-interface" % "0.10" % "test"
"junit" % "junit" % "4.13.2" % "test",
"org.codehaus.plexus" % "plexus-classworlds" % "2.8.0" % "test",
"org.xerial.java" % "xerial-core" % "2.1" % "test",
"org.wvlet.airframe" %% "airframe-log" % "2025.1.1" % "test",
"org.osgi" % "org.osgi.core" % "6.0.0" % "provided",
"com.github.sbt" % "junit-interface" % "0.13.3" % "test",
"org.apache.hadoop" % "hadoop-common" % "3.4.1" % "test" exclude ("org.xerial.snappy", "snappy-java")
)
enablePlugins(SbtOsgi)
osgiSettings
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer")
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java"
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""
OsgiKeys.additionalHeaders := Map(
"Bundle-NativeCode" -> Seq(
"org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x86-64",
"org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86",
"org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86",
"org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;osname=macosx;processor=x86-64",
"org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64",
"org/xerial/snappy/native/Linux/x86/libsnappyjava.so;osname=linux;processor=x86",
"org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm",
"org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64",
"org/xerial/snappy/native/Linux/ppc64le/libsnappyjava.so;osname=linux;processor=ppc64le",
"org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
"org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",
"org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64",
"org/xerial/snappy/native/SunOS/sparc/libsnappyjava.so;osname=sunos;processor=sparc"
).mkString(","),
"Bundle-DocURL" -> "http://www.xerial.org/",
"Bundle-License" -> "http://www.apache.org/licenses/LICENSE-2.0.txt",
"Bundle-ActivationPolicy" -> "lazy",
"Bundle-Name" -> "snappy-java: A fast compression/decompression library"
"org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x86-64",
"org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x64",
"org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=amd64",
"org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86",
"org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86",
"org/xerial/snappy/native/Mac/x86_64/libsnappyjava.dylib;osname=macosx;processor=x86-64",
"org/xerial/snappy/native/Mac/aarch64/libsnappyjava.dylib;osname=macosx;processor=aarch64",
"org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64",
"org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x64",
"org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=amd64",
"org/xerial/snappy/native/Linux/x86/libsnappyjava.so;osname=linux;processor=x86",
"org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so;osname=linux;processor=aarch64",
"org/xerial/snappy/native/Linux/riscv64/libsnappyjava.so;osname=linux;processor=riscv64",
"org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm",
"org/xerial/snappy/native/Linux/armv7/libsnappyjava.so;osname=linux;processor=arm_le",
"org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64le",
"org/xerial/snappy/native/Linux/s390x/libsnappyjava.so;osname=linux;processor=s390x",
"org/xerial/snappy/native/Linux/loongarch64/libsnappyjava.so;osname=linux;processor=loongarch64",
"org/xerial/snappy/native/AIX/ppc/libsnappyjava.a;osname=aix;processor=ppc",
"org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
"org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",
"org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64",
"org/xerial/snappy/native/SunOS/sparc/libsnappyjava.so;osname=sunos;processor=sparc"
).mkString(","),
"Bundle-DocURL" -> "http://www.xerial.org/",
"Bundle-License" -> "http://www.apache.org/licenses/LICENSE-2.0.txt",
"Bundle-ActivationPolicy" -> "lazy",
"Bundle-Name" -> "snappy-java: A fast compression/decompression library"
)

View File

@ -0,0 +1,41 @@
FROM centos:5
MAINTAINER Taro L. Saito <leo@xerial.org>
RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
RUN sed -i 's/mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo
RUN sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever|baseurl=http://vault.centos.org/5.11|' /etc/yum.repos.d/*.repo
RUN yum -y install make gcc gcc-c++ glibc-devel perl wget bzip2 curl \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /tmp/work \
&& cd /tmp/work \
&& wget http://www.netgull.com/gcc/releases/gcc-4.8.3/gcc-4.8.3.tar.gz \
&& tar xvfz gcc-4.8.3.tar.gz \
&& cd gcc-4.8.3 \
&& ./contrib/download_prerequisites \
&& cd .. \
&& mkdir objdir
RUN cd /tmp/work/objdir \
&& ../gcc-4.8.3/configure --prefix=/usr/local/gcc-4.8.3 CXXFLAGS=-fPIC CFLAGS=-fPIC --enable-languages=c,c++ \
&& make
RUN cd /tmp/work/objdir \
&& make install \
&& rm -rf /tmp/work
#RUN mkdir /tmp/cmake \
# && cd /tmp/cmake \
# && wget --no-check-certificate https://cmake.org/files/v3.10/cmake-3.10.0.tar.gz \
# && tar xvfz cmake-3.10.0.tar.gz \
# && cd cmake-3.10.0 \
# && CXX=/usr/local/gcc-4.8.3/bin/g++ ./bootstrap \
# && make \
# && make install \
# && rm -rf /tmp/cmake
ENV PATH /usr/local/gcc-4.8.3/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/gcc-4.8.3/lib64/:$LD_LIBRARY_PATH
WORKDIR /work

View File

@ -0,0 +1,55 @@
FROM dockcross/base:latest
MAINTAINER Taro L. Saito "leo@xerial.org"
# Add the cross compiler sources
RUN echo "deb http://emdebian.org/tools/debian/ jessie main" >> /etc/apt/sources.list && \
dpkg --add-architecture powerpc && \
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -
RUN apt-get update && apt-get install -y \
crossbuild-essential-powerpc \
gfortran-powerpc-linux-gnu \
libbz2-dev:powerpc \
libexpat1-dev:powerpc \
ncurses-dev:powerpc \
libssl-dev:powerpc
WORKDIR /usr/src
RUN apt-get update && \
apt-get install -y libglib2.0-dev zlib1g-dev libpixman-1-dev && \
curl -L http://wiki.qemu-project.org/download/qemu-2.6.0.tar.bz2 | tar xj && \
cd qemu-2.6.0 && \
./configure --target-list=ppc64-linux-user --prefix=/usr && \
make -j$(nproc) && \
make install && \
cd .. && rm -rf qemu-2.6.0
ENV CROSS_TRIPLE powerpc-linux-gnu
ENV CROSS_ROOT /usr/${CROSS_TRIPLE}
ENV AS=/usr/bin/${CROSS_TRIPLE}-as \
AR=/usr/bin/${CROSS_TRIPLE}-ar \
CC=/usr/bin/${CROSS_TRIPLE}-gcc \
CPP=/usr/bin/${CROSS_TRIPLE}-cpp \
CXX=/usr/bin/${CROSS_TRIPLE}-g++ \
LD=/usr/bin/${CROSS_TRIPLE}-ld
ENV DEFAULT_DOCKCROSS_IMAGE dockcross/linux-ppc64
WORKDIR /work
# Note: Toolchain file support is currently in debian Experimental according to:
# https://wiki.debian.org/CrossToolchains#In_jessie_.28Debian_8.29
# We can switch to that when it becomes stable.
COPY Toolchain-ppc64.cmake /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake
ENV CMAKE_TOOLCHAIN_FILE /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake
# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"

9
docker/Makefile Normal file
View File

@ -0,0 +1,9 @@
centos5-image:
docker build -f Dockerfile.centos5-linux-x86_64-pic -t xerial/centos5-linux-x86_64:latest
# dockerhub login
# docker login --username=xerial
# docker push xerial/centos5-linux-x86_64:latest
multiarch-crossbuild-image:
docker build https://github.com/iwasakims/crossbuild.git#fix-osxcross-cmake -t xerial/crossbuild:latest

View File

@ -0,0 +1,15 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR ppc64)
set(cross_triple "ppc64-linux-gnu")
set(CMAKE_C_COMPILER /usr/bin/${cross_triple}-cc)
set(CMAKE_CXX_COMPILER /usr/bin/${cross_triple}-c++)
set(CMAKE_Fortran_COMPILER /usr/bin/${cross_triple}-gfortran)
# Discard path returned by pkg-config and associated with HINTS in module
# like FindOpenSSL.
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/lib/)
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-ppc64)

200
docker/dockcross-aarch64 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-arm64-lts
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

279
docker/dockcross-android-arm Executable file
View File

@ -0,0 +1,279 @@
#!/usr/bin/env bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/android-arm:20230116-670f7f7
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 "ERROR: $*\n"
}
die() {
err "$*"
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
# If OCI_EXE is not already set, search for a container executor (OCI stands for "Open Container Initiative")
if [ -z "$OCI_EXE" ]; then
if which podman >/dev/null 2>/dev/null; then
OCI_EXE=podman
elif which docker >/dev/null 2>/dev/null; then
OCI_EXE=docker
else
die "Cannot find a container executor. Search for docker and podman."
fi
fi
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
$OCI_EXE pull $FINAL_IMAGE
}
help:update-image() {
echo "Pull the latest $FINAL_IMAGE ."
}
command:update-script() {
if cmp -s <( $OCI_EXE run --rm $FINAL_IMAGE ) $0; then
echo "$0 is up to date"
else
echo -n "Updating $0 ... "
$OCI_EXE run --rm $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-script() {
echo "Update $0 from $FINAL_IMAGE ."
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo "Pull the latest $FINAL_IMAGE, and then update $0 from that."
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
shift
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# Bash on Ubuntu on Windows
UBUNTU_ON_WINDOWS=$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
# MSYS, Git Bash, etc.
MSYS=$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
# CYGWIN
CYGWIN=$([ -e /proc/version ] && grep -l CYGWIN /proc/version || echo "")
if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" -a "$OCI_EXE" != "podman" ]; then
USER_IDS=(-e BUILDER_UID="$( id -u )" -e BUILDER_GID="$( id -g )" -e BUILDER_USER="$( id -un )" -e BUILDER_GROUP="$( id -gn )")
fi
# Change the PWD when working in Docker on Windows
if [ -n "$UBUNTU_ON_WINDOWS" ]; then
WSL_ROOT="/mnt/"
CFG_FILE=/etc/wsl.conf
if [ -f "$CFG_FILE" ]; then
CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
eval "$CFG_CONTENT"
if [ -n "$root" ]; then
WSL_ROOT=$root
fi
fi
HOST_PWD=`pwd -P`
HOST_PWD=${HOST_PWD/$WSL_ROOT//}
elif [ -n "$MSYS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\//}
HOST_PWD=${HOST_PWD/\//:\/}
elif [ -n "$CYGWIN" ]; then
for f in pwd readlink cygpath ; do
test -n "$(type "${f}" )" || { echo >&2 "Missing functionality (${f}) (in cygwin)." ; exit 1 ; } ;
done ;
HOST_PWD="$( cygpath -w "$( readlink -f "$( pwd ;)" ; )" ; )" ;
else
HOST_PWD=$PWD
[ -L $HOST_PWD ] && HOST_PWD=$(readlink $HOST_PWD)
fi
# Mount Additional Volumes
if [ -z "$SSH_DIR" ]; then
SSH_DIR="$HOME/.ssh"
fi
HOST_VOLUMES=
if [ -e "$SSH_DIR" -a -z "$MSYS" ]; then
if test -n "${CYGWIN}" ; then
HOST_VOLUMES+="-v $(cygpath -w ${SSH_DIR} ; ):/home/$(id -un)/.ssh" ;
else
HOST_VOLUMES+="-v $SSH_DIR:/home/$(id -un)/.ssh" ;
fi ;
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
TTY_ARGS=
tty -s && [ -z "$MSYS" ] && TTY_ARGS=-ti
CONTAINER_NAME=dockcross_$RANDOM
$OCI_EXE run $TTY_ARGS --name $CONTAINER_NAME \
--platform linux/amd64 \
-v "$HOST_PWD":/work \
$HOST_VOLUMES \
"${USER_IDS[@]}" \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
run_exit_code=$?
# Attempt to delete container
rm_output=$($OCI_EXE rm -f $CONTAINER_NAME 2>&1)
rm_exit_code=$?
if [[ $rm_exit_code != 0 ]]; then
if [[ "$CIRCLECI" == "true" ]] && [[ $rm_output == *"Driver btrfs failed to remove"* ]]; then
: # Ignore error because of https://circleci.com/docs/docker-btrfs-error/
else
echo "$rm_output"
exit $rm_exit_code
fi
fi
exit $run_exit_code
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/android-arm:20230116-670f7f7 image, run:
#
# docker run --rm dockcross/android-arm:20230116-670f7f7 > dockcross-android-arm-20230116-670f7f7
# chmod +x dockcross-android-arm-20230116-670f7f7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

278
docker/dockcross-android-arm64 Executable file
View File

@ -0,0 +1,278 @@
#!/usr/bin/env bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/android-arm64:20230421-a0eaff4
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 "ERROR: $*\n"
}
die() {
err "$*"
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
# If OCI_EXE is not already set, search for a container executor (OCI stands for "Open Container Initiative")
if [ -z "$OCI_EXE" ]; then
if which podman >/dev/null 2>/dev/null; then
OCI_EXE=podman
elif which docker >/dev/null 2>/dev/null; then
OCI_EXE=docker
else
die "Cannot find a container executor. Search for docker and podman."
fi
fi
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
$OCI_EXE pull $FINAL_IMAGE
}
help:update-image() {
echo "Pull the latest $FINAL_IMAGE ."
}
command:update-script() {
if cmp -s <( $OCI_EXE run --rm $FINAL_IMAGE ) $0; then
echo "$0 is up to date"
else
echo -n "Updating $0 ... "
$OCI_EXE run --rm $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-script() {
echo "Update $0 from $FINAL_IMAGE ."
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo "Pull the latest $FINAL_IMAGE, and then update $0 from that."
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
shift
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# Bash on Ubuntu on Windows
UBUNTU_ON_WINDOWS=$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
# MSYS, Git Bash, etc.
MSYS=$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
# CYGWIN
CYGWIN=$([ -e /proc/version ] && grep -l CYGWIN /proc/version || echo "")
if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" -a "$OCI_EXE" != "podman" ]; then
USER_IDS=(-e BUILDER_UID="$( id -u )" -e BUILDER_GID="$( id -g )" -e BUILDER_USER="$( id -un )" -e BUILDER_GROUP="$( id -gn )")
fi
# Change the PWD when working in Docker on Windows
if [ -n "$UBUNTU_ON_WINDOWS" ]; then
WSL_ROOT="/mnt/"
CFG_FILE=/etc/wsl.conf
if [ -f "$CFG_FILE" ]; then
CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
eval "$CFG_CONTENT"
if [ -n "$root" ]; then
WSL_ROOT=$root
fi
fi
HOST_PWD=`pwd -P`
HOST_PWD=${HOST_PWD/$WSL_ROOT//}
elif [ -n "$MSYS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\//}
HOST_PWD=${HOST_PWD/\//:\/}
elif [ -n "$CYGWIN" ]; then
for f in pwd readlink cygpath ; do
test -n "$(type "${f}" )" || { echo >&2 "Missing functionality (${f}) (in cygwin)." ; exit 1 ; } ;
done ;
HOST_PWD="$( cygpath -w "$( readlink -f "$( pwd ;)" ; )" ; )" ;
else
HOST_PWD=$PWD
[ -L $HOST_PWD ] && HOST_PWD=$(readlink $HOST_PWD)
fi
# Mount Additional Volumes
if [ -z "$SSH_DIR" ]; then
SSH_DIR="$HOME/.ssh"
fi
HOST_VOLUMES=
if [ -e "$SSH_DIR" -a -z "$MSYS" ]; then
if test -n "${CYGWIN}" ; then
HOST_VOLUMES+="-v $(cygpath -w ${SSH_DIR} ; ):/home/$(id -un)/.ssh" ;
else
HOST_VOLUMES+="-v $SSH_DIR:/home/$(id -un)/.ssh" ;
fi ;
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
TTY_ARGS=
tty -s && [ -z "$MSYS" ] && TTY_ARGS=-ti
CONTAINER_NAME=dockcross_$RANDOM
$OCI_EXE run $TTY_ARGS --name $CONTAINER_NAME \
-v "$HOST_PWD":/work \
$HOST_VOLUMES \
"${USER_IDS[@]}" \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
run_exit_code=$?
# Attempt to delete container
rm_output=$($OCI_EXE rm -f $CONTAINER_NAME 2>&1)
rm_exit_code=$?
if [[ $rm_exit_code != 0 ]]; then
if [[ "$CIRCLECI" == "true" ]] && [[ $rm_output == *"Driver btrfs failed to remove"* ]]; then
: # Ignore error because of https://circleci.com/docs/docker-btrfs-error/
else
echo "$rm_output"
exit $rm_exit_code
fi
fi
exit $run_exit_code
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/android-arm64:20230421-a0eaff4 image, run:
#
# docker run --rm dockcross/android-arm64:20230421-a0eaff4 > dockcross-android-arm64-20230421-a0eaff4
# chmod +x dockcross-android-arm64-20230421-a0eaff4
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

242
docker/dockcross-arm64 Executable file
View File

@ -0,0 +1,242 @@
#!/usr/bin/env bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-arm64-lts
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run --rm $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run --rm $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
shift
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# Bash on Ubuntu on Windows
UBUNTU_ON_WINDOWS=$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
# MSYS, Git Bash, etc.
MSYS=$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" ]; then
USER_IDS=(-e BUILDER_UID="$( id -u )" -e BUILDER_GID="$( id -g )" -e BUILDER_USER="$( id -un )" -e BUILDER_GROUP="$( id -gn )")
fi
# Change the PWD when working in Docker on Windows
if [ -n "$UBUNTU_ON_WINDOWS" ]; then
WSL_ROOT="/mnt/"
CFG_FILE=/etc/wsl.conf
if [ -f "$CFG_FILE" ]; then
CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
eval "$CFG_CONTENT"
if [ -n "$root" ]; then
WSL_ROOT=$root
fi
fi
HOST_PWD=`pwd -P`
HOST_PWD=${HOST_PWD/$WSL_ROOT//}
elif [ -n "$MSYS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\//}
HOST_PWD=${HOST_PWD/\//:\/}
else
HOST_PWD=$PWD
fi
# Mount Additional Volumes
if [ -z "$SSH_DIR" ]; then
SSH_DIR="$HOME/.ssh"
fi
HOST_VOLUMES=
if [ -e "$SSH_DIR" ]; then
HOST_VOLUMES+="-v $SSH_DIR:/home/$(id -un)/.ssh"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
tty -s && TTY_ARGS=-ti || TTY_ARGS=
CONTAINER_NAME=dockcross_$RANDOM
docker run $TTY_ARGS --name $CONTAINER_NAME \
-v "$HOST_PWD":/work \
$HOST_VOLUMES \
"${USER_IDS[@]}" \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
run_exit_code=$?
exit $run_exit_code
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-arm64 image, run:
#
# docker run --rm dockcross/linux-arm64 > dockcross-linux-arm64
# chmod +x dockcross-linux-arm64
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-armv5 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-armv5
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-armv6 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-armv6-lts
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

278
docker/dockcross-armv7 Executable file
View File

@ -0,0 +1,278 @@
#!/usr/bin/env bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-armv7-lts:20230421-a0eaff4
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 "ERROR: $*\n"
}
die() {
err "$*"
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
# If OCI_EXE is not already set, search for a container executor (OCI stands for "Open Container Initiative")
if [ -z "$OCI_EXE" ]; then
if which podman >/dev/null 2>/dev/null; then
OCI_EXE=podman
elif which docker >/dev/null 2>/dev/null; then
OCI_EXE=docker
else
die "Cannot find a container executor. Search for docker and podman."
fi
fi
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
$OCI_EXE pull $FINAL_IMAGE
}
help:update-image() {
echo "Pull the latest $FINAL_IMAGE ."
}
command:update-script() {
if cmp -s <( $OCI_EXE run --rm $FINAL_IMAGE ) $0; then
echo "$0 is up to date"
else
echo -n "Updating $0 ... "
$OCI_EXE run --rm $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-script() {
echo "Update $0 from $FINAL_IMAGE ."
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo "Pull the latest $FINAL_IMAGE, and then update $0 from that."
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
shift
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# Bash on Ubuntu on Windows
UBUNTU_ON_WINDOWS=$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
# MSYS, Git Bash, etc.
MSYS=$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
# CYGWIN
CYGWIN=$([ -e /proc/version ] && grep -l CYGWIN /proc/version || echo "")
if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" -a "$OCI_EXE" != "podman" ]; then
USER_IDS=(-e BUILDER_UID="$( id -u )" -e BUILDER_GID="$( id -g )" -e BUILDER_USER="$( id -un )" -e BUILDER_GROUP="$( id -gn )")
fi
# Change the PWD when working in Docker on Windows
if [ -n "$UBUNTU_ON_WINDOWS" ]; then
WSL_ROOT="/mnt/"
CFG_FILE=/etc/wsl.conf
if [ -f "$CFG_FILE" ]; then
CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
eval "$CFG_CONTENT"
if [ -n "$root" ]; then
WSL_ROOT=$root
fi
fi
HOST_PWD=`pwd -P`
HOST_PWD=${HOST_PWD/$WSL_ROOT//}
elif [ -n "$MSYS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\//}
HOST_PWD=${HOST_PWD/\//:\/}
elif [ -n "$CYGWIN" ]; then
for f in pwd readlink cygpath ; do
test -n "$(type "${f}" )" || { echo >&2 "Missing functionality (${f}) (in cygwin)." ; exit 1 ; } ;
done ;
HOST_PWD="$( cygpath -w "$( readlink -f "$( pwd ;)" ; )" ; )" ;
else
HOST_PWD=$PWD
[ -L $HOST_PWD ] && HOST_PWD=$(readlink $HOST_PWD)
fi
# Mount Additional Volumes
if [ -z "$SSH_DIR" ]; then
SSH_DIR="$HOME/.ssh"
fi
HOST_VOLUMES=
if [ -e "$SSH_DIR" -a -z "$MSYS" ]; then
if test -n "${CYGWIN}" ; then
HOST_VOLUMES+="-v $(cygpath -w ${SSH_DIR} ; ):/home/$(id -un)/.ssh" ;
else
HOST_VOLUMES+="-v $SSH_DIR:/home/$(id -un)/.ssh" ;
fi ;
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
TTY_ARGS=
tty -s && [ -z "$MSYS" ] && TTY_ARGS=-ti
CONTAINER_NAME=dockcross_$RANDOM
$OCI_EXE run $TTY_ARGS --name $CONTAINER_NAME \
-v "$HOST_PWD":/work \
$HOST_VOLUMES \
"${USER_IDS[@]}" \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
run_exit_code=$?
# Attempt to delete container
rm_output=$($OCI_EXE rm -f $CONTAINER_NAME 2>&1)
rm_exit_code=$?
if [[ $rm_exit_code != 0 ]]; then
if [[ "$CIRCLECI" == "true" ]] && [[ $rm_output == *"Driver btrfs failed to remove"* ]]; then
: # Ignore error because of https://circleci.com/docs/docker-btrfs-error/
else
echo "$rm_output"
exit $rm_exit_code
fi
fi
exit $run_exit_code
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7-lts:20230421-a0eaff4 image, run:
#
# docker run --rm dockcross/linux-armv7-lts:20230421-a0eaff4 > dockcross-linux-armv7-lts-20230421-a0eaff4
# chmod +x dockcross-linux-armv7-lts-20230421-a0eaff4
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-ppc64 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=xerial/linux-ppc64
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-ppc64le Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-ppc64le-lts
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-riscv64 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-riscv64
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

199
docker/dockcross-s390x Executable file
View File

@ -0,0 +1,199 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-s390x:20210210-84c47e5
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

199
docker/dockcross-windows-arm64 Executable file
View File

@ -0,0 +1,199 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/windows-arm64
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-windows-x64 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/windows-x64
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

200
docker/dockcross-windows-x86 Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/windows-x86
#------------------------------------------------------------------------------
# Helpers
#
err() {
echo -e >&2 ERROR: $@\\n
}
die() {
err $@
exit 1
}
has() {
# eg. has command update
local kind=$1
local name=$2
type -t $kind:$name | grep -q function
}
#------------------------------------------------------------------------------
# Command handlers
#
command:update-image() {
docker pull $FINAL_IMAGE
}
help:update-image() {
echo Pull the latest $FINAL_IMAGE .
}
command:update-script() {
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
echo $0 is up to date
else
echo -n Updating $0 '... '
docker run $FINAL_IMAGE > $0 && echo ok
fi
}
help:update-image() {
echo Update $0 from $FINAL_IMAGE .
}
command:update() {
command:update-image
command:update-script
}
help:update() {
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
}
command:help() {
if [[ $# != 0 ]]; then
if ! has command $1; then
err \"$1\" is not an dockcross command
command:help
elif ! has help $1; then
err No help found for \"$1\"
else
help:$1
fi
else
cat >&2 <<ENDHELP
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
ENDHELP
exit 1
fi
}
#------------------------------------------------------------------------------
# Option processing
#
special_update_command=''
while [[ $# != 0 ]]; do
case $1 in
--)
break
;;
--args|-a)
ARG_ARGS="$2"
shift 2
;;
--config|-c)
ARG_CONFIG="$2"
shift 2
;;
--image|-i)
ARG_IMAGE="$2"
shift 2
;;
update|update-image|update-script)
special_update_command=$1
break
;;
-*)
err Unknown option \"$1\"
command:help
exit
;;
*)
break
;;
esac
done
# The precedence for options is:
# 1. command-line arguments
# 2. environment variables
# 3. defaults
# Source the config file if it exists
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
# Set the docker image
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
# Handle special update command
if [ "$special_update_command" != "" ]; then
case $special_update_command in
update)
command:update
exit $?
;;
update-image)
command:update-image
exit $?
;;
update-script)
command:update-script
exit $?
;;
esac
fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
docker run --rm \
-v $PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"
################################################################################
#
# This image is not intended to be run manually.
#
# To create a dockcross helper script for the
# dockcross/linux-armv7 image, run:
#
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
# chmod +x dockcross-linux-armv7
#
# You may then wish to move the dockcross script to your PATH.
#
################################################################################

View File

@ -1,248 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2006, 2007 Google Inc. All Rights Reserved.
# Author: danderson@google.com (David Anderson)
#
# Script for uploading files to a Google Code project.
#
# This is intended to be both a useful script for people who want to
# streamline project uploads and a reference implementation for
# uploading files to Google Code projects.
#
# To upload a file to Google Code, you need to provide a path to the
# file on your local machine, a small summary of what the file is, a
# project name, and a valid account that is a member or owner of that
# project. You can optionally provide a list of labels that apply to
# the file. The file will be uploaded under the same name that it has
# in your local filesystem (that is, the "basename" or last path
# component). Run the script with '--help' to get the exact syntax
# and available options.
#
# Note that the upload script requests that you enter your
# googlecode.com password. This is NOT your Gmail account password!
# This is the password you use on googlecode.com for committing to
# Subversion and uploading files. You can find your password by going
# to http://code.google.com/hosting/settings when logged in with your
# Gmail account. If you have already committed to your project's
# Subversion repository, the script will automatically retrieve your
# credentials from there (unless disabled, see the output of '--help'
# for details).
#
# If you are looking at this script as a reference for implementing
# your own Google Code file uploader, then you should take a look at
# the upload() function, which is the meat of the uploader. You
# basically need to build a multipart/form-data POST request with the
# right fields and send it to https://PROJECT.googlecode.com/files .
# Authenticate the request using HTTP Basic authentication, as is
# shown below.
#
# Licensed under the terms of the Apache Software License 2.0:
# http://www.apache.org/licenses/LICENSE-2.0
#
# Questions, comments, feature requests and patches are most welcome.
# Please direct all of these to the Google Code users group:
# http://groups.google.com/group/google-code-hosting
"""Google Code file uploader script.
"""
__author__ = 'danderson@google.com (David Anderson)'
import httplib
import os.path
import optparse
import getpass
import base64
import sys
def upload(file, project_name, user_name, password, summary, labels=None):
"""Upload a file to a Google Code project's file server.
Args:
file: The local path to the file.
project_name: The name of your project on Google Code.
user_name: Your Google account name.
password: The googlecode.com password for your account.
Note that this is NOT your global Google Account password!
summary: A small description for the file.
labels: an optional list of label strings with which to tag the file.
Returns: a tuple:
http_status: 201 if the upload succeeded, something else if an
error occured.
http_reason: The human-readable string associated with http_status
file_url: If the upload succeeded, the URL of the file on Google
Code, None otherwise.
"""
# The login is the user part of user@gmail.com. If the login provided
# is in the full user@domain form, strip it down.
if user_name.endswith('@gmail.com'):
user_name = user_name[:user_name.index('@gmail.com')]
form_fields = [('summary', summary)]
if labels is not None:
form_fields.extend([('label', l.strip()) for l in labels])
content_type, body = encode_upload_request(form_fields, file)
upload_host = '%s.googlecode.com' % project_name
upload_uri = '/files'
auth_token = base64.b64encode('%s:%s'% (user_name, password))
headers = {
'Authorization': 'Basic %s' % auth_token,
'User-Agent': 'Googlecode.com uploader v0.9.4',
'Content-Type': content_type,
}
server = httplib.HTTPSConnection(upload_host)
server.request('POST', upload_uri, body, headers)
resp = server.getresponse()
server.close()
if resp.status == 201:
location = resp.getheader('Location', None)
else:
location = None
return resp.status, resp.reason, location
def encode_upload_request(fields, file_path):
"""Encode the given fields and file into a multipart form body.
fields is a sequence of (name, value) pairs. file is the path of
the file to upload. The file will be uploaded to Google Code with
the same file name.
Returns: (content_type, body) ready for httplib.HTTP instance
"""
BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla'
CRLF = '\r\n'
body = []
# Add the metadata about the upload first
for key, value in fields:
body.extend(
['--' + BOUNDARY,
'Content-Disposition: form-data; name="%s"' % key,
'',
value,
])
# Now add the file itself
file_name = os.path.basename(file_path)
f = open(file_path, 'rb')
file_content = f.read()
f.close()
body.extend(
['--' + BOUNDARY,
'Content-Disposition: form-data; name="filename"; filename="%s"'
% file_name,
# The upload server determines the mime-type, no need to set it.
'Content-Type: application/octet-stream',
'',
file_content,
])
# Finalize the form body
body.extend(['--' + BOUNDARY + '--', ''])
return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body)
def upload_find_auth(file_path, project_name, summary, labels=None,
user_name=None, password=None, tries=3):
"""Find credentials and upload a file to a Google Code project's file server.
file_path, project_name, summary, and labels are passed as-is to upload.
Args:
file_path: The local path to the file.
project_name: The name of your project on Google Code.
summary: A small description for the file.
labels: an optional list of label strings with which to tag the file.
config_dir: Path to Subversion configuration directory, 'none', or None.
user_name: Your Google account name.
tries: How many attempts to make.
"""
while tries > 0:
if user_name is None:
# Read username if not specified or loaded from svn config, or on
# subsequent tries.
sys.stdout.write('Please enter your googlecode.com username: ')
sys.stdout.flush()
user_name = sys.stdin.readline().rstrip()
if password is None:
# Read password if not loaded from svn config, or on subsequent tries.
print 'Please enter your googlecode.com password.'
print '** Note that this is NOT your Gmail account password! **'
print 'It is the password you use to access Subversion repositories,'
print 'and can be found here: http://code.google.com/hosting/settings'
password = getpass.getpass()
status, reason, url = upload(file_path, project_name, user_name, password,
summary, labels)
# Returns 403 Forbidden instead of 401 Unauthorized for bad
# credentials as of 2007-07-17.
if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]:
# Rest for another try.
user_name = password = None
tries = tries - 1
else:
# We're done.
break
return status, reason, url
def main():
parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY '
'-p PROJECT [options] FILE')
parser.add_option('-s', '--summary', dest='summary',
help='Short description of the file')
parser.add_option('-p', '--project', dest='project',
help='Google Code project name')
parser.add_option('-u', '--user', dest='user',
help='Your Google Code username')
parser.add_option('-w', '--password', dest='password',
help='Your Google Code password')
parser.add_option('-l', '--labels', dest='labels',
help='An optional list of comma-separated labels to attach '
'to the file')
options, args = parser.parse_args()
if not options.summary:
parser.error('File summary is missing.')
elif not options.project:
parser.error('Project name is missing.')
elif len(args) < 1:
parser.error('File to upload not provided.')
elif len(args) > 1:
parser.error('Only one file may be specified.')
file_path = args[0]
if options.labels:
labels = options.labels.split(',')
else:
labels = None
status, reason, url = upload_find_auth(file_path, options.project,
options.summary, labels,
options.user, options.password)
if url:
print 'The file was uploaded successfully.'
print 'URL: %s' % url
return 0
else:
print 'An error occurred. Your file was not uploaded.'
print 'Google Code upload server said: %s (%s)' % (reason, status)
return 1
if __name__ == '__main__':
sys.exit(main())

62
lib/inc_linux/config.h Normal file
View File

@ -0,0 +1,62 @@
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
/* Define to 1 if the compiler supports __builtin_ctz and friends. */
#define HAVE_BUILTIN_CTZ 1
/* Define to 1 if the compiler supports __builtin_expect. */
#define HAVE_BUILTIN_EXPECT 1
/* Define to 1 if you have the <byteswap.h> header file. */
/* #undef HAVE_BYTESWAP_H */
/* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */
#define HAVE_FUNC_MMAP 1
/* Define to 1 if you have a definition for sysconf() in <unistd.h>. */
#define HAVE_FUNC_SYSCONF 1
/* Define to 1 to use the gflags package for command-line parsing. */
/* #undef HAVE_GFLAGS */
/* Define to 1 if you have Google Test. */
/* #undef HAVE_GTEST */
/* Define to 1 if you have the `lzo2' library (-llzo2). */
/* #undef HAVE_LIBLZO2 */
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef SNAPPY_IS_BIG_ENDIAN */
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_

View File

@ -1,26 +1,26 @@
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@ -1951,9 +1951,10 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
#define JNI_VERSION_1_6 0x00010006
#define JNI_VERSION_1_8 0x00010008
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* !_JAVASOFT_JNI_H_ */
#endif /* !_JAVASOFT_JNI_H_ */

View File

@ -0,0 +1,94 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: sesse@google.com (Steinar H. Gunderson)
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Various type stubs for the open-source version of Snappy.
//
// This file cannot include config.h, as it is included from snappy.h,
// which is a public header. Instead, snappy-stubs-public.h is generated by
// from snappy-stubs-public.h.in at configure time.
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#if 1 // HAVE_STDINT_H
#include <stdint.h>
#endif // HAVE_STDDEF_H
#if 1 // HAVE_STDDEF_H
#include <stddef.h>
#endif // HAVE_STDDEF_H
#if 1 // HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif // HAVE_SYS_UIO_H
#define SNAPPY_MAJOR
#define SNAPPY_MINOR
#define SNAPPY_PATCHLEVEL
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
#include <string>
namespace snappy {
#if 1 // HAVE_STDINT_H
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#else
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
#endif // HAVE_STDINT_H
typedef std::string string;
#if !1 // !HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
void* iov_base;
size_t iov_len;
};
#endif // !HAVE_SYS_UIO_H
} // namespace snappy
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_

View File

@ -1,5 +0,0 @@
#ifndef __CONFIG_H
#define __CONFIG_H
#endif // __CONFIG_H

Binary file not shown.

View File

@ -1,2 +1,2 @@
sbt.version=0.13.6
sbt.version=1.10.7

View File

@ -1,12 +1,5 @@
addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
addSbtPlugin("com.github.sbt" % "sbt-osgi" % "0.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.4")
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.0")

739
sbt
View File

@ -1,87 +1,107 @@
#!/usr/bin/env bash
#
# A more capable sbt runner, coincidentally also called sbt.
# Author: Paul Phillips <paulp@typesafe.com>
# Author: Paul Phillips <paulp@improving.org>
# https://github.com/paulp/sbt-extras
#
# Generated from http://www.opensource.org/licenses/bsd-license.php
# Copyright (c) 2011, Paul Phillips. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -o pipefail
declare -r sbt_release_version="1.9.6"
declare -r sbt_unreleased_version="1.9.6"
declare -r latest_213="2.13.12"
declare -r latest_212="2.12.18"
declare -r latest_211="2.11.12"
declare -r latest_210="2.10.7"
declare -r latest_29="2.9.3"
declare -r latest_28="2.8.2"
# todo - make this dynamic
declare -r sbt_release_version="0.13.1"
declare -r sbt_unreleased_version="0.13.2-SNAPSHOT" # -sbt-dev doesn't work at present
declare -r buildProps="project/build.properties"
declare sbt_jar sbt_dir sbt_create sbt_launch_dir
declare scala_version java_home sbt_explicit_version
declare verbose debug quiet noshare batch trace_level log_level
declare sbt_saved_stty
declare -r sbt_launch_ivy_release_repo="https://repo.typesafe.com/typesafe/ivy-releases"
declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy-snapshots"
declare -r sbt_launch_mvn_release_repo="https://repo1.maven.org/maven2"
declare -r sbt_launch_mvn_snapshot_repo="https://repo.scala-sbt.org/scalasbt/maven-snapshots"
echoerr () { [[ -z "$quiet" ]] && echo "$@" >&2; }
vlog () { [[ -n "$verbose$debug" ]] && echoerr "$@"; }
dlog () { [[ -n "$debug" ]] && echoerr "$@"; }
declare -r default_jvm_opts_common="-Xms512m -Xss2m -XX:MaxInlineLevel=18"
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy -Dsbt.coursier.home=project/.coursier"
# we'd like these set before we get around to properly processing arguments
for arg in "$@"; do
case "$arg" in
-q|-quiet) quiet=true ;;
-d|-debug) debug=true ;;
-v|-verbose) verbose=true ;;
*) ;;
esac
done
declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new
declare sbt_explicit_version
declare verbose noshare batch trace_level
# spaces are possible, e.g. sbt.version = 0.13.0
build_props_sbt () {
[[ -r "$buildProps" ]] && \
grep '^sbt\.version' "$buildProps" | tr '=' ' ' | awk '{ print $2; }'
declare java_cmd="java"
declare sbt_launch_dir="$HOME/.sbt/launchers"
declare sbt_launch_repo
# pull -J and -D options to give to java.
declare -a java_args scalac_args sbt_commands residual_args
# args to jvm/sbt via files or environment variables
declare -a extra_jvm_opts extra_sbt_opts
echoerr() { echo >&2 "$@"; }
vlog() { [[ -n "$verbose" ]] && echoerr "$@"; }
die() {
echo "Aborting: $*"
exit 1
}
update_build_props_sbt () {
local ver="$1"
local old="$(build_props_sbt)"
setTrapExit() {
# save stty and trap exit, to ensure echo is re-enabled if we are interrupted.
SBT_STTY="$(stty -g 2>/dev/null)"
export SBT_STTY
[[ -r "$buildProps" ]] && [[ "$ver" != "$old" ]] && {
perl -pi -e "s/^sbt\.version\b.*\$/sbt.version=${ver}/" "$buildProps"
grep -q '^sbt.version[ =]' "$buildProps" || printf "\nsbt.version=%s\n" "$ver" >> "$buildProps"
echoerr "!!!"
echoerr "!!! Updated file $buildProps setting sbt.version to: $ver"
echoerr "!!! Previous value was: $old"
echoerr "!!!"
# restore stty settings (echo in particular)
onSbtRunnerExit() {
[ -t 0 ] || return
vlog ""
vlog "restoring stty: $SBT_STTY"
stty "$SBT_STTY"
}
}
sbt_version () {
if [[ -n "$sbt_explicit_version" ]]; then
echo "$sbt_explicit_version"
else
local v="$(build_props_sbt)"
if [[ -n "$v" ]]; then
echo "$v"
else
echo "$sbt_release_version"
fi
fi
vlog "saving stty: $SBT_STTY"
trap onSbtRunnerExit EXIT
}
# restore stty settings (echo in particular)
onSbtRunnerExit() {
[[ -n "$sbt_saved_stty" ]] || return
dlog ""
dlog "restoring stty: $sbt_saved_stty"
stty "$sbt_saved_stty"
unset sbt_saved_stty
}
# save stty and trap exit, to ensure echo is reenabled if we are interrupted.
trap onSbtRunnerExit EXIT
sbt_saved_stty="$(stty -g 2>/dev/null)"
dlog "Saved stty: $sbt_saved_stty"
# this seems to cover the bases on OSX, and someone will
# have to tell me about the others.
get_script_path () {
get_script_path() {
local path="$1"
[[ -L "$path" ]] || { echo "$path" ; return; }
[[ -L "$path" ]] || {
echo "$path"
return
}
local target="$(readlink "$path")"
local -r target="$(readlink "$path")"
if [[ "${target:0:1}" == "/" ]]; then
echo "$target"
else
@ -89,23 +109,12 @@ get_script_path () {
fi
}
die() {
echo "Aborting: $@"
exit 1
}
script_path="$(get_script_path "${BASH_SOURCE[0]}")"
declare -r script_path
script_name="${script_path##*/}"
declare -r script_name
make_url () {
version="$1"
case "$version" in
0.7.*) echo "http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.7.jar" ;;
0.10.* ) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
0.11.[12]) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
*) echo "$sbt_launch_repo/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
esac
}
init_default_option_file () {
init_default_option_file() {
local overriding_var="${!1}"
local default_file="$2"
if [[ ! -r "$default_file" && "$overriding_var" =~ ^@(.*)$ ]]; then
@ -117,112 +126,280 @@ init_default_option_file () {
echo "$default_file"
}
declare -r cms_opts="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
declare -r jit_opts="-XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation"
declare -r default_jvm_opts="-Dfile.encoding=UTF8 -XX:MaxPermSize=384m -Xms512m -Xmx1536m -Xss2m $jit_opts $cms_opts"
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
declare -r latest_28="2.8.2"
declare -r latest_29="2.9.3"
declare -r latest_210="2.10.3"
declare -r latest_211="2.11.0-M5"
sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
sbtx_opts_file="$(init_default_option_file SBTX_OPTS .sbtxopts)"
jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
declare -r script_path="$(get_script_path "$BASH_SOURCE")"
declare -r script_name="${script_path##*/}"
build_props_sbt() {
[[ -r "$buildProps" ]] &&
grep '^sbt\.version' "$buildProps" | tr '=\r' ' ' | awk '{ print $2; }'
}
# some non-read-onlies set with defaults
declare java_cmd="java"
declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
declare sbt_launch_repo="http://typesafe.artifactoryonline.com/typesafe/ivy-releases"
set_sbt_version() {
sbt_version="${sbt_explicit_version:-$(build_props_sbt)}"
[[ -n "$sbt_version" ]] || sbt_version=$sbt_release_version
export sbt_version
}
# pull -J and -D options to give to java.
declare -a residual_args
declare -a java_args
declare -a scalac_args
declare -a sbt_commands
url_base() {
local version="$1"
# args to jvm/sbt via files or environment variables
declare -a extra_jvm_opts extra_sbt_opts
case "$version" in
0.7.*) echo "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/simple-build-tool" ;;
0.10.*) echo "$sbt_launch_ivy_release_repo" ;;
0.11.[12]) echo "$sbt_launch_ivy_release_repo" ;;
0.*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmdd-hhMMss"
echo "$sbt_launch_ivy_snapshot_repo" ;;
0.*) echo "$sbt_launch_ivy_release_repo" ;;
*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmddThhMMss"
echo "$sbt_launch_mvn_snapshot_repo" ;;
*) echo "$sbt_launch_mvn_release_repo" ;;
esac
}
# if set, use JAVA_HOME over java found in path
[[ -e "$JAVA_HOME/bin/java" ]] && java_cmd="$JAVA_HOME/bin/java"
make_url() {
local version="$1"
# directory to store sbt launchers
declare sbt_launch_dir="$HOME/.sbt/launchers"
[[ -d "$sbt_launch_dir" ]] || mkdir -p "$sbt_launch_dir"
[[ -w "$sbt_launch_dir" ]] || sbt_launch_dir="$(mktemp -d -t sbt_extras_launchers.XXXXXX)"
local base="${sbt_launch_repo:-$(url_base "$version")}"
build_props_scala () {
if [[ -r "$buildProps" ]]; then
versionLine="$(grep '^build.scala.versions' "$buildProps")"
versionString="${versionLine##build.scala.versions=}"
echo "${versionString%% .*}"
case "$version" in
0.7.*) echo "$base/sbt-launch-0.7.7.jar" ;;
0.10.*) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
0.11.[12]) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
0.*) echo "$base/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
*) echo "$base/org/scala-sbt/sbt-launch/$version/sbt-launch-${version}.jar" ;;
esac
}
addJava() {
vlog "[addJava] arg = '$1'"
java_args+=("$1")
}
addSbt() {
vlog "[addSbt] arg = '$1'"
sbt_commands+=("$1")
}
addScalac() {
vlog "[addScalac] arg = '$1'"
scalac_args+=("$1")
}
addResidual() {
vlog "[residual] arg = '$1'"
residual_args+=("$1")
}
addResolver() { addSbt "set resolvers += $1"; }
addDebugger() { addJava "-Xdebug" && addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"; }
setThisBuild() {
vlog "[addBuild] args = '$*'"
local key="$1" && shift
addSbt "set $key in ThisBuild := $*"
}
setScalaVersion() {
[[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")'
addSbt "++ $1"
}
setJavaHome() {
java_cmd="$1/bin/java"
setThisBuild javaHome "_root_.scala.Some(file(\"$1\"))"
export JAVA_HOME="$1"
export JDK_HOME="$1"
export PATH="$JAVA_HOME/bin:$PATH"
}
getJavaVersion() {
local -r str=$("$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d '"')
# java -version on java8 says 1.8.x
# but on 9 and 10 it's 9.x.y and 10.x.y.
if [[ "$str" =~ ^1\.([0-9]+)(\..*)?$ ]]; then
echo "${BASH_REMATCH[1]}"
# Fixes https://github.com/dwijnand/sbt-extras/issues/326
elif [[ "$str" =~ ^([0-9]+)(\..*)?(-ea)?$ ]]; then
echo "${BASH_REMATCH[1]}"
elif [[ -n "$str" ]]; then
echoerr "Can't parse java version from: $str"
fi
}
execRunner () {
checkJava() {
# Warn if there is a Java version mismatch between PATH and JAVA_HOME/JDK_HOME
[[ -n "$JAVA_HOME" && -e "$JAVA_HOME/bin/java" ]] && java="$JAVA_HOME/bin/java"
[[ -n "$JDK_HOME" && -e "$JDK_HOME/lib/tools.jar" ]] && java="$JDK_HOME/bin/java"
if [[ -n "$java" ]]; then
pathJavaVersion=$(getJavaVersion java)
homeJavaVersion=$(getJavaVersion "$java")
if [[ "$pathJavaVersion" != "$homeJavaVersion" ]]; then
echoerr "Warning: Java version mismatch between PATH and JAVA_HOME/JDK_HOME, sbt will use the one in PATH"
echoerr " Either: fix your PATH, remove JAVA_HOME/JDK_HOME or use -java-home"
echoerr " java version from PATH: $pathJavaVersion"
echoerr " java version from JAVA_HOME/JDK_HOME: $homeJavaVersion"
fi
fi
}
java_version() {
local -r version=$(getJavaVersion "$java_cmd")
vlog "Detected Java version: $version"
echo "$version"
}
is_apple_silicon() { [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]; }
# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+
default_jvm_opts() {
local -r v="$(java_version)"
if [[ $v -ge 17 ]]; then
echo "$default_jvm_opts_common"
elif [[ $v -ge 10 ]]; then
if is_apple_silicon; then
# As of Dec 2020, JVM for Apple Silicon (M1) doesn't support JVMCI
echo "$default_jvm_opts_common"
else
echo "$default_jvm_opts_common -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler"
fi
elif [[ $v -ge 8 ]]; then
echo "$default_jvm_opts_common"
else
echo "-XX:MaxPermSize=384m $default_jvm_opts_common"
fi
}
execRunner() {
# print the arguments one to a line, quoting any containing spaces
[[ "$verbose" || "$debug" ]] && echo "# Executing command line:" && {
vlog "# Executing command line:" && {
for arg; do
if [[ -n "$arg" ]]; then
if printf "%s\n" "$arg" | grep -q ' '; then
printf "\"%s\"\n" "$arg"
printf >&2 "\"%s\"\n" "$arg"
else
printf "%s\n" "$arg"
printf >&2 "%s\n" "$arg"
fi
fi
done
echo ""
vlog ""
}
setTrapExit
if [[ -n "$batch" ]]; then
exec </dev/null
"$@" </dev/null
else
"$@"
fi
exec "$@"
}
jar_url () {
make_url "$1"
jar_url() { make_url "$1"; }
is_cygwin() { [[ "$(uname -a)" == "CYGWIN"* ]]; }
jar_file() {
is_cygwin &&
cygpath -w "$sbt_launch_dir/$1/sbt-launch.jar" ||
echo "$sbt_launch_dir/$1/sbt-launch.jar"
}
jar_file () {
echo "$sbt_launch_dir/$1/sbt-launch.jar"
}
download_url () {
download_url() {
local url="$1"
local jar="$2"
echo "Downloading sbt launcher for $(sbt_version):"
echo " From $url"
echo " To $jar"
mkdir -p "${jar%/*}" && {
if which curl >/dev/null; then
curl --fail --silent "$url" --output "$jar"
elif which wget >/dev/null; then
wget --quiet -O "$jar" "$url"
if command -v curl >/dev/null 2>&1; then
curl --fail --silent --location "$url" --output "$jar"
elif command -v wget >/dev/null 2>&1; then
wget -q -O "$jar" "$url"
fi
} && [[ -r "$jar" ]]
}
acquire_sbt_jar () {
for_sbt_version="$(sbt_version)"
sbt_url="$(jar_url "$for_sbt_version")"
sbt_jar="$(jar_file "$for_sbt_version")"
acquire_sbt_jar() {
{
sbt_jar="$(jar_file "$sbt_version")"
[[ -r "$sbt_jar" ]]
} || {
sbt_jar="$HOME/.ivy2/local/org.scala-sbt/sbt-launch/$sbt_version/jars/sbt-launch.jar"
[[ -r "$sbt_jar" ]]
} || {
sbt_jar="$(jar_file "$sbt_version")"
jar_url="$(make_url "$sbt_version")"
[[ -r "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar"
echoerr "Downloading sbt launcher for ${sbt_version}:"
echoerr " From ${jar_url}"
echoerr " To ${sbt_jar}"
download_url "${jar_url}" "${sbt_jar}"
case "${sbt_version}" in
0.*)
vlog "SBT versions < 1.0 do not have published MD5 checksums, skipping check"
echo ""
;;
*) verify_sbt_jar "${sbt_jar}" ;;
esac
}
}
usage () {
verify_sbt_jar() {
local jar="${1}"
local md5="${jar}.md5"
md5url="$(make_url "${sbt_version}").md5"
echoerr "Downloading sbt launcher ${sbt_version} md5 hash:"
echoerr " From ${md5url}"
echoerr " To ${md5}"
download_url "${md5url}" "${md5}" >/dev/null 2>&1
if command -v md5sum >/dev/null 2>&1; then
if echo "$(cat "${md5}") ${jar}" | md5sum -c -; then
rm -rf "${md5}"
return 0
else
echoerr "Checksum does not match"
return 1
fi
elif command -v md5 >/dev/null 2>&1; then
if [ "$(md5 -q "${jar}")" == "$(cat "${md5}")" ]; then
rm -rf "${md5}"
return 0
else
echoerr "Checksum does not match"
return 1
fi
elif command -v openssl >/dev/null 2>&1; then
if [ "$(openssl md5 -r "${jar}" | awk '{print $1}')" == "$(cat "${md5}")" ]; then
rm -rf "${md5}"
return 0
else
echoerr "Checksum does not match"
return 1
fi
else
echoerr "Could not find an MD5 command"
return 1
fi
}
usage() {
set_sbt_version
cat <<EOM
Usage: $script_name [options]
Note that options which are passed along to sbt begin with -- whereas
options to this runner use a single dash. Any sbt command can be scheduled
to run first by prefixing the command with --, so --warn, --error and so on
are not special.
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to Debug
-q | -quiet set sbt log level to Error
-v verbose operation (this runner is chattier)
-d, -w, -q aliases for --debug, --warn, --error (q means quiet)
-x debug this script
-trace <level> display stack traces with a max of <level> frames (default: -1, traces suppressed)
-debug-inc enable debugging log for the incremental compiler
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt/<version>)
@ -233,77 +410,58 @@ Usage: $script_name [options]
-jvm-debug <port> Turn on JVM debugging, open at the given port.
-batch Disable interactive mode
-prompt <expr> Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted
-script <file> Run the specified file as a scala script
# sbt version (default: from $buildProps if present, else latest release)
!!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which
!!! contains an sbt.version property is to update the file on disk. That's what this does.
-sbt-version <version> use the specified version of sbt (default: $sbt_release_version)
-sbt-jar <path> use the specified jar as the sbt launcher
-sbt-launch-dir <path> directory to hold sbt launchers (default: $sbt_launch_dir)
-sbt-launch-repo <url> repo url for downloading sbt launcher jar (default: $sbt_launch_repo)
# sbt version (default: sbt.version from $buildProps if present, otherwise $sbt_release_version)
-sbt-version <version> use the specified version of sbt (default: $sbt_release_version)
-sbt-force-latest force the use of the latest release of sbt: $sbt_release_version
-sbt-dev use the latest pre-release version of sbt: $sbt_unreleased_version
-sbt-jar <path> use the specified jar as the sbt launcher
-sbt-launch-dir <path> directory to hold sbt launchers (default: $sbt_launch_dir)
-sbt-launch-repo <url> repo url for downloading sbt launcher jar (default: $(url_base "$sbt_version"))
# scala version (default: as chosen by sbt)
-28 use $latest_28
-29 use $latest_29
-210 use $latest_210
-211 use $latest_211
-scala-home <path> use the scala build at the specified directory
-scala-version <version> use the specified version of scala
-binary-version <version> use the specified scala version when searching for dependencies
-28 use $latest_28
-29 use $latest_29
-210 use $latest_210
-211 use $latest_211
-212 use $latest_212
-213 use $latest_213
-scala-home <path> use the scala build at the specified directory
-scala-version <version> use the specified version of scala
-binary-version <version> use the specified scala version when searching for dependencies
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
-java-home <path> alternate JAVA_HOME
-java-home <path> alternate JAVA_HOME
# passing options to the jvm - note it does NOT use JAVA_OPTS due to pollution
# The default set is used if JVM_OPTS is unset and no -jvm-opts file is found
<default> $default_jvm_opts
JVM_OPTS environment variable holding either the jvm args directly, or
the reference to a file containing jvm args if given path is prepended by '@' (e.g. '@/etc/jvmopts')
Note: "@"-file is overridden by local '.jvmopts' or '-jvm-opts' argument.
-jvm-opts <path> file containing jvm args (if not given, .jvmopts in project root is used if present)
-Dkey=val pass -Dkey=val directly to the jvm
-J-X pass option -X directly to the jvm (-J is stripped)
<default> $(default_jvm_opts)
JVM_OPTS environment variable holding either the jvm args directly, or
the reference to a file containing jvm args if given path is prepended by '@' (e.g. '@/etc/jvmopts')
Note: "@"-file is overridden by local '.jvmopts' or '-jvm-opts' argument.
-jvm-opts <path> file containing jvm args (if not given, .jvmopts in project root is used if present)
-Dkey=val pass -Dkey=val directly to the jvm
-J-X pass option -X directly to the jvm (-J is stripped)
# passing options to sbt, OR to this runner
SBT_OPTS environment variable holding either the sbt args directly, or
the reference to a file containing sbt args if given path is prepended by '@' (e.g. '@/etc/sbtopts')
Note: "@"-file is overridden by local '.sbtopts' or '-sbt-opts' argument.
-sbt-opts <path> file containing sbt args (if not given, .sbtopts in project root is used if present)
-S-X add -X to sbt's scalacOptions (-S is stripped)
SBT_OPTS environment variable holding either the sbt args directly, or
the reference to a file containing sbt args if given path is prepended by '@' (e.g. '@/etc/sbtopts')
Note: "@"-file is overridden by local '.sbtopts' or '-sbt-opts' argument.
-sbt-opts <path> file containing sbt args (if not given, .sbtopts in project root is used if present)
-S-X add -X to sbt's scalacOptions (-S is stripped)
# passing options exclusively to this runner
SBTX_OPTS environment variable holding either the sbt-extras args directly, or
the reference to a file containing sbt-extras args if given path is prepended by '@' (e.g. '@/etc/sbtxopts')
Note: "@"-file is overridden by local '.sbtxopts' or '-sbtx-opts' argument.
-sbtx-opts <path> file containing sbt-extras args (if not given, .sbtxopts in project root is used if present)
EOM
exit 0
}
addJava () {
dlog "[addJava] arg = '$1'"
java_args=( "${java_args[@]}" "$1" )
}
addSbt () {
dlog "[addSbt] arg = '$1'"
sbt_commands=( "${sbt_commands[@]}" "$1" )
}
addScalac () {
dlog "[addScalac] arg = '$1'"
scalac_args=( "${scalac_args[@]}" "$1" )
}
addResidual () {
dlog "[residual] arg = '$1'"
residual_args=( "${residual_args[@]}" "$1" )
}
addResolver () {
addSbt "set resolvers += $1"
}
addDebugger () {
addJava "-Xdebug"
addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
}
setScalaVersion () {
[[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")'
addSbt "++ $1"
}
process_args ()
{
require_arg () {
process_args() {
require_arg() {
local type="$1"
local opt="$2"
local arg="$3"
@ -314,45 +472,56 @@ process_args ()
}
while [[ $# -gt 0 ]]; do
case "$1" in
-h|-help) usage; exit 1 ;;
-v|-verbose) verbose=true && log_level=Info && shift ;;
-d|-debug) debug=true && log_level=Debug && shift ;;
-q|-quiet) quiet=true && log_level=Error && shift ;;
-h | -help) usage ;;
-v) verbose=true && shift ;;
-d) addSbt "--debug" && shift ;;
-w) addSbt "--warn" && shift ;;
-q) addSbt "--error" && shift ;;
-x) shift ;; # currently unused
-trace) require_arg integer "$1" "$2" && trace_level="$2" && shift 2 ;;
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
-trace) require_arg integer "$1" "$2" && trace_level="$2" && shift 2 ;;
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
-no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
-no-share) noshare=true && shift ;;
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
-sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;;
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
-offline) addSbt "set offline := true" && shift ;;
-jvm-debug) require_arg port "$1" "$2" && addDebugger "$2" && shift 2 ;;
-batch) batch=true && shift ;;
-prompt) require_arg "expr" "$1" "$2" && addSbt "set shellPrompt in ThisBuild := (s => { val e = Project.extract(s) ; $2 })" && shift 2 ;;
-no-colors) addJava "-Dsbt.log.noformat=true" && addJava "-Dsbt.color=false" && shift ;;
-sbt-create) sbt_create=true && shift ;;
-sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;;
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
-no-share) noshare=true && shift ;;
-offline) addSbt "set offline in Global := true" && shift ;;
-jvm-debug) require_arg port "$1" "$2" && addDebugger "$2" && shift 2 ;;
-batch) batch=true && shift ;;
-prompt) require_arg "expr" "$1" "$2" && setThisBuild shellPrompt "(s => { val e = Project.extract(s) ; $2 })" && shift 2 ;;
-script) require_arg file "$1" "$2" && sbt_script="$2" && addJava "-Dsbt.main.class=sbt.ScriptMain" && shift 2 ;;
-sbt-create) sbt_create=true && shift ;;
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
-sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;;
-sbt-dev) sbt_explicit_version="$sbt_unreleased_version" && shift ;;
-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;;
-sbt-launch-repo) require_arg path "$1" "$2" && sbt_launch_repo="$2" && shift 2 ;;
-scala-version) require_arg version "$1" "$2" && setScalaVersion "$2" && shift 2 ;;
-binary-version) require_arg version "$1" "$2" && addSbt "set scalaBinaryVersion in ThisBuild := \"$2\"" && shift 2 ;;
-scala-home) require_arg path "$1" "$2" && addSbt "set every scalaHome := Some(file(\"$2\"))" && shift 2 ;;
-java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
-sbt-opts) require_arg path "$1" "$2" && sbt_opts_file="$2" && shift 2 ;;
-jvm-opts) require_arg path "$1" "$2" && jvm_opts_file="$2" && shift 2 ;;
-sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;;
-sbt-force-latest) sbt_explicit_version="$sbt_release_version" && shift ;;
-sbt-dev) sbt_explicit_version="$sbt_unreleased_version" && shift ;;
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;;
-sbt-launch-repo) require_arg path "$1" "$2" && sbt_launch_repo="$2" && shift 2 ;;
-D*) addJava "$1" && shift ;;
-J*) addJava "${1:2}" && shift ;;
-S*) addScalac "${1:2}" && shift ;;
-28) setScalaVersion "$latest_28" && shift ;;
-29) setScalaVersion "$latest_29" && shift ;;
-210) setScalaVersion "$latest_210" && shift ;;
-211) setScalaVersion "$latest_211" && shift ;;
-28) setScalaVersion "$latest_28" && shift ;;
-29) setScalaVersion "$latest_29" && shift ;;
-210) setScalaVersion "$latest_210" && shift ;;
-211) setScalaVersion "$latest_211" && shift ;;
-212) setScalaVersion "$latest_212" && shift ;;
-213) setScalaVersion "$latest_213" && shift ;;
*) addResidual "$1" && shift ;;
-scala-version) require_arg version "$1" "$2" && setScalaVersion "$2" && shift 2 ;;
-binary-version) require_arg version "$1" "$2" && setThisBuild scalaBinaryVersion "\"$2\"" && shift 2 ;;
-scala-home) require_arg path "$1" "$2" && setThisBuild scalaHome "_root_.scala.Some(file(\"$2\"))" && shift 2 ;;
-java-home) require_arg path "$1" "$2" && setJavaHome "$2" && shift 2 ;;
-sbt-opts) require_arg path "$1" "$2" && sbt_opts_file="$2" && shift 2 ;;
-sbtx-opts) require_arg path "$1" "$2" && sbtx_opts_file="$2" && shift 2 ;;
-jvm-opts) require_arg path "$1" "$2" && jvm_opts_file="$2" && shift 2 ;;
-D*) addJava "$1" && shift ;;
-J*) addJava "${1:2}" && shift ;;
-S*) addScalac "${1:2}" && shift ;;
new) sbt_new=true && : ${sbt_explicit_version:=$sbt_release_version} && addResidual "$1" && shift ;;
*) addResidual "$1" && shift ;;
esac
done
}
@ -362,58 +531,74 @@ process_args "$@"
# skip #-styled comments and blank lines
readConfigFile() {
while read line; do
[[ $line =~ ^# ]] || [[ -z $line ]] || echo "$line"
done < "$1"
local end=false
until $end; do
read -r || end=true
[[ $REPLY =~ ^# ]] || [[ -z $REPLY ]] || echo "$REPLY"
done <"$1"
}
# if there are file/environment sbt_opts, process again so we
# can supply args to this runner
if [[ -r "$sbt_opts_file" ]]; then
vlog "Using sbt options defined in file $sbt_opts_file"
while read opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
elif [[ -n "$SBT_OPTS" && ! ("$SBT_OPTS" =~ ^@.*) ]]; then
vlog "Using sbt options defined in variable \$SBT_OPTS"
extra_sbt_opts=( $SBT_OPTS )
IFS=" " read -r -a extra_sbt_opts <<<"$SBT_OPTS"
else
vlog "No extra sbt options have been defined"
fi
[[ -n "$extra_sbt_opts" ]] && process_args "${extra_sbt_opts[@]}"
# if there are file/environment sbtx_opts, process again so we
# can supply args to this runner
if [[ -r "$sbtx_opts_file" ]]; then
vlog "Using sbt options defined in file $sbtx_opts_file"
while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbtx_opts_file")
elif [[ -n "$SBTX_OPTS" && ! ("$SBTX_OPTS" =~ ^@.*) ]]; then
vlog "Using sbt options defined in variable \$SBTX_OPTS"
IFS=" " read -r -a extra_sbt_opts <<<"$SBTX_OPTS"
else
vlog "No extra sbt options have been defined"
fi
[[ -n "${extra_sbt_opts[*]}" ]] && process_args "${extra_sbt_opts[@]}"
# reset "$@" to the residual args
set -- "${residual_args[@]}"
argumentCount=$#
# set sbt version
set_sbt_version
checkJava
# only exists in 0.12+
setTraceLevel() {
case "$(sbt_version)" in
"0.7."* | "0.10."* | "0.11."* )
echoerr "Cannot set trace level in sbt version $(sbt_version)"
;;
*)
addSbt "set every traceLevel := $trace_level"
;;
case "$sbt_version" in
"0.7."* | "0.10."* | "0.11."*) echoerr "Cannot set trace level in sbt version $sbt_version" ;;
*) setThisBuild traceLevel "$trace_level" ;;
esac
}
# set scalacOptions if we were given any -S opts
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[*]}\""
# Update build.properties on disk to set explicit version - sbt gives us no choice
[[ -n "$sbt_explicit_version" ]] && update_build_props_sbt "$sbt_explicit_version"
vlog "Detected sbt version $(sbt_version)"
[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && addJava "-Dsbt.version=$sbt_explicit_version"
vlog "Detected sbt version $sbt_version"
[[ -n "$scala_version" ]] && echoerr "Overriding scala version to $scala_version"
if [[ -n "$sbt_script" ]]; then
residual_args=("$sbt_script" "${residual_args[@]}")
else
# no args - alert them there's stuff in here
((argumentCount > 0)) || {
vlog "Starting $script_name: invoke with -help for other options"
residual_args=(shell)
}
fi
# no args - alert them there's stuff in here
(( argumentCount > 0 )) || {
vlog "Starting $script_name: invoke with -help for other options"
residual_args=( shell )
}
# verify this is an sbt dir or -create was given
[[ -r ./build.sbt || -d ./project || -n "$sbt_create" ]] || {
# verify this is an sbt dir, -create was given or user attempts to run a scala script
[[ -r ./build.sbt || -d ./project || -n "$sbt_create" || -n "$sbt_script" || -n "$sbt_new" ]] || {
cat <<EOM
$(pwd) doesn't appear to be an sbt project.
If you want to start sbt anyway, run:
@ -424,12 +609,17 @@ EOM
}
# pick up completion if present; todo
# shellcheck disable=SC1091
[[ -r .sbt_completion.sh ]] && source .sbt_completion.sh
# directory to store sbt launchers
[[ -d "$sbt_launch_dir" ]] || mkdir -p "$sbt_launch_dir"
[[ -w "$sbt_launch_dir" ]] || sbt_launch_dir="$(mktemp -d -t sbt_extras_launchers.XXXXXX)"
# no jar? download it.
[[ -r "$sbt_jar" ]] || acquire_sbt_jar || {
# still no jar? uh-oh.
echo "Download failed. Obtain the jar manually and place it at $sbt_jar"
echo "Could not download and verify the launcher. Obtain the jar manually and place it at $sbt_jar"
exit 1
}
@ -438,13 +628,13 @@ if [[ -n "$noshare" ]]; then
addJava "$opt"
done
else
case "$(sbt_version)" in
"0.7."* | "0.10."* | "0.11."* | "0.12."* )
case "$sbt_version" in
"0.7."* | "0.10."* | "0.11."* | "0.12."*)
[[ -n "$sbt_dir" ]] || {
sbt_dir="$HOME/.sbt/$(sbt_version)"
sbt_dir="$HOME/.sbt/$sbt_version"
vlog "Using $sbt_dir as sbt dir, -sbt-dir to override."
}
;;
;;
esac
if [[ -n "$sbt_dir" ]]; then
@ -454,25 +644,18 @@ fi
if [[ -r "$jvm_opts_file" ]]; then
vlog "Using jvm options defined in file $jvm_opts_file"
while read opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
while read -r opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
elif [[ -n "$JVM_OPTS" && ! ("$JVM_OPTS" =~ ^@.*) ]]; then
vlog "Using jvm options defined in \$JVM_OPTS variable"
extra_jvm_opts=( $JVM_OPTS )
IFS=" " read -r -a extra_jvm_opts <<<"$JVM_OPTS"
else
vlog "Using default jvm options"
extra_jvm_opts=( $default_jvm_opts )
IFS=" " read -r -a extra_jvm_opts <<<"$( default_jvm_opts)"
fi
# traceLevel is 0.12+
[[ -n "$trace_level" ]] && setTraceLevel
if [[ -n "$log_level" ]] && [[ "$log_level" != Info ]]; then
sbt_commands=("set logLevel in Global := Level.$log_level" "${sbt_commands[@]}")
fi
# run sbt
execRunner "$java_cmd" \
"${extra_jvm_opts[@]}" \
"${java_args[@]}" \

21
script/dynver.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# Compute sbt-dynver-compatible version number
BUILD_TIME=`date '+%Y%m%d-%H%M'`
DYN_VER=`git describe --long --tags --abbrev=8 --match "v[0-9]*" --always --dirty="-${BUILD_TIME}"`
GIT_DIST=`echo ${DYN_VER} | sed -re "s/v([^-]*)-([0-9]+)-g(.*)/\2/g"`
GIT_TAG=`git describe --tags --dirty`
RELEASE_VERSION=`echo ${DYN_VER} | sed -re "s/v([^-]*)-([0-9]+)-g(.*)/\1/g"`
SNAPSHOT_VERSION=`echo ${DYN_VER} | sed -re "s/v([^-]*)-([0-9]+)-g(.*)/\1-\2-\3/g"`-SNAPSHOT
if [ ${GIT_DIST} -eq 0 ]; then
if [ ${GIT_TAG} == *"-dirty" ]; then
VERSION=${SNAPSHOT_VERSION}
else
VERSION=${RELEASE_VERSION}
fi
else
VERSION=${SNAPSHOT_VERSION}
fi
echo ${VERSION}

15
script/travis-deploy.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -ev
VERSION=`perl -npe "s/version in ThisBuild\s+:=\s+\"(.*)\"/\1/" version.sbt | sed -e "/^$/d"`
# Deploy a snapshot version only for master branch and jdk8
if [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]]; then
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]] && [[ "$VERSION" == *SNAPSHOT ]]; then
./sbt "; test; publish";
else
./sbt test;
fi;
else
./sbt test;
fi;

117
src/checkstyle/checks.xml Normal file
View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="FileTabCharacter"/>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="\r"/>
<property name="message" value="Line contains carriage return"/>
</module>
<module name="RegexpMultiline">
<property name="format" value=" \n"/>
<property name="message" value="Line has trailing whitespace"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="\{\n\n"/>
<property name="message" value="Blank line after opening brace"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="\n\n\}"/>
<property name="message" value="Blank line before closing brace"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="\n\n\n"/>
<property name="message" value="Multiple consecutive blank lines"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="\n\n\Z"/>
<property name="message" value="Blank line before end of file"/>
</module>
<module name="TreeWalker">
<module name="EmptyBlock">
<property name="option" value="text"/>
<property name="tokens" value="
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
</module>
<module name="EmptyStatement"/>
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad">
<property name="option" value="space"/>
</module>
<module name="MethodParamPad">
<property name="allowLineBreaks" value="true"/>
<property name="option" value="nospace"/>
</module>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="option" value="nl"/>
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
</module>
<module name="LeftCurly">
<property name="option" value="eol"/>
<property name="tokens" value="
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
</module>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<module name="GenericWhitespace"/>
<module name="WhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="UpperEll"/>
<module name="DefaultComesLast"/>
<module name="ArrayTypeStyle"/>
<module name="MultipleVariableDeclarations"/>
<module name="ModifierOrder"/>
<module name="OneStatementPerLine"/>
<module name="StringLiteralEquality"/>
<module name="MutableException"/>
<module name="EqualsHashCode"/>
<module name="InnerAssignment"/>
<module name="InterfaceIsType"/>
<module name="HideUtilityClassConstructor"/>
<module name="MemberName"/>
<module name="LocalVariableName"/>
<module name="LocalFinalVariableName"/>
<module name="TypeName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="ClassTypeParameterName">
<property name="format" value="^[A-Z][0-9]?$"/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="^[A-Z][0-9]?$"/>
</module>
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<property name="tokens" value="
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
</module>
</module>
</module>

View File

@ -0,0 +1,280 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// snappy-java Project
//
// BitShuffle.java
// Since: 2016/03/31
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
import java.nio.ByteBuffer;
public class BitShuffle
{
static {
try {
impl = SnappyLoader.loadBitShuffleApi();
}
catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
/**
* An instance of BitShuffleNative
*/
private static BitShuffleNative impl;
/**
* Apply a bit-shuffling filter into the content in the given input buffer. After bit-shuffling,
* you can retrieve the shuffled data from the output buffer [pos() ...limit())
* (shuffled data size = limit() - pos() = remaining()).
*
* @param input buffer[pos() ... limit()) containing the input data
* @param type element type of the input data
* @param shuffled output of the shuffled data. Uses range [pos()..].
* @return byte size of the shuffled data.
* @throws SnappyError when the input is not a direct buffer
* @throws IllegalArgumentException when the input length is not a multiple of the given type size
*/
public static int shuffle(ByteBuffer input, BitShuffleType type, ByteBuffer shuffled) throws IOException {
if (!input.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "input is not a direct buffer");
}
if (!shuffled.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "destination is not a direct buffer");
}
// input: input[pos(), limit())
// output: shuffled
int uPos = input.position();
int uLen = input.remaining();
int typeSize = type.getTypeSize();
if (uLen % typeSize != 0) {
throw new IllegalArgumentException("input length must be a multiple of the given type size: " + typeSize);
}
if (shuffled.remaining() < uLen) {
throw new IllegalArgumentException("not enough space for output");
}
int numProcessed = impl.shuffleDirectBuffer(input, uPos, typeSize, uLen, shuffled, shuffled.position());
assert(numProcessed == uLen);
// pos limit
// [ ......BBBBBBB.........]
shuffled.limit(shuffled.position() + numProcessed);
return numProcessed;
}
/**
* Apply a bit-shuffling filter into the input short array.
*
* @param input
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] shuffle(short[] input) throws IOException {
if (input.length * 2 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 2];
int numProcessed = impl.shuffle(input, 0, 2, input.length * 2, output, 0);
assert(numProcessed == input.length * 2);
return output;
}
/**
* Apply a bit-shuffling filter into the input int array.
*
* @param input
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] shuffle(int[] input) throws IOException {
if (input.length * 4 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 4];
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
}
/**
* Apply a bit-shuffling filter into the input long array.
*
* @param input
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] shuffle(long[] input) throws IOException {
if (input.length * 8 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 8];
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
}
/**
* Apply a bit-shuffling filter into the input float array.
*
* @param input
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] shuffle(float[] input) throws IOException {
if (input.length * 4 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 4];
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
}
/**
* Apply a bit-shuffling filter into the input double array.
*
* @param input
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] shuffle(double[] input) throws IOException {
if (input.length * 8 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 8];
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
}
/**
* Convert the input bit-shuffled byte array into an original array. The result is dumped
* to the specified output buffer.
*
* @param shuffled buffer[pos() ... limit()) containing the input shuffled data
* @param type element type of the input data
* @param output output of the the original data. It uses buffer[pos()..]
* @return byte size of the unshuffled data.
* @throws IOException when failed to unshuffle the given input
* @throws SnappyError when the input is not a direct buffer
* @throws IllegalArgumentException when the length of input shuffled data is not a multiple of the given type size
*/
public static int unshuffle(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) throws IOException {
if (!shuffled.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "input is not a direct buffer");
}
if (!output.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "destination is not a direct buffer");
}
// input: input[pos(), limit())
// output: shuffled
int uPos = shuffled.position();
int uLen = shuffled.remaining();
int typeSize = type.getTypeSize();
if (uLen % typeSize != 0) {
throw new IllegalArgumentException("length of input shuffled data must be a multiple of the given type size: " + typeSize);
}
if (output.remaining() < uLen) {
throw new IllegalArgumentException("not enough space for output");
}
int numProcessed = impl.unshuffleDirectBuffer(shuffled, uPos, typeSize, uLen, output, shuffled.position());
assert(numProcessed == uLen);
// pos limit
// [ ......BBBBBBB.........]
shuffled.limit(shuffled.position() + numProcessed);
return numProcessed;
}
/**
* Convert the input bit-shuffled byte array into an original short array.
*
* @param input
* @return a short array
* @throws IOException
*/
public static short[] unshuffleShortArray(byte[] input) throws IOException {
short[] output = new short[input.length / 2];
int numProcessed = impl.unshuffle(input, 0, 2, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
/**
* Convert the input bit-shuffled byte array into an original int array.
*
* @param input
* @return an int array
* @throws IOException
*/
public static int[] unshuffleIntArray(byte[] input) throws IOException {
int[] output = new int[input.length / 4];
int numProcessed = impl.unshuffle(input, 0, 4, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
/**
* Convert the input bit-shuffled byte array into an original long array.
*
* @param input
* @return a long array
* @throws IOException
*/
public static long[] unshuffleLongArray(byte[] input) throws IOException {
long[] output = new long[input.length / 8];
int numProcessed = impl.unshuffle(input, 0, 8, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
/**
* Convert the input bit-shuffled byte array into an original float array.
*
* @param input
* @return an float array
* @throws IOException
*/
public static float[] unshuffleFloatArray(byte[] input) throws IOException {
float[] output = new float[input.length / 4];
int numProcessed = impl.unshuffle(input, 0, 4, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
/**
* Convert the input bit-shuffled byte array into an original double array.
*
* @param input
* @return a double array
* @throws IOException
*/
public static double[] unshuffleDoubleArray(byte[] input) throws IOException {
double[] output = new double[input.length / 8];
int numProcessed = impl.unshuffle(input, 0, 8, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
}

View File

@ -0,0 +1,133 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
#include <bitshuffle.h>
#include "BitShuffleNative.h"
inline void throw_exception(JNIEnv *env, jobject self, int errorCode)
{
jclass c = env->FindClass("org/xerial/snappy/SnappyNative");
if(c==0)
return;
jmethodID mth_throwex = env->GetMethodID(c, "throw_error", "(I)V");
if(mth_throwex == 0)
return;
env->CallVoidMethod(self, mth_throwex, (jint) errorCode);
}
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: shuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffle
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
int64_t processedBytes = bshuf_bitshuffle(
in + inputOffset, out + outputOffset, (size_t) (length / typeSize), (size_t) typeSize, 0);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
return (jint) processedBytes;
}
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: shuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffleDirectBuffer
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* inputBuffer = (char*) env->GetDirectBufferAddress(input);
char* outputBuffer = (char*) env->GetDirectBufferAddress(output);
if(inputBuffer == 0 || outputBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
int64_t processedBytes = bshuf_bitshuffle(
inputBuffer + inputOffset, outputBuffer + outputOffset, (size_t) (length / typeSize), (size_t) typeSize, 0);
return (jint) processedBytes;
}
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: unshuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffle
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
int64_t processedBytes = bshuf_bitunshuffle(
in + inputOffset, out + outputOffset, (size_t) (length / typeSize), (size_t) typeSize, 0);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
return (jint) processedBytes;
}
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: unshuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffleDirectBuffer
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* inputBuffer = (char*) env->GetDirectBufferAddress(input);
char* outputBuffer = (char*) env->GetDirectBufferAddress(output);
if(inputBuffer == 0 || outputBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
int64_t processedBytes = bshuf_bitunshuffle(
inputBuffer + inputOffset, outputBuffer + outputOffset, (size_t) (length / typeSize), (size_t) typeSize, 0);
return (jint) processedBytes;
}

View File

@ -0,0 +1,45 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_xerial_snappy_BitShuffleNative */
#ifndef _Included_org_xerial_snappy_BitShuffleNative
#define _Included_org_xerial_snappy_BitShuffleNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: shuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffle
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: shuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffleDirectBuffer
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: unshuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffle
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: unshuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffleDirectBuffer
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,60 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// snappy-java Project
//
// BitShuffleNative.java
// Since: 2016/03/31
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* JNI interfaces of the {@link BitShuffle} implementation. The native method in this class is
* defined in BitShuffleNative.h (genereted by javah) and BitShuffleNative.cpp
* <p/>
* <p>
* <b> DO NOT USE THIS CLASS since the direct use of this class might break the
* native library code loading in {@link SnappyLoader}. </b>
* </p>
*
* @author leo
*/
public class BitShuffleNative
{
// ------------------------------------------------------------------------
// Bit-shuffling routines to improve compression of typed binary data.
// A quick benchmark result can be found in a gist below;
// https://gist.github.com/maropu/01103215df34b317a7a7
// ------------------------------------------------------------------------
public native int shuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
throws IOException;
public native int shuffleDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
throws IOException;
public native int unshuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
throws IOException;
public native int unshuffleDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
throws IOException;
}

View File

@ -0,0 +1,53 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyErrorCode.java
// Since: 2011/03/30 14:56:50
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
/**
* Type codes used in ByteBuffer based BitShuffle APIs
*
* @author leo
*/
public enum BitShuffleType
{
BYTE(1),
SHORT(2),
INT(4),
LONG(8),
FLOAT(4),
DOUBLE(8);
public final int id;
private BitShuffleType(int id)
{
this.id = id;
}
public int getTypeSize()
{
return id;
}
}

View File

@ -24,18 +24,18 @@
//--------------------------------------
package org.xerial.snappy;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Locale;
/**
* Provides OS name and architecture name.
*
*
* @author leo
*
*/
public class OSInfo
{
public class OSInfo {
private static HashMap<String, String> archMapping = new HashMap<String, String>();
public static final String X86 = "x86";
@ -44,6 +44,12 @@ public class OSInfo
public static final String IA64 = "ia64";
public static final String PPC = "ppc";
public static final String PPC64 = "ppc64";
public static final String PPC64LE = "ppc64le";
public static final String IBMZ = "s390";
public static final String IBMZ_64 = "s390x";
public static final String AARCH_64 = "aarch64";
public static final String RISCV_64 = "riscv64";
public static final String LOONGARCH_64 = "loongarch64";
static {
// x86 mappings
@ -75,22 +81,39 @@ public class OSInfo
archMapping.put("power_pc", PPC);
archMapping.put("power_rs", PPC);
//PowerPC 64bit Little Endian mappings
archMapping.put(PPC64LE, PPC64LE);
// TODO: PowerPC 64bit mappings
archMapping.put(PPC64, PPC64);
archMapping.put("power64", PPC64);
archMapping.put("powerpc64", PPC64);
archMapping.put("power_pc64", PPC64);
archMapping.put("power_rs64", PPC64);
archMapping.put(PPC64, PPC64);
archMapping.put("power64", PPC64);
archMapping.put("powerpc64", PPC64);
archMapping.put("power_pc64", PPC64);
archMapping.put("power_rs64", PPC64);
// IBM z mappings
archMapping.put(IBMZ, IBMZ);
// IBM z 64-bit mappings
archMapping.put(IBMZ_64, IBMZ_64);
// Aarch64 mappings
archMapping.put(AARCH_64, AARCH_64);
// RISC-V mappings
archMapping.put(RISCV_64, RISCV_64);
// LoongArch64 mappings
archMapping.put(LOONGARCH_64, LOONGARCH_64);
}
public static void main(String[] args) {
if (args.length >= 1) {
if ("--os".equals(args[0])) {
if(args.length >= 1) {
if("--os".equals(args[0])) {
System.out.print(getOSName());
return;
}
else if ("--arch".equals(args[0])) {
else if("--arch".equals(args[0])) {
System.out.print(getArchName());
return;
}
@ -107,27 +130,98 @@ public class OSInfo
return translateOSNameToFolderName(System.getProperty("os.name"));
}
public static String getArchName() {
// if running Linux on ARM, need to determine ABI of JVM
String osArch = System.getProperty("os.arch");
if (osArch.startsWith("arm") && System.getProperty("os.name").contains("Linux")) {
String javaHome = System.getProperty("java.home");
public static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
}
static String getHardwareName() {
try {
Process p = Runtime.getRuntime().exec("uname -m");
p.waitFor();
InputStream in = p.getInputStream();
try {
int readLen = 0;
ByteArrayOutputStream b = new ByteArrayOutputStream();
byte[] buf = new byte[32];
while((readLen = in.read(buf, 0, buf.length)) >= 0) {
b.write(buf, 0, readLen);
}
return b.toString();
}
finally {
if(in != null) {
in.close();
}
}
}
catch(Throwable e) {
System.err.println("Error while running uname -m: " + e.getMessage());
return "unknown";
}
}
static String resolveArmArchType() {
if(System.getProperty("os.name").contains("Linux")) {
String armType = getHardwareName();
// armType (uname -m) can be armv5t, armv5te, armv5tej, armv5tejl, armv6, armv7, armv7l, i686
if(armType.startsWith("armv6")) {
// Raspberry PI
return "armv6";
}
else if(armType.startsWith("armv7")) {
// Generic
return "armv7";
}
// Java 1.8 introduces a system property to determine armel or armhf
// http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8005545
String abi = System.getProperty("sun.arch.abi");
if(abi != null && abi.startsWith("gnueabihf")) {
return "armv7";
}
// For java7, we stil need to if run some shell commands to determine ABI of JVM
try {
// determine if first JVM found uses ARM hard-float ABI
String[] cmdarray = { "/bin/sh", "-c", "find '" + javaHome +
"' -name 'libjvm.so' | head -1 | xargs readelf -A | " +
"grep 'Tag_ABI_VFP_args: VFP registers'" };
int exitCode = Runtime.getRuntime().exec(cmdarray).waitFor();
if (exitCode == 0)
return "armhf";
int exitCode = Runtime.getRuntime().exec("which readelf").waitFor();
if(exitCode == 0) {
String javaHome = System.getProperty("java.home");
String[] cmdarray = {"/bin/sh", "-c", "find '" + javaHome +
"' -name 'libjvm.so' | head -1 | xargs readelf -A | " +
"grep 'Tag_ABI_VFP_args: VFP registers'"};
exitCode = Runtime.getRuntime().exec(cmdarray).waitFor();
if(exitCode == 0) {
return "armv7";
}
}
else {
System.err.println("WARNING! readelf not found. Cannot check if running on an armhf system, " +
"armel architecture will be presumed.");
}
}
catch (IOException e) {
catch(IOException e) {
// ignored: fall back to "arm" arch (soft-float ABI)
}
catch (InterruptedException e) {
catch(InterruptedException e) {
// ignored: fall back to "arm" arch (soft-float ABI)
}
}
}
// Use armv5, soft-float ABI
return "arm";
}
public static String getArchName() {
String osArch = System.getProperty("os.arch");
// For Android
if(isAndroid()) {
return "android-arm";
}
if(osArch.startsWith("arm")) {
osArch = resolveArmArchType();
}
else {
String lc = osArch.toLowerCase(Locale.US);
if(archMapping.containsKey(lc))
@ -137,20 +231,19 @@ public class OSInfo
}
static String translateOSNameToFolderName(String osName) {
if (osName.contains("Windows")) {
if(osName.contains("Windows")) {
return "Windows";
}
else if (osName.contains("Mac")) {
else if(osName.contains("Mac")) {
return "Mac";
}
else if (osName.contains("Linux")) {
else if(osName.contains("Linux")) {
return "Linux";
}
else if (osName.contains("AIX")) {
return "AIX";
}
else {
else if(osName.contains("AIX")) {
return "AIX";
}
else {
return osName.replaceAll("\\W", "");
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
package org.xerial.snappy;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* Snappy compressor/decompressor interface. The implementation can be JNI binding or pure-java Snappy implementation.
*/
public interface SnappyApi
{
// ------------------------------------------------------------------------
// Generic compression/decompression routines.
// ------------------------------------------------------------------------
long rawCompress(long inputAddr, long inputSize, long destAddr)
throws IOException;
long rawUncompress(long inputAddr, long inputSize, long destAddr)
throws IOException;
int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed,
int outputOffset)
throws IOException;
int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset)
throws IOException;
int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed,
int outputOffset)
throws IOException;
int rawUncompress(Object input, int inputOffset, int inputLength, Object output, int outputOffset)
throws IOException;
// Returns the maximal size of the compressed representation of
// input data that is "source_bytes" bytes in length;
int maxCompressedLength(int source_bytes);
// This operation takes O(1) time.
int uncompressedLength(ByteBuffer compressed, int offset, int len)
throws IOException;
int uncompressedLength(Object input, int offset, int len)
throws IOException;
long uncompressedLength(long inputAddr, long len)
throws IOException;
boolean isValidCompressedBuffer(ByteBuffer compressed, int offset, int len)
throws IOException;
boolean isValidCompressedBuffer(Object input, int offset, int len)
throws IOException;
boolean isValidCompressedBuffer(long inputAddr, long offset, long len)
throws IOException;
void arrayCopy(Object src, int offset, int byteLength, Object dest, int dOffset)
throws IOException;
}

View File

@ -1,67 +1,70 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyBundleActivator.java
// Since: 2011/06/22 10:01:46
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import java.util.jar.Manifest;
/**
* OSGi bundle entry point
*
* @author leo
*
*/
public class SnappyBundleActivator implements BundleActivator
{
/**
* Name of the Snappy native library
*/
public static final String LIBRARY_NAME = "snappyjava";
/**
* Make a call to {@link System#loadLibrary(String)} to load the native library which assumes
* that the library is available on the path based on this {@link Bundle}'s {@link Manifest}.
*/
public void start(BundleContext context) throws Exception
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyBundleActivator.java
// Since: 2011/06/22 10:01:46
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import java.util.jar.Manifest;
/**
* OSGi bundle entry point
*
* @author leo
*/
public class SnappyBundleActivator
implements BundleActivator
{
/**
* Name of the Snappy native library
*/
public static final String LIBRARY_NAME = "snappyjava";
/**
* Make a call to {@link System#loadLibrary(String)} to load the native library which assumes
* that the library is available on the path based on this {@link Bundle}'s {@link Manifest}.
*/
public void start(BundleContext context)
throws Exception
{
String library = System.mapLibraryName(LIBRARY_NAME);
if (library.toLowerCase().endsWith(".dylib"))
{
// some MacOS JDK7+ vendors map to dylib instead of jnilib
library = library.replace(".dylib", ".jnilib");
}
System.loadLibrary(library);
SnappyLoader.setApi(new SnappyNative());
}
public void stop(BundleContext context) throws Exception
{
SnappyLoader.setApi(null);
SnappyLoader.cleanUpExtractedNativeLib();
}
}
String library = System.mapLibraryName(LIBRARY_NAME);
String osArch = System.getProperty("os.arch");
if (library.toLowerCase().endsWith(".dylib") && "x86".equals(osArch)) {
// some MacOS JDK7+ vendors map to dylib instead of jnilib
library = library.replace(".dylib", ".jnilib");
}
System.loadLibrary(library);
SnappyLoader.setSnappyApi(new SnappyNative());
}
public void stop(BundleContext context)
throws Exception
{
SnappyLoader.setSnappyApi(null);
SnappyLoader.cleanUpExtractedNativeLib();
}
}

View File

@ -1,117 +1,146 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyCodec.java
// Since: 2011/04/03 14:50:20
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
/**
* Preamble header for {@link SnappyOutputStream}.
*
* <p>
* The magic header is the following 8 bytes data:
*
* <pre>
* -126, 'S', 'N', 'A', 'P', 'P', 'Y', 0
* </pre>
*
* </p>
*
* @author leo
*
*/
public class SnappyCodec
{
public static final byte[] MAGIC_HEADER = new byte[] { -126, 'S', 'N', 'A', 'P', 'P', 'Y', 0 };
public static final int MAGIC_LEN = MAGIC_HEADER.length;
public static final int HEADER_SIZE = MAGIC_LEN + 8;
public static final int DEFAULT_VERSION = 1;
public static final int MINIMUM_COMPATIBLE_VERSION = 1;
public final byte[] magic;
public final int version;
public final int compatibleVersion;
private final byte[] headerArray;
private SnappyCodec(byte[] magic, int version, int compatibleVersion) {
this.magic = magic;
this.version = version;
this.compatibleVersion = compatibleVersion;
ByteArrayOutputStream header = new ByteArrayOutputStream(HEADER_SIZE);
DataOutputStream d = new DataOutputStream(header);
try {
d.write(magic, 0, MAGIC_LEN);
d.writeInt(version);
d.writeInt(compatibleVersion);
d.close();
}
catch(IOException e) {
throw new RuntimeException(e);
}
headerArray = header.toByteArray();
}
@Override
public String toString() {
return String.format("version:%d, compatible version:%d", version, compatibleVersion);
}
public static int headerSize() {
return HEADER_SIZE;
}
public int writeHeader(byte[] dst, int dstOffset) {
System.arraycopy(headerArray, 0, dst, dstOffset, headerArray.length);
return headerArray.length;
}
public int writeHeader(OutputStream out) throws IOException {
out.write(headerArray, 0, headerArray.length);
return headerArray.length;
}
public boolean isValidMagicHeader() {
return Arrays.equals(MAGIC_HEADER, magic);
}
public static SnappyCodec readHeader(InputStream in) throws IOException {
DataInputStream d = new DataInputStream(in);
byte[] magic = new byte[MAGIC_LEN];
d.readFully(magic, 0, MAGIC_LEN);
int version = d.readInt();
int compatibleVersion = d.readInt();
return new SnappyCodec(magic, version, compatibleVersion);
}
public static SnappyCodec currentHeader = new SnappyCodec(MAGIC_HEADER, DEFAULT_VERSION, MINIMUM_COMPATIBLE_VERSION);
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyCodec.java
// Since: 2011/04/03 14:50:20
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
/**
* Preamble header for {@link SnappyOutputStream}.
* <p/>
* <p>
* The magic header is the following 8 bytes data:
* <p/>
* <pre>
* -126, 'S', 'N', 'A', 'P', 'P', 'Y', 0
* </pre>
* <p/>
* </p>
*
* @author leo
*/
public class SnappyCodec
{
static final byte[] MAGIC_HEADER = new byte[] {-126, 'S', 'N', 'A', 'P', 'P', 'Y', 0};
public static final int MAGIC_LEN = MAGIC_HEADER.length;
public static final int HEADER_SIZE = MAGIC_LEN + 8;
public static final int MAGIC_HEADER_HEAD = SnappyOutputStream.readInt(MAGIC_HEADER, 0);
static {
assert (MAGIC_HEADER_HEAD < 0);
}
public static final int DEFAULT_VERSION = 1;
public static final int MINIMUM_COMPATIBLE_VERSION = 1;
public static final SnappyCodec currentHeader = new SnappyCodec(MAGIC_HEADER, DEFAULT_VERSION, MINIMUM_COMPATIBLE_VERSION);
public final byte[] magic;
public final int version;
public final int compatibleVersion;
private final byte[] headerArray;
private SnappyCodec(byte[] magic, int version, int compatibleVersion)
{
this.magic = magic;
this.version = version;
this.compatibleVersion = compatibleVersion;
ByteArrayOutputStream header = new ByteArrayOutputStream(HEADER_SIZE);
DataOutputStream d = new DataOutputStream(header);
try {
d.write(magic, 0, MAGIC_LEN);
d.writeInt(version);
d.writeInt(compatibleVersion);
d.close();
}
catch (IOException e) {
throw new RuntimeException(e);
}
headerArray = header.toByteArray();
}
public static byte[] getMagicHeader()
{
return MAGIC_HEADER.clone();
}
@Override
public String toString()
{
return String.format("version:%d, compatible version:%d", version, compatibleVersion);
}
public static int headerSize()
{
return HEADER_SIZE;
}
public int writeHeader(byte[] dst, int dstOffset)
{
System.arraycopy(headerArray, 0, dst, dstOffset, headerArray.length);
return headerArray.length;
}
public int writeHeader(OutputStream out)
throws IOException
{
out.write(headerArray, 0, headerArray.length);
return headerArray.length;
}
public boolean isValidMagicHeader()
{
return Arrays.equals(MAGIC_HEADER, magic);
}
public static boolean hasMagicHeaderPrefix(byte[] b) {
int limit = Math.min(MAGIC_LEN, b.length);
int i = 0;
while(i < limit) {
if(b[i] != MAGIC_HEADER[i]) {
return false;
}
++i;
}
return true;
}
public static SnappyCodec readHeader(InputStream in)
throws IOException
{
DataInputStream d = new DataInputStream(in);
byte[] magic = new byte[MAGIC_LEN];
d.readFully(magic, 0, MAGIC_LEN);
int version = d.readInt();
int compatibleVersion = d.readInt();
return new SnappyCodec(magic, version, compatibleVersion);
}
}

View File

@ -1,62 +1,65 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyError.java
// Since: 2011/03/30 15:22:43
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
/**
* Used when serious errors (unchecked exception) are observed.
*
* @author leo
*
*/
public class SnappyError extends Error
{
/**
*
*/
private static final long serialVersionUID = 1L;
public final SnappyErrorCode errorCode;
public SnappyError(SnappyErrorCode code) {
super();
this.errorCode = code;
}
public SnappyError(SnappyErrorCode code, Error e) {
super(e);
this.errorCode = code;
}
public SnappyError(SnappyErrorCode code, String message) {
super(message);
this.errorCode = code;
}
@Override
public String getMessage() {
return String.format("[%s] %s", errorCode.name(), super.getMessage());
}
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyError.java
// Since: 2011/03/30 15:22:43
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
/**
* Used when serious errors (unchecked exception) are observed.
*
* @author leo
*/
public class SnappyError
extends Error
{
/**
*
*/
private static final long serialVersionUID = 1L;
public final SnappyErrorCode errorCode;
public SnappyError(SnappyErrorCode code)
{
super();
this.errorCode = code;
}
public SnappyError(SnappyErrorCode code, Error e)
{
super(e);
this.errorCode = code;
}
public SnappyError(SnappyErrorCode code, String message)
{
super(message);
this.errorCode = code;
}
@Override
public String getMessage()
{
return String.format("[%s] %s", errorCode.name(), super.getMessage());
}
}

View File

@ -1,64 +1,69 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyErrorCode.java
// Since: 2011/03/30 14:56:50
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
/**
* Error codes of snappy-java
*
* @author leo
*
*/
public enum SnappyErrorCode {
// DO NOT change these error code IDs because these numbers are used inside SnappyNative.cpp
UNKNOWN(0),
FAILED_TO_LOAD_NATIVE_LIBRARY(1),
PARSING_ERROR(2),
NOT_A_DIRECT_BUFFER(3),
OUT_OF_MEMORY(4),
FAILED_TO_UNCOMPRESS(5),
EMPTY_INPUT(6),
INCOMPATIBLE_VERSION(7),
INVALID_CHUNK_SIZE(8)
;
public final int id;
private SnappyErrorCode(int id) {
this.id = id;
}
public static SnappyErrorCode getErrorCode(int id) {
for (SnappyErrorCode code : SnappyErrorCode.values()) {
if (code.id == id)
return code;
}
return UNKNOWN;
}
public static String getErrorMessage(int id) {
return getErrorCode(id).name();
}
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyErrorCode.java
// Since: 2011/03/30 14:56:50
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
/**
* Error codes of snappy-java
*
* @author leo
*/
public enum SnappyErrorCode
{
// DO NOT change these error code IDs because these numbers are used inside SnappyNative.cpp
UNKNOWN(0),
FAILED_TO_LOAD_NATIVE_LIBRARY(1),
PARSING_ERROR(2),
NOT_A_DIRECT_BUFFER(3),
OUT_OF_MEMORY(4),
FAILED_TO_UNCOMPRESS(5),
EMPTY_INPUT(6),
INCOMPATIBLE_VERSION(7),
INVALID_CHUNK_SIZE(8),
UNSUPPORTED_PLATFORM(9),
TOO_LARGE_INPUT(10);
public final int id;
private SnappyErrorCode(int id)
{
this.id = id;
}
public static SnappyErrorCode getErrorCode(int id)
{
for (SnappyErrorCode code : SnappyErrorCode.values()) {
if (code.id == id) {
return code;
}
}
return UNKNOWN;
}
public static String getErrorMessage(int id)
{
return getErrorCode(id).name();
}
}

View File

@ -1,74 +1,82 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyException.java
// Since: 2011/03/30 14:56:14
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
/**
* Exception in snappy-java
*
* @deprecated Snappy-java now uses {@link IOException}
* @author leo
*
*/
@Deprecated
public class SnappyException extends Exception
{
private static final long serialVersionUID = 1L;
public final SnappyErrorCode errorCode;
public SnappyException(int code) {
this(SnappyErrorCode.getErrorCode(code));
}
public SnappyException(SnappyErrorCode errorCode) {
super();
this.errorCode = errorCode;
}
public SnappyException(SnappyErrorCode errorCode, Exception e) {
super(e);
this.errorCode = errorCode;
}
public SnappyException(SnappyErrorCode errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public SnappyErrorCode getErrorCode() {
return errorCode;
}
public static void throwException(int errorCode) throws SnappyException {
throw new SnappyException(errorCode);
}
@Override
public String getMessage() {
return String.format("[%s] %s", errorCode.name(), super.getMessage());
}
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyException.java
// Since: 2011/03/30 14:56:14
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
/**
* Exception in snappy-java
*
* @author leo
* @deprecated Snappy-java now uses {@link IOException}
*/
@Deprecated
public class SnappyException
extends Exception
{
private static final long serialVersionUID = 1L;
public final SnappyErrorCode errorCode;
public SnappyException(int code)
{
this(SnappyErrorCode.getErrorCode(code));
}
public SnappyException(SnappyErrorCode errorCode)
{
super();
this.errorCode = errorCode;
}
public SnappyException(SnappyErrorCode errorCode, Exception e)
{
super(e);
this.errorCode = errorCode;
}
public SnappyException(SnappyErrorCode errorCode, String message)
{
super(message);
this.errorCode = errorCode;
}
public SnappyErrorCode getErrorCode()
{
return errorCode;
}
public static void throwException(int errorCode)
throws SnappyException
{
throw new SnappyException(errorCode);
}
@Override
public String getMessage()
{
return String.format("[%s] %s", errorCode.name(), super.getMessage());
}
}

View File

@ -4,52 +4,70 @@
package org.xerial.snappy;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.Checksum;
/**
* Constants and utilities for implementing x-snappy-framed.
*
*
* @author Brett Okken
* @since 1.1.0
*/
final class SnappyFramed {
final class SnappyFramed
{
public static final int COMPRESSED_DATA_FLAG = 0x00;
public static final int UNCOMPRESSED_DATA_FLAG = 0x01;
public static final int STREAM_IDENTIFIER_FLAG = 0xff;
private static final int MASK_DELTA = 0xa282ead8;
/**
* Sun specific mechanisms to clean up resources associated with direct byte buffers.
*/
@SuppressWarnings("unchecked")
private static final Class<? extends ByteBuffer> SUN_DIRECT_BUFFER = (Class<? extends ByteBuffer>) lookupClassQuietly("sun.nio.ch.DirectBuffer");
private static final Method SUN_BUFFER_CLEANER;
private static final Method SUN_CLEANER_CLEAN;
private static final Supplier<Checksum> CHECKSUM_SUPPLIER;
static
{
Method bufferCleaner = null;
Method cleanerClean = null;
try {
//operate under the assumption that if the sun direct buffer class exists,
//all of the sun classes exist
if (SUN_DIRECT_BUFFER != null) {
bufferCleaner = SUN_DIRECT_BUFFER.getMethod("cleaner", (Class[])null);
Class<?> cleanClazz = lookupClassQuietly("sun.misc.Cleaner");
cleanerClean = cleanClazz.getMethod("clean", (Class[])null);
}
} catch(Throwable t) {
Logger.getLogger(SnappyFramed.class.getName()).log(Level.FINE, "Exception occurred attempting to lookup Sun specific DirectByteBuffer cleaner classes.", t);
Supplier<Checksum> supplier = null;
try
{
final Class<?> crc32cClazz = Class.forName("java.util.zip.CRC32C");
// using LambdaMetafactory requires a caller sensitive lookup
final MethodHandles.Lookup lookup = MethodHandles.lookup();
final MethodHandle conHandle = lookup.findConstructor(crc32cClazz, MethodType.methodType(void.class));
// use LambdaMetafactory to generate an implementation of Supplier<Checksum> which invokes
// the java.util.zip.CRC32C default constructor
supplier = (Supplier<Checksum>) LambdaMetafactory.metafactory(lookup,
// method name on Supplier
"get",
// functional interface to be created by factory
MethodType.methodType(Supplier.class),
// type of the functional interface
// uses a generic, so erasure to Object
MethodType.methodType(Object.class),
// the method handle to call
conHandle,
// type as used at call site
MethodType.methodType(Checksum.class))
.getTarget()
.invoke();
}
SUN_BUFFER_CLEANER = bufferCleaner;
SUN_CLEANER_CLEAN = cleanerClean;
catch(Throwable t)
{
Logger.getLogger(SnappyFramed.class.getName())
.log(Level.FINE, "java.util.zip.CRC32C not loaded, using PureJavaCrc32C", t);
supplier = null;
}
CHECKSUM_SUPPLIER = supplier != null ? supplier : PureJavaCrc32C::new;
}
/**
@ -58,18 +76,18 @@ final class SnappyFramed {
*/
public static final byte[] HEADER_BYTES = new byte[] {
(byte) STREAM_IDENTIFIER_FLAG, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61,
0x50, 0x70, 0x59 };
0x50, 0x70, 0x59};
public static int maskedCrc32c(byte[] data)
public static Checksum getCRC32C()
{
return maskedCrc32c(data, 0, data.length);
return CHECKSUM_SUPPLIER.get();
}
public static int maskedCrc32c(byte[] data, int offset, int length)
public static int maskedCrc32c(Checksum crc32c, byte[] data, int offset, int length)
{
final PureJavaCrc32C crc32c = new PureJavaCrc32C();
crc32c.reset();
crc32c.update(data, offset, length);
return mask(crc32c.getIntegerValue());
return mask((int) crc32c.getValue());
}
/**
@ -78,10 +96,10 @@ final class SnappyFramed {
* in Apache Hadoop: Rotate the checksum by 15 bits, then add the constant
* 0xa282ead8 (using wraparound as normal for unsigned integers). This is
* equivalent to the following C code:
*
* <p/>
* <pre>
* uint32_t mask_checksum(uint32_t x) {
* return ((x >> 15) | (x << 17)) + 0xa282ead8;
* return ((x >> 15) | (x << 17)) + 0xa282ead8;
* }
* </pre>
*/
@ -90,9 +108,9 @@ final class SnappyFramed {
// Rotate right by 15 bits and add a constant.
return ((crc >>> 15) | (crc << 17)) + MASK_DELTA;
}
static final int readBytes(ReadableByteChannel source, ByteBuffer dest) throws IOException
static final int readBytes(ReadableByteChannel source, ByteBuffer dest)
throws IOException
{
// tells how many bytes to read.
final int expectedLength = dest.remaining();
@ -105,47 +123,43 @@ final class SnappyFramed {
totalRead = lastRead;
// if we did not read as many bytes as we had hoped, try reading again.
if (lastRead < expectedLength)
{
if (lastRead < expectedLength) {
// as long the buffer is not full (remaining() == 0) and we have not reached EOF (lastRead == -1) keep reading.
while (dest.remaining() != 0 && lastRead != -1)
{
while (dest.remaining() != 0 && lastRead != -1) {
lastRead = source.read(dest);
// if we got EOF, do not add to total read.
if (lastRead != -1)
{
if (lastRead != -1) {
totalRead += lastRead;
}
}
}
if (totalRead > 0)
{
if (totalRead > 0) {
dest.limit(dest.position());
}
else
{
else {
dest.position(dest.limit());
}
return totalRead;
}
static int skip(final ReadableByteChannel source, final int skip, final ByteBuffer buffer) throws IOException
static int skip(final ReadableByteChannel source, final int skip, final ByteBuffer buffer)
throws IOException
{
if (skip <= 0) {
return 0;
}
int toSkip = skip;
int skipped = 0;
while(toSkip > 0 && skipped != -1) {
int skipped = 0;
while (toSkip > 0 && skipped != -1) {
buffer.clear();
if (toSkip < buffer.capacity()) {
buffer.limit(toSkip);
}
skipped = source.read(buffer);
if (skipped > 0) {
toSkip -= skipped;
@ -155,32 +169,4 @@ final class SnappyFramed {
buffer.clear();
return skip - toSkip;
}
private static Class<?> lookupClassQuietly(String name) {
try {
return SnappyFramed.class.getClassLoader().loadClass(name);
} catch (Throwable t) {
Logger.getLogger(SnappyFramed.class.getName()).log(Level.FINE, "Did not find requested class: " + name, t);
}
return null;
}
/**
* Provides jvm implementation specific operation to aggressively release resources associated with <i>buffer</i>.
* @param buffer The {@code ByteBuffer} to release. Must not be {@code null}. Must be {@link ByteBuffer#isDirect() direct}.
*/
static void releaseDirectByteBuffer(ByteBuffer buffer)
{
assert buffer != null && buffer.isDirect();
if (SUN_DIRECT_BUFFER != null && SUN_DIRECT_BUFFER.isAssignableFrom(buffer.getClass())) {
try {
Object cleaner = SUN_BUFFER_CLEANER.invoke(buffer, (Object[]) null);
SUN_CLEANER_CLEAN.invoke(cleaner, (Object[]) null);
} catch (Throwable t) {
Logger.getLogger(SnappyFramed.class.getName()).log(Level.FINE, "Exception occurred attempting to clean up Sun specific DirectByteBuffer.", t);
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
package org.xerial.snappy;
import org.xerial.snappy.buffer.CachedBufferAllocator;
import java.io.OutputStream;
public class SnappyHadoopCompatibleOutputStream extends SnappyOutputStream
{
public SnappyHadoopCompatibleOutputStream(OutputStream out)
{
this(out, DEFAULT_BLOCK_SIZE);
}
public SnappyHadoopCompatibleOutputStream(OutputStream out, int blockSize)
{
super(out, blockSize, CachedBufferAllocator.getBufferAllocatorFactory());
}
@Override
protected int writeHeader()
{
return 0;
}
@Override
protected void writeBlockPreemble()
{
writeCurrentDataSize();
}
}

View File

@ -5,19 +5,22 @@ import java.io.IOException;
/**
* Enhanced IOException with SnappyErrorCode
*/
public class SnappyIOException extends IOException {
public class SnappyIOException
extends IOException
{
private final SnappyErrorCode errorCode;
public SnappyIOException(SnappyErrorCode errorCode, String message) {
public SnappyIOException(SnappyErrorCode errorCode, String message)
{
super(message);
this.errorCode = errorCode;
}
@Override
public String getMessage() {
public String getMessage()
{
return String.format("[%s] %s", errorCode.name(), super.getMessage());
}
public SnappyErrorCode getErrorCode() { return errorCode; }
}

View File

@ -30,30 +30,49 @@ import java.io.InputStream;
/**
* A stream filter for reading data compressed by {@link SnappyOutputStream}.
*
*
*
* @author leo
*
*/
public class SnappyInputStream extends InputStream
public class SnappyInputStream
extends InputStream
{
private boolean finishedReading = false;
public static final int MAX_CHUNK_SIZE = 512 * 1024 * 1024; // 512 MiB
private boolean finishedReading = false;
protected final InputStream in;
private final int maxChunkSize;
private byte[] compressed;
private byte[] uncompressed;
private int uncompressedCursor = 0;
private int uncompressedLimit = 0;
private byte[] compressed;
private byte[] uncompressed;
private int uncompressedCursor = 0;
private int uncompressedLimit = 0;
private byte[] chunkSizeBuf = new byte[4];
private byte[] header = new byte[SnappyCodec.headerSize()];
/**
* Create a filter for reading compressed data as a uncompressed stream
*
*
* @param input
* @throws IOException
*/
public SnappyInputStream(InputStream input) throws IOException {
public SnappyInputStream(InputStream input)
throws IOException
{
this(input, MAX_CHUNK_SIZE);
}
/**
* Create a filter for reading compressed data as a uncompressed stream with provided maximum chunk size
*
* @param input
* @param maxChunkSize
* @throws IOException
*/
public SnappyInputStream(InputStream input, int maxChunkSize)
throws IOException
{
this.maxChunkSize = maxChunkSize;
this.in = input;
readHeader();
}
@ -65,34 +84,44 @@ public class SnappyInputStream extends InputStream
* @see java.io.InputStream#close()
*/
@Override
public void close() throws IOException {
public void close()
throws IOException
{
compressed = null;
uncompressed = null;
if (in != null)
if (in != null) {
in.close();
}
}
protected void readHeader() throws IOException {
byte[] header = new byte[SnappyCodec.headerSize()];
protected void readHeader()
throws IOException
{
int readBytes = 0;
while (readBytes < header.length) {
int ret = in.read(header, readBytes, header.length - readBytes);
if (ret == -1)
if (ret == -1) {
break;
}
readBytes += ret;
}
// Quick test of the header
if(readBytes == 0) {
if (readBytes == 0) {
// Snappy produces at least 1-byte result. So the empty input is not a valid input
throw new SnappyIOException(SnappyErrorCode.EMPTY_INPUT, "Cannot decompress empty stream");
}
if (readBytes < header.length || header[0] != SnappyCodec.MAGIC_HEADER[0]) {
if (readBytes < header.length || !SnappyCodec.hasMagicHeaderPrefix(header)) {
// do the default uncompression
// (probably) compressed by Snappy.compress(byte[])
readFully(header, readBytes);
return;
}
}
private static boolean isValidHeader(byte[] header)
throws IOException
{
SnappyCodec codec = SnappyCodec.readHeader(new ByteArrayInputStream(header));
if (codec.isValidMagicHeader()) {
// The input data is compressed by SnappyOutputStream
@ -101,16 +130,17 @@ public class SnappyInputStream extends InputStream
"Compressed with an incompatible codec version %d. At least version %d is required",
codec.version, SnappyCodec.MINIMUM_COMPATIBLE_VERSION));
}
return true;
}
else {
// (probably) compressed by Snappy.compress(byte[])
readFully(header, readBytes);
return;
return false;
}
}
protected void readFully(byte[] fragment, int fragmentLength) throws IOException {
if(fragmentLength == 0) {
protected void readFully(byte[] fragment, int fragmentLength)
throws IOException
{
if (fragmentLength == 0) {
finishedReading = true;
return;
}
@ -118,7 +148,7 @@ public class SnappyInputStream extends InputStream
compressed = new byte[Math.max(8 * 1024, fragmentLength)]; // 8K
System.arraycopy(fragment, 0, compressed, 0, fragmentLength);
int cursor = fragmentLength;
for (int readBytes = 0; (readBytes = in.read(compressed, cursor, compressed.length - cursor)) != -1;) {
for (int readBytes = 0; (readBytes = in.read(compressed, cursor, compressed.length - cursor)) != -1; ) {
cursor += readBytes;
if (cursor >= compressed.length) {
byte[] newBuf = new byte[(compressed.length * 2)];
@ -135,7 +165,6 @@ public class SnappyInputStream extends InputStream
Snappy.uncompress(compressed, 0, cursor, uncompressed, 0);
this.uncompressedCursor = 0;
this.uncompressedLimit = uncompressedLength;
}
/**
@ -146,26 +175,48 @@ public class SnappyInputStream extends InputStream
* @see java.io.InputStream#read(byte[], int, int)
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
return rawRead(b, off, len);
public int read(byte[] b, int byteOffset, int byteLength)
throws IOException
{
int writtenBytes = 0;
for (; writtenBytes < byteLength; ) {
if (uncompressedCursor >= uncompressedLimit) {
if (hasNextChunk()) {
continue;
}
else {
return writtenBytes == 0 ? -1 : writtenBytes;
}
}
int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes);
System.arraycopy(uncompressed, uncompressedCursor, b, byteOffset + writtenBytes, bytesToWrite);
writtenBytes += bytesToWrite;
uncompressedCursor += bytesToWrite;
}
return writtenBytes;
}
/**
* Read uncompressed data into the specified array
*
*
* @param array
* @param byteOffset
* @param byteLength
* @return written bytes
* @throws IOException
*/
public int rawRead(Object array, int byteOffset, int byteLength) throws IOException {
public int rawRead(Object array, int byteOffset, int byteLength)
throws IOException
{
int writtenBytes = 0;
for (; writtenBytes < byteLength;) {
for (; writtenBytes < byteLength; ) {
if (uncompressedCursor >= uncompressedLimit) {
if (hasNextChunk())
if (hasNextChunk()) {
continue;
}
else {
return writtenBytes == 0 ? -1 : writtenBytes;
}
@ -181,175 +232,235 @@ public class SnappyInputStream extends InputStream
/**
* Read long array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of long elements to read
*
* @param d input
* @param off offset
* @param len the number of long elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(long[] d, int off, int len) throws IOException {
public int read(long[] d, int off, int len)
throws IOException
{
return rawRead(d, off * 8, len * 8);
}
/**
* Read long array from the stream
*
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(long[] d) throws IOException {
public int read(long[] d)
throws IOException
{
return read(d, 0, d.length);
}
/**
* Read double array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of double elements to read
*
* @param d input
* @param off offset
* @param len the number of double elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(double[] d, int off, int len) throws IOException {
public int read(double[] d, int off, int len)
throws IOException
{
return rawRead(d, off * 8, len * 8);
}
/**
* Read double array from the stream
*
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(double[] d) throws IOException {
public int read(double[] d)
throws IOException
{
return read(d, 0, d.length);
}
/**
* Read int array from the stream
*
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(int[] d) throws IOException {
public int read(int[] d)
throws IOException
{
return read(d, 0, d.length);
}
/**
* Read int array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of int elements to read
*
* @param d input
* @param off offset
* @param len the number of int elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(int[] d, int off, int len) throws IOException {
public int read(int[] d, int off, int len)
throws IOException
{
return rawRead(d, off * 4, len * 4);
}
/**
* Read float array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of float elements to read
*
* @param d input
* @param off offset
* @param len the number of float elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(float[] d, int off, int len) throws IOException {
public int read(float[] d, int off, int len)
throws IOException
{
return rawRead(d, off * 4, len * 4);
}
/**
* Read float array from the stream
*
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(float[] d) throws IOException {
public int read(float[] d)
throws IOException
{
return read(d, 0, d.length);
}
/**
* Read short array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of short elements to read
*
* @param d input
* @param off offset
* @param len the number of short elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(short[] d, int off, int len) throws IOException {
public int read(short[] d, int off, int len)
throws IOException
{
return rawRead(d, off * 2, len * 2);
}
/**
* Read short array from the stream
*
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(short[] d) throws IOException {
public int read(short[] d)
throws IOException
{
return read(d, 0, d.length);
}
protected boolean hasNextChunk() throws IOException {
if (finishedReading)
/**
* Read next len bytes
*
* @param dest
* @param offset
* @param len
* @return read bytes
*/
private int readNext(byte[] dest, int offset, int len)
throws IOException
{
int readBytes = 0;
while (readBytes < len) {
int ret = in.read(dest, readBytes + offset, len - readBytes);
if (ret == -1) {
finishedReading = true;
return readBytes;
}
readBytes += ret;
}
return readBytes;
}
protected boolean hasNextChunk()
throws IOException
{
if (finishedReading) {
return false;
}
uncompressedCursor = 0;
uncompressedLimit = 0;
int readBytes = 0;
while (readBytes < 4) {
int ret = in.read(chunkSizeBuf, readBytes, 4 - readBytes);
if (ret == -1) {
finishedReading = true;
int readBytes = readNext(header, 0, 4);
if (readBytes < 4) {
return false;
}
int chunkSize = SnappyOutputStream.readInt(header, 0);
if (chunkSize == SnappyCodec.MAGIC_HEADER_HEAD) {
// Concatenated data
int remainingHeaderSize = SnappyCodec.headerSize() - 4;
readBytes = readNext(header, 4, remainingHeaderSize);
if(readBytes < remainingHeaderSize) {
throw new SnappyIOException(SnappyErrorCode.FAILED_TO_UNCOMPRESS, String.format("Insufficient header size in a concatenated block"));
}
if (isValidHeader(header)) {
return hasNextChunk();
}
else {
return false;
}
readBytes += ret;
}
int chunkSize = SnappyOutputStream.readInt(chunkSizeBuf, 0);
// chunkSize is negative
if (chunkSize < 0) {
throw new SnappyError(SnappyErrorCode.INVALID_CHUNK_SIZE, "chunkSize is too big or negative : " + chunkSize);
}
// chunkSize is big
if (chunkSize > maxChunkSize) {
throw new SnappyError(SnappyErrorCode.FAILED_TO_UNCOMPRESS, String.format("Received chunkSize %,d is greater than max configured chunk size %,d", chunkSize, maxChunkSize));
}
// extend the compressed data buffer size
if (compressed == null || chunkSize > compressed.length) {
compressed = new byte[chunkSize];
// chunkSize exceeds limit
try {
compressed = new byte[chunkSize];
}
catch (java.lang.OutOfMemoryError e) {
throw new SnappyError(SnappyErrorCode.INVALID_CHUNK_SIZE, e.getMessage());
}
}
readBytes = 0;
while (readBytes < chunkSize) {
int ret = in.read(compressed, readBytes, chunkSize - readBytes);
if (ret == -1)
if (ret == -1) {
break;
}
readBytes += ret;
}
if (readBytes < chunkSize) {
@ -379,15 +490,19 @@ public class SnappyInputStream extends InputStream
* @see java.io.InputStream#read()
*/
@Override
public int read() throws IOException {
public int read()
throws IOException
{
if (uncompressedCursor < uncompressedLimit) {
return uncompressed[uncompressedCursor++] & 0xFF;
}
else {
if (hasNextChunk())
if (hasNextChunk()) {
return read();
else
}
else {
return -1;
}
}
}
@ -395,7 +510,9 @@ public class SnappyInputStream extends InputStream
* @see java.io.InputStream#available()
*/
@Override
public int available() throws IOException {
public int available()
throws IOException
{
if (uncompressedCursor < uncompressedLimit) {
return uncompressedLimit - uncompressedCursor;
}

281
src/main/java/org/xerial/snappy/SnappyLoader.java Executable file → Normal file
View File

@ -19,13 +19,15 @@
// SnappyLoader.java
// Since: 2011/03/29
//
// $URL$
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.*;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration;
import java.util.Properties;
import java.util.UUID;
@ -36,10 +38,10 @@ import java.util.UUID;
* user platform (<i>os.name</i> and <i>os.arch</i>). The natively compiled
* libraries bundled to snappy-java contain the codes of the original snappy and
* JNI programs to access Snappy.
*
* <p/>
* In default, no configuration is required to use snappy-java, but you can load
* your own native library created by 'make native' command.
*
* <p/>
* This SnappyLoader searches for native libraries (snappyjava.dll,
* libsnappy.so, etc.) in the following order:
* <ol>
@ -49,74 +51,85 @@ import java.util.UUID;
* <li>(System property: <i>org.xerial.snappy.lib.path</i>)/(System property:
* <i>org.xerial.lib.name</i>)
* <li>One of the libraries embedded in snappy-java-(version).jar extracted into
* (System property: <i>java.io.tempdir</i>). If
* (System property: <i>java.io.tmpdir</i>). If
* <i>org.xerial.snappy.tempdir</i> is set, use this folder instead of
* <i>java.io.tempdir</i>.
* <i>java.io.tmpdir</i>.
* </ol>
*
* <p/>
* <p>
* If you do not want to use folder <i>java.io.tempdir</i>, set the System
* If you do not want to use folder <i>java.io.tmpdir</i>, set the System
* property <i>org.xerial.snappy.tempdir</i>. For example, to use
* <i>/tmp/leo</i> as a temporary folder to copy native libraries, use -D option
* of JVM:
*
* <p/>
* <pre>
* <code>
* java -Dorg.xerial.snappy.tempdir="/tmp/leo" ...
* </code>
* </pre>
*
* <p/>
* </p>
*
*
* @author leo
*
*/
public class SnappyLoader
{
public static final String SNAPPY_SYSTEM_PROPERTIES_FILE = "org-xerial-snappy.properties";
public static final String KEY_SNAPPY_LIB_PATH = "org.xerial.snappy.lib.path";
public static final String KEY_SNAPPY_LIB_NAME = "org.xerial.snappy.lib.name";
public static final String KEY_SNAPPY_TEMPDIR = "org.xerial.snappy.tempdir";
public static final String KEY_SNAPPY_USE_SYSTEMLIB = "org.xerial.snappy.use.systemlib";
public static final String SNAPPY_SYSTEM_PROPERTIES_FILE = "org-xerial-snappy.properties";
public static final String KEY_SNAPPY_LIB_PATH = "org.xerial.snappy.lib.path";
public static final String KEY_SNAPPY_LIB_NAME = "org.xerial.snappy.lib.name";
public static final String KEY_SNAPPY_PUREJAVA = "org.xerial.snappy.purejava";
public static final String KEY_SNAPPY_TEMPDIR = "org.xerial.snappy.tempdir";
public static final String KEY_SNAPPY_USE_SYSTEMLIB = "org.xerial.snappy.use.systemlib";
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS = "org.xerial.snappy.disable.bundled.libs"; // Depreciated, but preserved for backward compatibility
private static volatile boolean isLoaded = false;
private static volatile SnappyNative api = null;
private static boolean isLoaded = false;
private static volatile SnappyApi snappyApi = null;
private static volatile BitShuffleNative bitshuffleApi = null;
private static File nativeLibFile = null;
static void cleanUpExtractedNativeLib() {
if(nativeLibFile != null && nativeLibFile.exists())
nativeLibFile.delete();
static void cleanUpExtractedNativeLib()
{
if (nativeLibFile != null && nativeLibFile.exists()) {
boolean deleted = nativeLibFile.delete();
if (!deleted) {
// Deleting native lib has failed, but it's not serious so simply ignore it here
}
snappyApi = null;
bitshuffleApi = null;
}
}
/**
* Set the api instance.
*
* @param nativeCode
* Set the `snappyApi` instance.
*
* @param apiImpl
*/
static synchronized void setApi(SnappyNative nativeCode)
static synchronized void setSnappyApi(SnappyApi apiImpl)
{
api = nativeCode;
snappyApi = apiImpl;
}
/**
* load system properties when configuration file of the name
* {@link #SNAPPY_SYSTEM_PROPERTIES_FILE} is found
*/
private static void loadSnappySystemProperties() {
private static void loadSnappySystemProperties()
{
try {
InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(SNAPPY_SYSTEM_PROPERTIES_FILE);
if (is == null)
return; // no configuration file is found
if (is == null) {
return; // no configuration file is found
}
// Load property file
Properties props = new Properties();
props.load(is);
is.close();
Enumeration< ? > names = props.propertyNames();
Enumeration<?> names = props.propertyNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (name.startsWith("org.xerial.snappy.")) {
@ -136,69 +149,82 @@ public class SnappyLoader
loadSnappySystemProperties();
}
static synchronized SnappyNative load()
static synchronized SnappyApi loadSnappyApi()
{
if (api != null)
return api;
try {
loadNativeLibrary();
setApi(new SnappyNative());
isLoaded = true;
}
catch (Exception e) {
e.printStackTrace();
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
if (snappyApi != null) {
return snappyApi;
}
loadNativeLibrary();
setSnappyApi(new SnappyNative());
return snappyApi;
}
return api;
static synchronized BitShuffleNative loadBitShuffleApi()
{
if (bitshuffleApi != null) {
return bitshuffleApi;
}
loadNativeLibrary();
bitshuffleApi = new BitShuffleNative();
return bitshuffleApi;
}
/**
* Load a native library of snappy-java
*/
private static void loadNativeLibrary() {
nativeLibFile = findNativeLibrary();
if (nativeLibFile != null) {
// Load extracted or specified snappyjava native library.
System.load(nativeLibFile.getAbsolutePath());
}
else {
// Load preinstalled snappyjava (in the path -Djava.library.path)
System.loadLibrary("snappyjava");
private synchronized static void loadNativeLibrary()
{
if (!isLoaded) {
try {
nativeLibFile = findNativeLibrary();
if (nativeLibFile != null) {
// Load extracted or specified snappyjava native library.
System.load(nativeLibFile.getAbsolutePath());
} else {
// Load preinstalled snappyjava (in the path -Djava.library.path)
System.loadLibrary("snappyjava");
}
}
catch (Exception e) {
e.printStackTrace();
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
}
isLoaded = true;
}
}
private static boolean contentsEquals(InputStream in1, InputStream in2) throws IOException {
if(!(in1 instanceof BufferedInputStream)) {
in1 = new BufferedInputStream(in1);
private static boolean contentsEquals(InputStream in1, InputStream in2)
throws IOException
{
if (!(in1 instanceof BufferedInputStream)) {
in1 = new BufferedInputStream(in1);
}
if(!(in2 instanceof BufferedInputStream)) {
in2 = new BufferedInputStream(in2);
if (!(in2 instanceof BufferedInputStream)) {
in2 = new BufferedInputStream(in2);
}
int ch = in1.read();
while(ch != -1) {
int ch2 = in2.read();
if(ch != ch2)
while (ch != -1) {
int ch2 = in2.read();
if (ch != ch2) {
return false;
}
ch = in1.read();
}
int ch2 = in2.read();
return ch2 == -1;
}
/**
* Extract the specified library file to the target folder
*
*
* @param libFolderForCurrentOS
* @param libraryFileName
* @param targetFolder
* @return
*/
private static File extractLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) {
private static File extractLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder)
{
String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName;
// Attach UUID to the native library file to ensure multiple class loaders can read the libsnappy-java multiple times.
@ -208,44 +234,61 @@ public class SnappyLoader
try {
// Extract a native library file into the target directory
InputStream reader = SnappyLoader.class.getResourceAsStream(nativeLibraryFilePath);
FileOutputStream writer = new FileOutputStream(extractedLibFile);
InputStream reader = null;
FileOutputStream writer = null;
try {
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
reader = getResourceAsInputStream(nativeLibraryFilePath);
try {
writer = new FileOutputStream(extractedLibFile);
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
}
}
finally {
if (writer != null) {
writer.close();
}
}
}
finally {
if (reader != null) {
reader.close();
}
// Delete the extracted lib file on JVM exit.
extractedLibFile.deleteOnExit();
if(writer != null)
writer.close();
if(reader != null)
reader.close();
}
// Set executable (x) flag to enable Java to load the native library
extractedLibFile.setReadable(true);
extractedLibFile.setWritable(true, true);
extractedLibFile.setExecutable(true);
boolean success = extractedLibFile.setReadable(true) &&
extractedLibFile.setWritable(true, true) &&
extractedLibFile.setExecutable(true);
if (!success) {
// Setting file flag may fail, but in this case another error will be thrown in later phase
}
// Check whether the contents are properly copied from the resource folder
{
InputStream nativeIn = SnappyLoader.class.getResourceAsStream(nativeLibraryFilePath);
InputStream extractedLibIn = new FileInputStream(extractedLibFile);
InputStream nativeIn = null;
InputStream extractedLibIn = null;
try {
if(!contentsEquals(nativeIn, extractedLibIn))
nativeIn = getResourceAsInputStream(nativeLibraryFilePath);
extractedLibIn = new FileInputStream(extractedLibFile);
if (!contentsEquals(nativeIn, extractedLibIn)) {
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, String.format("Failed to write a native library file at %s", extractedLibFile));
}
}
finally {
if(nativeIn != null)
if (nativeIn != null) {
nativeIn.close();
if(extractedLibIn != null)
}
if (extractedLibIn != null) {
extractedLibIn.close();
}
}
}
@ -257,76 +300,84 @@ public class SnappyLoader
}
}
static File findNativeLibrary() {
static File findNativeLibrary()
{
boolean useSystemLib = Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_USE_SYSTEMLIB, "false"));
boolean disabledBundledLibs = Boolean
.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_BUNDLED_LIBS, "false"));
if (useSystemLib || disabledBundledLibs)
if (useSystemLib || disabledBundledLibs) {
return null; // Use a pre-installed libsnappyjava
}
// Try to load the library in org.xerial.snappy.lib.path */
String snappyNativeLibraryPath = System.getProperty(KEY_SNAPPY_LIB_PATH);
String snappyNativeLibraryName = System.getProperty(KEY_SNAPPY_LIB_NAME);
// Resolve the library file name with a suffix (e.g., dll, .so, etc.)
if (snappyNativeLibraryName == null)
// Resolve the library file name with a suffix (e.g., dll, .so, etc.)
if (snappyNativeLibraryName == null) {
snappyNativeLibraryName = System.mapLibraryName("snappyjava");
}
if (snappyNativeLibraryPath != null) {
File nativeLib = new File(snappyNativeLibraryPath, snappyNativeLibraryName);
if (nativeLib.exists())
if (nativeLib.exists()) {
return nativeLib;
}
}
// Load an OS-dependent native library inside a jar file
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
boolean hasNativeLib = hasResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName);
if(!hasNativeLib) {
if(OSInfo.getOSName().equals("Mac")) {
if (!hasNativeLib) {
if (OSInfo.getOSName().equals("Mac")) {
// Fix for openjdk7 for Mac
String altName = "libsnappyjava.jnilib";
if(hasResource(snappyNativeLibraryPath + "/" + altName)) {
String altName = "libsnappyjava.dylib";
if (hasResource(snappyNativeLibraryPath + "/" + altName)) {
snappyNativeLibraryName = altName;
hasNativeLib = true;
}
}
}
if(!hasNativeLib) {
if (!hasNativeLib) {
String errorMessage = String.format("no native library is found for os.name=%s and os.arch=%s", OSInfo.getOSName(), OSInfo.getArchName());
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, errorMessage);
}
// Temporary folder for the native lib. Use the value of org.xerial.snappy.tempdir or java.io.tmpdir
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
System.getProperty("java.io.tmpdir"))).getAbsolutePath();
File tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR, System.getProperty("java.io.tmpdir")));
if (!tempFolder.exists()) {
boolean created = tempFolder.mkdirs();
if (!created) {
// if created == false, it will fail eventually in the later part
}
}
// Extract and load a native library inside the jar file
return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder);
return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder.getAbsolutePath());
}
private static boolean hasResource(String path) {
private static boolean hasResource(String path)
{
return SnappyLoader.class.getResource(path) != null;
}
/**
* Get the snappy-java version by reading pom.properties embedded in jar.
* This version data is used as a suffix of a dll file extracted from the
* jar.
*
*
* @return the version string
*/
public static String getVersion() {
public static String getVersion()
{
URL versionFile = SnappyLoader.class
.getResource("/META-INF/maven/org.xerial.snappy/snappy-java/pom.properties");
if (versionFile == null)
if (versionFile == null) {
versionFile = SnappyLoader.class.getResource("/org/xerial/snappy/VERSION");
}
String version = "unknown";
try {
@ -334,8 +385,9 @@ public class SnappyLoader
Properties versionData = new Properties();
versionData.load(versionFile.openStream());
version = versionData.getProperty("version", version);
if (version.equals("unknown"))
version = versionData.getProperty("VERSION", version);
if (version.equals("unknown")) {
version = versionData.getProperty("SNAPPY_VERSION", version);
}
version = version.trim().replaceAll("[^0-9M\\.]", "");
}
}
@ -345,4 +397,15 @@ public class SnappyLoader
return version;
}
private static InputStream getResourceAsInputStream(String resourcePath) throws IOException {
URL url = SnappyLoader.class.getResource(resourcePath);
URLConnection connection = url.openConnection();
if (connection instanceof JarURLConnection) {
JarURLConnection jarConnection = (JarURLConnection) connection;
jarConnection.setUseCaches(false); // workaround for https://bugs.openjdk.org/browse/JDK-8205976
return jarConnection.getInputStream();
} else {
return connection.getInputStream();
}
}
}

View File

@ -1,309 +1,299 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
#include <string>
#include <cstring>
#include <snappy.h>
#include "SnappyNative.h"
void throw_exception(JNIEnv *env, jobject self, int errorCode)
{
jclass c = env->FindClass("org/xerial/snappy/SnappyNative");
if(c==0)
return;
jmethodID mth_throwex = env->GetMethodID(c, "throw_error", "(I)V");
if(mth_throwex == 0)
return;
env->CallVoidMethod(self, mth_throwex, (jint) errorCode);
}
JNIEXPORT jstring JNICALL Java_org_xerial_snappy_SnappyNative_nativeLibraryVersion
(JNIEnv * env, jobject self)
{
return env->NewStringUTF("1.1.0");
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t compressedLength;
snappy::RawCompress((char*) srcAddr, (size_t) length, (char*) destAddr, &compressedLength);
return (jlong) compressedLength;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t uncompressedLength;
snappy::GetUncompressedLength((char*) srcAddr, (size_t) length, &uncompressedLength);
bool ret = snappy::RawUncompress((char*) srcAddr, (size_t) length, (char*) destAddr);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jlong) uncompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: compress
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__Ljava_nio_ByteBuffer_2IILjava_nio_ByteBuffer_2I
(JNIEnv* env, jobject self, jobject uncompressed, jint upos, jint ulen, jobject compressed, jint cpos)
{
char* uncompressedBuffer = (char*) env->GetDirectBufferAddress(uncompressed);
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(uncompressedBuffer == 0 || compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t compressedLength;
snappy::RawCompress(uncompressedBuffer + upos, (size_t) ulen, compressedBuffer + cpos, &compressedLength);
return (jint) compressedLength;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__Ljava_lang_Object_2IILjava_lang_Object_2I
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint inputLen, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
size_t compressedLength;
snappy::RawCompress(in + inputOffset, (size_t) inputLen, out + outputOffset, &compressedLength);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
return (jint) compressedLength;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__Ljava_lang_Object_2IILjava_lang_Object_2I
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint inputLength, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
size_t uncompressedLength;
snappy::GetUncompressedLength(in + inputOffset, (size_t) inputLength, &uncompressedLength);
bool ret = snappy::RawUncompress(in + inputOffset, (size_t) inputLength, out + outputOffset);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jint) uncompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: uncompress
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)Z
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__Ljava_nio_ByteBuffer_2IILjava_nio_ByteBuffer_2I
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen, jobject decompressed, jint dpos)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
char* decompressedBuffer = (char*) env->GetDirectBufferAddress(decompressed);
if(compressedBuffer == 0 || decompressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t decompressedLength;
snappy::GetUncompressedLength(compressedBuffer + cpos, (size_t) clen, &decompressedLength);
bool ret = snappy::RawUncompress(compressedBuffer + cpos, (size_t) clen, decompressedBuffer + dpos);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jint) decompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: maxCompressedLength
* Signature: (J)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_maxCompressedLength
(JNIEnv *, jobject, jint size)
{
size_t l = snappy::MaxCompressedLength((size_t) size);
return (jint) l;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: getUncompressedLength
* Signature: (Ljava/nio/ByteBuffer;)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_nio_ByteBuffer_2II
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t result;
bool ret = snappy::GetUncompressedLength(compressedBuffer + cpos, (size_t) clen, &result);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_lang_Object_2II
(JNIEnv * env, jobject self, jobject input, jint offset, jint length)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
if(in == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
size_t result;
bool ret = snappy::GetUncompressedLength(in + offset, (size_t) length, &result);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__JJ
(JNIEnv *env, jobject self, jlong inputAddr, jlong len) {
size_t result;
bool ret = snappy::GetUncompressedLength((char*) inputAddr, (size_t) len, &result);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_nio_ByteBuffer_2II
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
bool ret = snappy::IsValidCompressedBuffer(compressedBuffer + cpos, (size_t) clen);
return ret;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_lang_Object_2II
(JNIEnv * env, jobject self, jobject input, jint offset, jint length)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
if(in == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
bool ret = snappy::IsValidCompressedBuffer(in + offset, (size_t) length);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
return ret;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__JJJ
(JNIEnv * env, jobject self, jlong inputAddr, jlong offset, jlong length)
{
if(inputAddr == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
bool ret = snappy::IsValidCompressedBuffer((char*) (inputAddr + offset), (size_t) length);
return ret;
}
JNIEXPORT void JNICALL Java_org_xerial_snappy_SnappyNative_arrayCopy
(JNIEnv * env, jobject self, jobject input, jint offset, jint length, jobject output, jint output_offset)
{
char* src = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* dest = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(src == 0 || dest == 0) {
// out of memory
if(src != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, src, 0);
}
if(dest != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, dest, 0);
}
throw_exception(env, self, 4);
return;
}
memcpy(dest+output_offset, src+offset, (size_t) length);
env->ReleasePrimitiveArrayCritical((jarray) input, src, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, dest, 0);
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
#include <string>
#include <cstring>
#include <snappy.h>
#include "SnappyNative.h"
inline void throw_exception(JNIEnv *env, jobject self, int errorCode)
{
jclass c = env->GetObjectClass(self);
if(c==0)
return;
jmethodID mth_throwex = env->GetMethodID(c, "throw_error", "(I)V");
if(mth_throwex == 0)
return;
env->CallVoidMethod(self, mth_throwex, (jint) errorCode);
}
JNIEXPORT jstring JNICALL Java_org_xerial_snappy_SnappyNative_nativeLibraryVersion
(JNIEnv * env, jobject self)
{
// TODO: Do we need to read this library version from resources/org/xerial/snappy/VERSION?
return env->NewStringUTF("1.1.3");
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t compressedLength;
snappy::RawCompress((char*) srcAddr, (size_t) length, (char*) destAddr, &compressedLength);
return (jlong) compressedLength;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t uncompressedLength;
snappy::GetUncompressedLength((char*) srcAddr, (size_t) length, &uncompressedLength);
bool ret = snappy::RawUncompress((char*) srcAddr, (size_t) length, (char*) destAddr);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jlong) uncompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: compress
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__Ljava_nio_ByteBuffer_2IILjava_nio_ByteBuffer_2I
(JNIEnv* env, jobject self, jobject uncompressed, jint upos, jint ulen, jobject compressed, jint cpos)
{
char* uncompressedBuffer = (char*) env->GetDirectBufferAddress(uncompressed);
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(uncompressedBuffer == 0 || compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t compressedLength;
snappy::RawCompress(uncompressedBuffer + upos, (size_t) ulen, compressedBuffer + cpos, &compressedLength);
return (jint) compressedLength;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__Ljava_lang_Object_2IILjava_lang_Object_2I
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint inputLen, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
size_t compressedLength;
snappy::RawCompress(in + inputOffset, (size_t) inputLen, out + outputOffset, &compressedLength);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
return (jint) compressedLength;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__Ljava_lang_Object_2IILjava_lang_Object_2I
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint inputLength, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* out = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(in == 0 || out == 0) {
// out of memory
if(in != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
}
if(out != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
}
throw_exception(env, self, 4);
return 0;
}
size_t uncompressedLength;
snappy::GetUncompressedLength(in + inputOffset, (size_t) inputLength, &uncompressedLength);
bool ret = snappy::RawUncompress(in + inputOffset, (size_t) inputLength, out + outputOffset);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, out, 0);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jint) uncompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: uncompress
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)Z
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__Ljava_nio_ByteBuffer_2IILjava_nio_ByteBuffer_2I
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen, jobject decompressed, jint dpos)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
char* decompressedBuffer = (char*) env->GetDirectBufferAddress(decompressed);
if(compressedBuffer == 0 || decompressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t decompressedLength;
snappy::GetUncompressedLength(compressedBuffer + cpos, (size_t) clen, &decompressedLength);
bool ret = snappy::RawUncompress(compressedBuffer + cpos, (size_t) clen, decompressedBuffer + dpos);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jint) decompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: maxCompressedLength
* Signature: (J)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_maxCompressedLength
(JNIEnv *, jobject, jint size)
{
size_t l = snappy::MaxCompressedLength((size_t) size);
return (jint) l;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: getUncompressedLength
* Signature: (Ljava/nio/ByteBuffer;)J
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_nio_ByteBuffer_2II
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
size_t result;
bool ret = snappy::GetUncompressedLength(compressedBuffer + cpos, (size_t) clen, &result);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_lang_Object_2II
(JNIEnv * env, jobject self, jobject input, jint offset, jint length)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
if(in == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
size_t result;
bool ret = snappy::GetUncompressedLength(in + offset, (size_t) length, &result);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__JJ
(JNIEnv *env, jobject self, jlong inputAddr, jlong len) {
size_t result;
bool ret = snappy::GetUncompressedLength((char*) inputAddr, (size_t) len, &result);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_nio_ByteBuffer_2II
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen)
{
char* compressedBuffer = (char*) env->GetDirectBufferAddress(compressed);
if(compressedBuffer == 0) {
throw_exception(env, self, 3);
return (jint) 0;
}
bool ret = snappy::IsValidCompressedBuffer(compressedBuffer + cpos, (size_t) clen);
return ret;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_lang_Object_2II
(JNIEnv * env, jobject self, jobject input, jint offset, jint length)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
if(in == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
bool ret = snappy::IsValidCompressedBuffer(in + offset, (size_t) length);
env->ReleasePrimitiveArrayCritical((jarray) input, in, 0);
return ret;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__JJJ
(JNIEnv * env, jobject self, jlong inputAddr, jlong offset, jlong length)
{
if(inputAddr == 0) {
// out of memory
throw_exception(env, self, 4);
return 0;
}
bool ret = snappy::IsValidCompressedBuffer((char*) (inputAddr + offset), (size_t) length);
return ret;
}
JNIEXPORT void JNICALL Java_org_xerial_snappy_SnappyNative_arrayCopy
(JNIEnv * env, jobject self, jobject input, jint offset, jint length, jobject output, jint output_offset)
{
char* src = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
char* dest = (char*) env->GetPrimitiveArrayCritical((jarray) output, 0);
if(src == 0 || dest == 0) {
// out of memory
if(src != 0) {
env->ReleasePrimitiveArrayCritical((jarray) input, src, 0);
}
if(dest != 0) {
env->ReleasePrimitiveArrayCritical((jarray) output, dest, 0);
}
throw_exception(env, self, 4);
return;
}
memcpy(dest+output_offset, src+offset, (size_t) length);
env->ReleasePrimitiveArrayCritical((jarray) input, src, 0);
env->ReleasePrimitiveArrayCritical((jarray) output, dest, 0);
}

0
src/main/java/org/xerial/snappy/SnappyNative.h Executable file → Normal file
View File

View File

@ -1,87 +1,114 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// snappy-java Project
//
// SnappyNative.java
// Since: 2011/03/30
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* JNI interface of the {@link Snappy} implementation. The native method in this class is
* defined in SnappyNative.h (genereted by javah) and SnappyNative.cpp
*
* <p>
* <b> DO NOT USE THIS CLASS since the direct use of this class might break the
* native library code loading in {@link SnappyLoader}. </b>
* </p>
*
* @author leo
*
*/
public class SnappyNative
{
public native String nativeLibraryVersion();
// ------------------------------------------------------------------------
// Generic compression/decompression routines.
// ------------------------------------------------------------------------
public native long rawCompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public native long rawUncompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public native int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed,
int outputOffset) throws IOException;
public native int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset) throws IOException;
public native int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed,
int outputOffset) throws IOException;
public native int rawUncompress(Object input, int inputOffset, int inputLength, Object output, int outputOffset)
throws IOException;
// Returns the maximal size of the compressed representation of
// input data that is "source_bytes" bytes in length;
public native int maxCompressedLength(int source_bytes);
// This operation takes O(1) time.
public native int uncompressedLength(ByteBuffer compressed, int offset, int len) throws IOException;
public native int uncompressedLength(Object input, int offset, int len) throws IOException;
public native long uncompressedLength(long inputAddr, long len) throws IOException;
public native boolean isValidCompressedBuffer(ByteBuffer compressed, int offset, int len) throws IOException;
public native boolean isValidCompressedBuffer(Object input, int offset, int len) throws IOException;
public native boolean isValidCompressedBuffer(long inputAddr, long offset, long len) throws IOException;
public native void arrayCopy(Object src, int offset, int byteLength, Object dest, int dOffset) throws IOException;
public void throw_error(int errorCode) throws IOException {
throw new IOException(String.format("%s(%d)", SnappyErrorCode.getErrorMessage(errorCode), errorCode));
}
}
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// snappy-java Project
//
// SnappyNative.java
// Since: 2011/03/30
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* JNI interface of the {@link Snappy} implementation. The native method in this class is
* defined in SnappyNative.h (genereted by javah) and SnappyNative.cpp
* <p/>
* <p>
* <b> DO NOT USE THIS CLASS since the direct use of this class might break the
* native library code loading in {@link SnappyLoader}. </b>
* </p>
*
* @author leo
*/
public class SnappyNative implements SnappyApi
{
public native String nativeLibraryVersion();
// ------------------------------------------------------------------------
// Generic compression/decompression routines.
// ------------------------------------------------------------------------
@Override
public native long rawCompress(long inputAddr, long inputSize, long destAddr)
throws IOException;
@Override
public native long rawUncompress(long inputAddr, long inputSize, long destAddr)
throws IOException;
@Override
public native int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed,
int outputOffset)
throws IOException;
@Override
public native int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset)
throws IOException;
@Override
public native int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed,
int outputOffset)
throws IOException;
@Override
public native int rawUncompress(Object input, int inputOffset, int inputLength, Object output, int outputOffset)
throws IOException;
// Returns the maximal size of the compressed representation of
// input data that is "source_bytes" bytes in length;
@Override
public native int maxCompressedLength(int source_bytes);
// This operation takes O(1) time.
@Override
public native int uncompressedLength(ByteBuffer compressed, int offset, int len)
throws IOException;
@Override
public native int uncompressedLength(Object input, int offset, int len)
throws IOException;
@Override
public native long uncompressedLength(long inputAddr, long len)
throws IOException;
@Override
public native boolean isValidCompressedBuffer(ByteBuffer compressed, int offset, int len)
throws IOException;
@Override
public native boolean isValidCompressedBuffer(Object input, int offset, int len)
throws IOException;
@Override
public native boolean isValidCompressedBuffer(long inputAddr, long offset, long len)
throws IOException;
@Override
public native void arrayCopy(Object src, int offset, int byteLength, Object dest, int dOffset)
throws IOException;
public void throw_error(int errorCode)
throws IOException
{
throw new IOException(String.format("%s(%d)", SnappyErrorCode.getErrorMessage(errorCode), errorCode));
}
}

View File

@ -41,6 +41,7 @@ import java.io.OutputStream;
* The output data format is:
* <ol>
* <li>snappy codec header defined in {@link SnappyCodec} (8 bytes)
* <li>codec version (4 bytes integer, at least 1) and compatible version (4 bytes integer)
* <li>compressed block 1 : a pair of (compressed data size [4 byte integer.
* Big-endian], compressed data...)
* <li>compressed block 2
@ -55,9 +56,12 @@ import java.io.OutputStream;
*
* @author leo
*/
public class SnappyOutputStream extends OutputStream {
static final int MIN_BLOCK_SIZE = 1 * 1024;
static final int DEFAULT_BLOCK_SIZE = 32 * 1024; // Use 32kb for the default block size
public class SnappyOutputStream
extends OutputStream
{
public static final int MAX_BLOCK_SIZE = 512 * 1024 * 1024; // 512 MiB
public static final int MIN_BLOCK_SIZE = 1 * 1024;
public static final int DEFAULT_BLOCK_SIZE = 32 * 1024; // Use 32kb for the default block size
protected final OutputStream out;
private final int blockSize;
@ -65,27 +69,36 @@ public class SnappyOutputStream extends OutputStream {
private final BufferAllocator inputBufferAllocator;
private final BufferAllocator outputBufferAllocator;
protected final byte[] inputBuffer;
protected final byte[] outputBuffer;
// The input and output buffer fields are set to null when closing this stream:
protected byte[] inputBuffer;
protected byte[] outputBuffer;
private int inputCursor = 0;
private int outputCursor = 0;
private boolean headerWritten;
private boolean closed;
public SnappyOutputStream(OutputStream out) {
public SnappyOutputStream(OutputStream out)
{
this(out, DEFAULT_BLOCK_SIZE);
}
/**
* @param out
* @param blockSize byte size of the internal buffer size
* @throws IOException
* @throws IllegalArgumentException when blockSize is larger than 512 MiB
*/
public SnappyOutputStream(OutputStream out, int blockSize) {
this(out, blockSize, CachedBufferAllocator.factory);
public SnappyOutputStream(OutputStream out, int blockSize)
{
this(out, blockSize, CachedBufferAllocator.getBufferAllocatorFactory());
}
public SnappyOutputStream(OutputStream out, int blockSize, BufferAllocatorFactory bufferAllocatorFactory) {
public SnappyOutputStream(OutputStream out, int blockSize, BufferAllocatorFactory bufferAllocatorFactory)
{
this.out = out;
this.blockSize = Math.max(MIN_BLOCK_SIZE, blockSize);
if (this.blockSize > MAX_BLOCK_SIZE){
throw new IllegalArgumentException(String.format("Provided chunk size %,d larger than max %,d", this.blockSize, MAX_BLOCK_SIZE));
}
int inputSize = blockSize;
int outputSize = SnappyCodec.HEADER_SIZE + 4 + Snappy.maxCompressedLength(blockSize);
@ -93,77 +106,103 @@ public class SnappyOutputStream extends OutputStream {
this.outputBufferAllocator = bufferAllocatorFactory.getBufferAllocator(outputSize);
inputBuffer = inputBufferAllocator.allocate(inputSize);
outputBuffer = inputBufferAllocator.allocate(outputSize);
outputCursor = SnappyCodec.currentHeader.writeHeader(outputBuffer, 0);
outputBuffer = outputBufferAllocator.allocate(outputSize);
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(byte[], int, int)
*/
@Override
public void write(byte[] b, int off, int len) throws IOException {
rawWrite(b, off, len);
public void write(byte[] b, int byteOffset, int byteLength)
throws IOException
{
if (closed) {
throw new IOException("Stream is closed");
}
int cursor = 0;
while (cursor < byteLength) {
int readLen = Math.min(byteLength - cursor, blockSize - inputCursor);
// copy the input data to uncompressed buffer
if (readLen > 0) {
System.arraycopy(b, byteOffset + cursor, inputBuffer, inputCursor, readLen);
inputCursor += readLen;
}
if (inputCursor < blockSize) {
return;
}
compressInput();
cursor += readLen;
}
}
/**
* Compress the input long array data
*
* @param d input array
* @param d input array
* @param off offset in the array
* @param len the number of elements in the array to copy
* @throws IOException
*/
public void write(long[] d, int off, int len) throws IOException {
public void write(long[] d, int off, int len)
throws IOException
{
rawWrite(d, off * 8, len * 8);
}
/**
* Compress the input double array data
*
* @param f input array
* @param f input array
* @param off offset in the array
* @param len the number of elements in the array to copy
* @throws IOException
*/
public void write(double[] f, int off, int len) throws IOException {
public void write(double[] f, int off, int len)
throws IOException
{
rawWrite(f, off * 8, len * 8);
}
/**
* Compress the input float array data
*
* @param f input array
* @param f input array
* @param off offset in the array
* @param len the number of elements in the array to copy
* @throws IOException
*/
public void write(float[] f, int off, int len) throws IOException {
public void write(float[] f, int off, int len)
throws IOException
{
rawWrite(f, off * 4, len * 4);
}
/**
* Compress the input int array data
*
* @param f input array
* @param f input array
* @param off offset in the array
* @param len the number of elements in the array to copy
* @throws IOException
*/
public void write(int[] f, int off, int len) throws IOException {
public void write(int[] f, int off, int len)
throws IOException
{
rawWrite(f, off * 4, len * 4);
}
/**
* Compress the input short array data
*
* @param f input array
* @param f input array
* @param off offset in the array
* @param len the number of elements in the array to copy
* @throws IOException
*/
public void write(short[] f, int off, int len) throws IOException {
public void write(short[] f, int off, int len)
throws IOException
{
rawWrite(f, off * 2, len * 2);
}
@ -173,7 +212,9 @@ public class SnappyOutputStream extends OutputStream {
* @param d
* @throws IOException
*/
public void write(long[] d) throws IOException {
public void write(long[] d)
throws IOException
{
write(d, 0, d.length);
}
@ -183,7 +224,9 @@ public class SnappyOutputStream extends OutputStream {
* @param f
* @throws IOException
*/
public void write(double[] f) throws IOException {
public void write(double[] f)
throws IOException
{
write(f, 0, f.length);
}
@ -193,7 +236,9 @@ public class SnappyOutputStream extends OutputStream {
* @param f
* @throws IOException
*/
public void write(float[] f) throws IOException {
public void write(float[] f)
throws IOException
{
write(f, 0, f.length);
}
@ -203,7 +248,9 @@ public class SnappyOutputStream extends OutputStream {
* @param f
* @throws IOException
*/
public void write(int[] f) throws IOException {
public void write(int[] f)
throws IOException
{
write(f, 0, f.length);
}
@ -213,11 +260,14 @@ public class SnappyOutputStream extends OutputStream {
* @param f
* @throws IOException
*/
public void write(short[] f) throws IOException {
public void write(short[] f)
throws IOException
{
write(f, 0, f.length);
}
private boolean hasSufficientOutputBufferFor(int inputSize) {
private boolean hasSufficientOutputBufferFor(int inputSize)
{
int maxCompressedSize = Snappy.maxCompressedLength(inputSize);
return maxCompressedSize < outputBuffer.length - outputCursor - 4;
}
@ -225,31 +275,31 @@ public class SnappyOutputStream extends OutputStream {
/**
* Compress the raw byte array data.
*
* @param array array data of any type (e.g., byte[], float[], long[], ...)
* @param array array data of any type (e.g., byte[], float[], long[], ...)
* @param byteOffset
* @param byteLength
* @throws IOException
*/
public void rawWrite(Object array, int byteOffset, int byteLength) throws IOException {
if(inputCursor + byteLength < MIN_BLOCK_SIZE) {
// copy the input data to uncompressed buffer
Snappy.arrayCopy(array, byteOffset, byteLength, inputBuffer, inputCursor);
inputCursor += byteLength;
return;
public void rawWrite(Object array, int byteOffset, int byteLength)
throws IOException
{
if (closed) {
throw new IOException("Stream is closed");
}
compressInput();
for(int readBytes = 0; readBytes < byteLength; ) {
int inputLen = Math.min(blockSize, byteLength - readBytes);
if(!hasSufficientOutputBufferFor(inputLen)) {
dumpOutput();
int cursor = 0;
while (cursor < byteLength) {
int readLen = Math.min(byteLength - cursor, blockSize - inputCursor);
// copy the input data to uncompressed buffer
if (readLen > 0) {
Snappy.arrayCopy(array, byteOffset + cursor, readLen, inputBuffer, inputCursor);
inputCursor += readLen;
}
int compressedSize = Snappy.rawCompress(array, byteOffset + readBytes, inputLen, outputBuffer, outputCursor + 4);
writeInt(outputBuffer, outputCursor, compressedSize);
outputCursor += 4 + compressedSize;
readBytes += inputLen;
if (inputCursor < blockSize) {
return;
}
compressInput();
cursor += readLen;
}
}
@ -263,8 +313,13 @@ public class SnappyOutputStream extends OutputStream {
* @see java.io.OutputStream#write(int)
*/
@Override
public void write(int b) throws IOException {
if(inputCursor >= inputBuffer.length) {
public void write(int b)
throws IOException
{
if (closed) {
throw new IOException("Stream is closed");
}
if (inputCursor >= inputBuffer.length) {
compressInput();
}
inputBuffer[inputCursor++] = (byte) b;
@ -274,20 +329,27 @@ public class SnappyOutputStream extends OutputStream {
* @see java.io.OutputStream#flush()
*/
@Override
public void flush() throws IOException {
public void flush()
throws IOException
{
if (closed) {
throw new IOException("Stream is closed");
}
compressInput();
dumpOutput();
out.flush();
}
static void writeInt(byte[] dst, int offset, int v) {
static void writeInt(byte[] dst, int offset, int v)
{
dst[offset] = (byte) ((v >> 24) & 0xFF);
dst[offset + 1] = (byte) ((v >> 16) & 0xFF);
dst[offset + 2] = (byte) ((v >> 8) & 0xFF);
dst[offset + 3] = (byte) ((v >> 0) & 0xFF);
}
static int readInt(byte[] buffer, int pos) {
static int readInt(byte[] buffer, int pos)
{
int b1 = (buffer[pos] & 0xFF) << 24;
int b2 = (buffer[pos + 1] & 0xFF) << 16;
int b3 = (buffer[pos + 2] & 0xFF) << 8;
@ -295,22 +357,30 @@ public class SnappyOutputStream extends OutputStream {
return b1 | b2 | b3 | b4;
}
protected void dumpOutput() throws IOException {
if(outputCursor > 0) {
protected void dumpOutput()
throws IOException
{
if (outputCursor > 0) {
out.write(outputBuffer, 0, outputCursor);
outputCursor = 0;
}
}
protected void compressInput() throws IOException {
if(inputCursor <= 0) {
protected void compressInput()
throws IOException
{
if (!headerWritten) {
outputCursor = writeHeader();
headerWritten = true;
}
if (inputCursor <= 0) {
return; // no need to dump
}
// Compress and dump the buffer content
if(!hasSufficientOutputBufferFor(inputCursor)) {
if (!hasSufficientOutputBufferFor(inputCursor)) {
dumpOutput();
}
writeBlockPreemble();
int compressedSize = Snappy.compress(inputBuffer, 0, inputCursor, outputBuffer, outputCursor + 4);
// Write compressed data size
writeInt(outputBuffer, outputCursor, compressedSize);
@ -318,6 +388,24 @@ public class SnappyOutputStream extends OutputStream {
inputCursor = 0;
}
protected int writeHeader(){
return SnappyCodec.currentHeader.writeHeader(outputBuffer, 0);
}
/**
* Optionally write a preemble before a block. Hadoop requires the actual block data size being written. This base
* implementation does nothing. Derive implementation can call {@code writeCurrentDataSize()}.
*/
protected void writeBlockPreemble()
{
// do nothing
}
protected void writeCurrentDataSize(){
writeInt(outputBuffer, outputCursor, inputCursor);
outputCursor += 4;
}
/**
* close the stream
*/
@ -325,14 +413,22 @@ public class SnappyOutputStream extends OutputStream {
* @see java.io.OutputStream#close()
*/
@Override
public void close() throws IOException {
public void close()
throws IOException
{
if (closed) {
return;
}
try {
flush();
out.close();
} finally {
}
finally {
closed = true;
inputBufferAllocator.release(inputBuffer);
outputBufferAllocator.release(outputBuffer);
inputBuffer = null;
outputBuffer = null;
}
}
}

View File

@ -1,2 +0,0 @@
VERSION=1.1.1

View File

@ -3,9 +3,10 @@ package org.xerial.snappy.buffer;
/**
* BufferAllocator interface. The implementation of this interface must be thread-safe
*/
public interface BufferAllocator {
public interface BufferAllocator
{
public byte[] allocate(int size);
public void release(byte[] buffer);
public void release(byte[] buffer);
}

View File

@ -3,7 +3,8 @@ package org.xerial.snappy.buffer;
/**
*
*/
public interface BufferAllocatorFactory {
public interface BufferAllocatorFactory
{
BufferAllocator getBufferAllocator(int minSize);
}

View File

@ -6,29 +6,45 @@ import java.util.*;
/**
* Cached buffer
*/
public class CachedBufferAllocator implements BufferAllocator {
public static BufferAllocatorFactory factory = new BufferAllocatorFactory() {
public class CachedBufferAllocator
implements BufferAllocator
{
private static BufferAllocatorFactory factory = new BufferAllocatorFactory()
{
@Override
public BufferAllocator getBufferAllocator(int bufferSize) {
public BufferAllocator getBufferAllocator(int bufferSize)
{
return CachedBufferAllocator.getAllocator(bufferSize);
}
};
public static void setBufferAllocatorFactory(BufferAllocatorFactory factory)
{
assert (factory != null);
CachedBufferAllocator.factory = factory;
}
public static BufferAllocatorFactory getBufferAllocatorFactory()
{
return factory;
}
/**
* Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances
*/
public static Map<Integer, SoftReference<CachedBufferAllocator>> queueTable = new HashMap<Integer, SoftReference<CachedBufferAllocator>>();
private static final Map<Integer, SoftReference<CachedBufferAllocator>> queueTable = new HashMap<Integer, SoftReference<CachedBufferAllocator>>();
private final int bufferSize;
private final Deque<byte[]> bufferQueue;
public CachedBufferAllocator(int bufferSize) {
public CachedBufferAllocator(int bufferSize)
{
this.bufferSize = bufferSize;
this.bufferQueue = new ArrayDeque<byte[]>();
}
public static synchronized CachedBufferAllocator getAllocator(int bufferSize) {
public static synchronized CachedBufferAllocator getAllocator(int bufferSize)
{
CachedBufferAllocator result = null;
if (queueTable.containsKey(bufferSize)) {
@ -42,9 +58,10 @@ public class CachedBufferAllocator implements BufferAllocator {
}
@Override
public byte[] allocate(int size) {
synchronized(this) {
if(bufferQueue.isEmpty()) {
public byte[] allocate(int size)
{
synchronized (this) {
if (bufferQueue.isEmpty()) {
return new byte[size];
}
else {
@ -52,9 +69,11 @@ public class CachedBufferAllocator implements BufferAllocator {
}
}
}
@Override
public void release(byte[] buffer) {
synchronized(this) {
public void release(byte[] buffer)
{
synchronized (this) {
bufferQueue.addLast(buffer);
}
}

View File

@ -3,24 +3,30 @@ package org.xerial.snappy.buffer;
/**
* Simple buffer allocator, which does not reuse the allocated buffer
*/
public class DefaultBufferAllocator implements BufferAllocator {
public class DefaultBufferAllocator
implements BufferAllocator
{
public static BufferAllocatorFactory factory = new BufferAllocatorFactory() {
public static BufferAllocatorFactory factory = new BufferAllocatorFactory()
{
public BufferAllocator singleton = new DefaultBufferAllocator();
@Override
public BufferAllocator getBufferAllocator(int bufferSize) {
public BufferAllocator getBufferAllocator(int bufferSize)
{
return singleton;
}
};
@Override
public byte[] allocate(int size) {
public byte[] allocate(int size)
{
return new byte[size];
}
@Override
public void release(byte[] buffer) {
public void release(byte[] buffer)
{
// do nothing
}
}

View File

@ -1,44 +1,44 @@
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
/**
* Snappy API for compressing/decompressing data.
*
* Usage
* First, import {@link org.xerial.snappy.Snappy} in your Java code:
* <code>
* <pre>
* import org.xerial.snappy.Snappy;
* </pre>
* </code>
* Then use {@link org.xerial.snappy.Snappy#compress(byte[])} and {@link org.xerial.snappy.Snappy#uncompress(byte[])}:
* <code>
* <pre>
* String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.";
* byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
* byte[] uncompressed = Snappy.uncompress(compressed);
* String result = new String(uncompressed, "UTF-8");
* System.out.println(result);
* </pre>
* </code>
*
* <p>In addition, high-level methods (Snappy.compress(String), Snappy.compress(float[] ..) etc. ) and low-level ones (e.g. Snappy.rawCompress(.. ), Snappy.rawUncompress(..), etc.), which minimize memory copies, can be used. </p>
*
* <h3>Stream-based API</h3>
* Stream-based compressor/decompressor SnappyOutputStream, SnappyInputStream are also available for reading/writing large data sets.
*/
package org.xerial.snappy;
/*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
/**
* Snappy API for compressing/decompressing data.
* <p/>
* Usage
* First, import {@link org.xerial.snappy.Snappy} in your Java code:
* <code>
* <pre>
* import org.xerial.snappy.Snappy;
* </pre>
* </code>
* Then use {@link org.xerial.snappy.Snappy#compress(byte[])} and {@link org.xerial.snappy.Snappy#uncompress(byte[])}:
* <code>
* <pre>
* String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.";
* byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
* byte[] uncompressed = Snappy.uncompress(compressed);
* String result = new String(uncompressed, "UTF-8");
* System.out.println(result);
* </pre>
* </code>
* <p/>
* <p>In addition, high-level methods (Snappy.compress(String), Snappy.compress(float[] ..) etc. ) and low-level ones (e.g. Snappy.rawCompress(.. ), Snappy.rawUncompress(..), etc.), which minimize memory copies, can be used. </p>
* <p/>
* <h3>Stream-based API</h3>
* Stream-based compressor/decompressor SnappyOutputStream, SnappyInputStream are also available for reading/writing large data sets.
*/
package org.xerial.snappy;

View File

@ -0,0 +1,53 @@
package org.xerial.snappy.pool;
import java.nio.ByteBuffer;
/**
* Makes various types of buffers available for use and potential re-use.
*
* <p>
* Implementations must be safe for concurrent use by multiple threads.
* </p>
*
* @author Brett Okken
*/
public interface BufferPool {
/**
* Returns a {@code byte[]} of <i>size</i> or greater length.
* @param size The minimum size array required. Must be {@code >= 0}.
* @return A {@code byte[]} with length of at least <i>size</i>.
* @see #releaseArray(byte[])
*/
public byte[] allocateArray(int size);
/**
* Returns instance to pool for potential future reuse.
* <p>
* Must not be returned more than 1 time. Must not be used by caller after return.
* </p>
* @param buffer Instance to return to pool. Must not be {@code null}.
* Must not be returned more than 1 time. Must not be used by caller after return.
*/
public void releaseArray(byte[] buffer);
/**
* Returns a {@link ByteBuffer#allocateDirect(int) direct ByteBuffer} of <i>size</i> or
* greater {@link ByteBuffer#capacity() capacity}.
* @param size The minimum size buffer required. Must be {@code >= 0}.
* @return A {@code ByteBuffer} of <i>size</i> or greater {@link ByteBuffer#capacity() capacity}.
* @see #releaseDirect(ByteBuffer)
* @see ByteBuffer#allocateDirect(int)
*/
public ByteBuffer allocateDirect(int size);
/**
* Returns instance to pool for potential future reuse.
* <p>
* Must not be returned more than 1 time. Must not be used by caller after return.
* </p>
* @param buffer Instance to return to pool. Must not be {@code null}.
* Must not be returned more than 1 time. Must not be used by caller after return.
*/
public void releaseDirect(ByteBuffer buffer);
}

View File

@ -0,0 +1,216 @@
package org.xerial.snappy.pool;
import java.lang.ref.SoftReference;
import java.nio.ByteBuffer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentMap;
/**
* A {@link BufferPool} implementation which caches values at fixed sizes.
* <p>
* Pooled instances are held as {@link SoftReference} to allow GC if necessary.
* </p>
* <p>
* The current fixed sizes are calculated as follows:
* <ul>
* <li>Values < 4KB return 4KB</li>
* <li>4KB - 32KB to 2KB</li>
* <li>32KB - 512KB to 16KB</li>
* <li>512KB - 2MB to 128KB</li>
* <li>2MB - 16MB to 512KB</li>
* <li>16MB - 128MB to 4MB</li>
* <li>128MB - 512MB to 16MB</li>
* <li>512MB - 1.5 GB to 128MB</li>
* <li>Values > 1.5GB return {@link Integer#MAX_VALUE}</li>
* </ul>
* </p>
* @author Brett Okken
*/
public final class CachingBufferPool implements BufferPool {
private static interface IntFunction<E> {
public E create(int size);
}
private static final IntFunction<byte[]> ARRAY_FUNCTION = new IntFunction<byte[]>() {
@Override
public byte[] create(int size) {
return new byte[size];
}
};
private static final IntFunction<ByteBuffer> DBB_FUNCTION = new IntFunction<ByteBuffer>() {
@Override
public ByteBuffer create(int size) {
return ByteBuffer.allocateDirect(size);
}
};
private static final CachingBufferPool INSTANCE = new CachingBufferPool();
private final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<byte[]>>> bytes = new ConcurrentHashMap<>();
private final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<ByteBuffer>>> buffers = new ConcurrentHashMap<>();
private CachingBufferPool() {
}
/**
* Returns instance of {@link CachingBufferPool} for using cached buffers.
* @return instance of {@link CachingBufferPool} for using cached buffers.
*/
public static BufferPool getInstance() {
return INSTANCE;
}
/**
* {@inheritDoc}
*/
@Override
public byte[] allocateArray(int size) {
if (size <= 0) {
throw new IllegalArgumentException("size is invalid: " + size);
}
return getOrCreate(size, bytes, ARRAY_FUNCTION);
}
/**
* {@inheritDoc}
*/
@Override
public void releaseArray(byte[] buffer) {
if (buffer == null) {
throw new IllegalArgumentException("buffer is null");
}
returnValue(buffer, buffer.length, bytes);
}
/**
* {@inheritDoc}
*/
@Override
public ByteBuffer allocateDirect(int size) {
if (size <= 0) {
throw new IllegalArgumentException("size is invalid: " + size);
}
return getOrCreate(size, buffers, DBB_FUNCTION);
}
/**
* {@inheritDoc}
*/
@Override
public void releaseDirect(ByteBuffer buffer) {
if (buffer == null) {
throw new IllegalArgumentException("buffer is null");
}
buffer.clear();
returnValue(buffer, buffer.capacity(), buffers);
}
private static <E> E getOrCreate(final int size, final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map, final IntFunction<E> creator) {
assert size > 0;
final int adjustedSize = adjustSize(size);
final ConcurrentLinkedDeque<SoftReference<E>> queue = optimisticGetEntry(adjustedSize, map);
SoftReference<E> entry;
while ((entry = queue.pollFirst()) != null) {
final E val = entry.get();
if (val != null) {
return val;
}
}
return creator.create(adjustedSize);
}
/*
* This is package scope to allow direct unit testing.
*/
static int adjustSize(int size) {
assert size > 0;
switch (Integer.numberOfLeadingZeros(size)) {
case 1: // 1GB - 2GB
case 2: // 512MB
//if 512MB - 1.5 GB round to nearest 128 MB (2^27), else Integer.MAX_VALUE
return size <= 0x6000_0000 ? roundToPowers(size, 27) : Integer.MAX_VALUE;
case 3: //256MB
case 4: //128MB
//if 128MB - 512MB, round to nearest 16 MB
return roundToPowers(size, 24);
case 5: // 64MB
case 6: // 32MB
case 7: // 16MB
//if 16MB - 128MB, round to nearest 4MB
return roundToPowers(size, 22);
case 8: // 8MB
case 9: // 4MB
case 10: // 2MB
//if 2MB - 16MB, round to nearest 512KB
return roundToPowers(size, 19);
case 11: // 1MB
case 12: //512KB
//if 512KB - 2MB, round to nearest 128KB
return roundToPowers(size, 17);
case 13: //256KB
case 14: //128KB
case 15: // 64KB
case 16: // 32KB
//if 32KB to 512KB, round to nearest 16KB
return roundToPowers(size, 14);
case 17: // 16KB
case 18: // 8KB
case 19: // 4KB
// if 4KB - 32KB, round to nearest 2KB
return roundToPowers(size, 11);
default:
return 4 * 1024;
}
}
private static int roundToPowers(int number, int bits) {
final int mask = (0x7FFF_FFFF >> bits) << bits;
final int floor = number & mask;
return floor == number ? number : floor + (1 << bits);
}
private static <E> ConcurrentLinkedDeque<SoftReference<E>> optimisticGetEntry(Integer key, ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map) {
ConcurrentLinkedDeque<SoftReference<E>> val = map.get(key);
if (val == null) {
map.putIfAbsent(key, new ConcurrentLinkedDeque<SoftReference<E>>());
val = map.get(key);
}
return val;
}
private static <E> void returnValue(E value, Integer size, ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map) {
final ConcurrentLinkedDeque<SoftReference<E>> queue = map.get(size);
//no queue will exist if buffer was not originally obtained from this class
if (queue != null) {
//push this value onto deque first so that concurrent request can use it
queue.addFirst(new SoftReference<E>(value));
//purge oldest entries have lost references
SoftReference<E> entry;
boolean lastEmpty = true;
while(lastEmpty && (entry = queue.peekLast()) != null) {
if (entry.get() == null) {
queue.removeLastOccurrence(entry);
} else {
lastEmpty = false;
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "CachingBufferPool [bytes=" + this.bytes + ", buffers=" + this.buffers + "]";
}
}

View File

@ -0,0 +1,37 @@
package org.xerial.snappy.pool;
/**
* Manages implementation of {@link BufferPool} to use by default. Setting the system property {@link #DISABLE_CACHING_PROPERTY} to {@code true} will
* cause the {@link QuiescentBufferPool} to be used by default. Otherwise, {@link CachingBufferPool} will be used by default.
* {@link #setDefaultPool(BufferPool)} can be used to explicitly control the implementation to use.
*/
public final class DefaultPoolFactory {
/**
* Name of system property to disable use of {@link CachingBufferPool} by default.
*/
public static final String DISABLE_CACHING_PROPERTY = "org.xerial.snappy.pool.disable";
private static volatile BufferPool defaultPool = "true".equalsIgnoreCase(System.getProperty(DISABLE_CACHING_PROPERTY))
? QuiescentBufferPool.getInstance()
: CachingBufferPool.getInstance();
/**
* @return The default instance to use.
*/
public static BufferPool getDefaultPool() {
return defaultPool;
}
/**
* Sets the default instance to use.
* @param pool The default instance to use. Must not be {@code null}.
* @see #getDefaultPool()
*/
public static void setDefaultPool(BufferPool pool) {
if (pool == null) {
throw new IllegalArgumentException("pool is null");
}
defaultPool = pool;
}
}

View File

@ -0,0 +1,150 @@
package org.xerial.snappy.pool;
import static java.lang.invoke.MethodHandles.constant;
import static java.lang.invoke.MethodHandles.dropArguments;
import static java.lang.invoke.MethodHandles.filterReturnValue;
import static java.lang.invoke.MethodHandles.guardWithTest;
import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Utility to facilitate disposing of direct byte buffer instances.
*/
final class DirectByteBuffers {
/**
* Sun specific mechanisms to clean up resources associated with direct byte buffers.
*/
@SuppressWarnings("unchecked")
static final Class<? extends ByteBuffer> DIRECT_BUFFER_CLAZZ = (Class<? extends ByteBuffer>) lookupClassQuietly("java.nio.DirectByteBuffer");
static final MethodHandle CLEAN_HANDLE;
static {
// this approach is based off that used by apache lucene and documented here: https://issues.apache.org/jira/browse/LUCENE-6989
// and https://github.com/apache/lucene-solr/blob/7e03427fa14a024ce257babcb8362d2451941e21/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
MethodHandle cleanHandle = null;
try {
final PrivilegedExceptionAction<MethodHandle> action = new PrivilegedExceptionAction<MethodHandle>() {
@Override
public MethodHandle run() throws Exception {
MethodHandle handle = null;
if (DIRECT_BUFFER_CLAZZ != null) {
final Lookup lookup = lookup();
try {
// sun.misc.Unsafe unmapping (Java 9+)
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
// first check if Unsafe has the right method, otherwise we can give up
// without doing any security critical stuff:
final MethodHandle unmapper = lookup.findVirtual(unsafeClass, "invokeCleaner", methodType(void.class, ByteBuffer.class));
// fetch the unsafe instance and bind it to the virtual MH:
final Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object theUnsafe = f.get(null);
handle = unmapper.bindTo(theUnsafe);
} catch (Exception e) {
Logger.getLogger(DirectByteBuffers.class.getName()).log(Level.FINE, "unable to use java 9 Unsafe.invokeCleaner", e);
// sun.misc.Cleaner unmapping (Java 8 and older)
final Method m = DIRECT_BUFFER_CLAZZ.getMethod("cleaner");
m.setAccessible(true);
final MethodHandle directBufferCleanerMethod = lookup.unreflect(m);
final Class<?> cleanerClass = directBufferCleanerMethod.type().returnType();
/*
* "Compile" a MethodHandle that basically is equivalent to the following code:
* void unmapper(ByteBuffer byteBuffer)
* {
* sun.misc.Cleaner cleaner = ((java.nio.DirectByteBuffer) byteBuffer).cleaner();
* if (nonNull(cleaner))
* {
* cleaner.clean();
* }
* else
* {
* // the noop is needed because MethodHandles#guardWithTest always needs ELSE
* noop(cleaner);
* }
* }
*/
final MethodHandle cleanMethod = lookup.findVirtual(cleanerClass, "clean", methodType(void.class));
final MethodHandle nonNullTest = lookup.findStatic(DirectByteBuffers.class, "nonNull", methodType(boolean.class, Object.class)).asType(methodType(boolean.class, cleanerClass));
final MethodHandle noop = dropArguments(constant(Void.class, null).asType(methodType(void.class)), 0, cleanerClass);
handle = filterReturnValue(directBufferCleanerMethod, guardWithTest(nonNullTest, cleanMethod, noop)).asType(methodType(void.class, ByteBuffer.class));
}
}
return handle;
}
};
cleanHandle = AccessController.doPrivileged(action);
} catch (Throwable t) {
Logger.getLogger(DirectByteBuffers.class.getName()).log(Level.FINE, "Exception occurred attempting to lookup Sun specific DirectByteBuffer cleaner classes.", t);
}
CLEAN_HANDLE = cleanHandle;
}
private static Class<?> lookupClassQuietly(String name)
{
try {
return DirectByteBuffers.class.getClassLoader().loadClass(name);
}
catch (Throwable t) {
Logger.getLogger(DirectByteBuffers.class.getName()).log(Level.FINE, "Did not find requested class: " + name, t);
}
return null;
}
static boolean nonNull(Object o) {
return o != null;
}
/**
* Provides jvm implementation specific operation to aggressively release resources associated with <i>buffer</i>.
*
* @param buffer The {@code ByteBuffer} to release. Must not be {@code null}. Must be {@link ByteBuffer#isDirect() direct}.
*/
public static void releaseDirectByteBuffer(final ByteBuffer buffer)
{
assert buffer != null && buffer.isDirect();
if (CLEAN_HANDLE != null && DIRECT_BUFFER_CLAZZ.isInstance(buffer)) {
try {
final PrivilegedExceptionAction<Void> pea = new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try {
CLEAN_HANDLE.invokeExact(buffer);
} catch (Exception e) {
throw e;
} catch (Throwable t) {
//this will be an error
throw new RuntimeException(t);
}
return null;
}
};
AccessController.doPrivileged(pea);
} catch (Throwable t) {
Logger.getLogger(DirectByteBuffers.class.getName()).log(Level.FINE, "Exception occurred attempting to clean up Sun specific DirectByteBuffer.", t);
}
}
}
}

View File

@ -0,0 +1,55 @@
package org.xerial.snappy.pool;
import java.nio.ByteBuffer;
/**
* A {@link BufferPool} implementation which does no pooling. New instances will be created for each call to allocate.
* @author Brett Okken
*/
public final class QuiescentBufferPool implements BufferPool {
private static final QuiescentBufferPool INSTANCE = new QuiescentBufferPool();
private QuiescentBufferPool() {
}
/**
* @return Instance of {@link BufferPool} which does no caching/reuse of instances.
*/
public static BufferPool getInstance() {
return INSTANCE;
}
/**
* Creates a new {@code byte[]} of <i>size</i>.
*/
@Override
public byte[] allocateArray(int size) {
return new byte[size];
}
/**
* Does nothing.
*/
@Override
public void releaseArray(byte[] buffer) {
}
/**
* {@link ByteBuffer#allocateDirect(int) Allocates} a direct {@link ByteBuffer} of <i>size</i>.
*/
@Override
public ByteBuffer allocateDirect(int size) {
return ByteBuffer.allocateDirect(size);
}
/**
* Aggressively releases native resources associated with <i>buffer</i>.
*/
@Override
public void releaseDirect(ByteBuffer buffer) {
assert buffer != null && buffer.isDirect();
DirectByteBuffers.releaseDirectByteBuffer(buffer);
}
}

View File

@ -0,0 +1,11 @@
{
"resources": {
"includes": [
{"pattern":".*libsnappyjava.dylib"},
{"pattern":".*libsnappyjava.so"},
{"pattern":".*snappyjava.dll"},
{"pattern":".*libsnappyjava.a"}
]
},
"bundles": []
}

View File

@ -0,0 +1,2 @@
SNAPPY_VERSION=1.1.10
BITSHUFFLE_VERSION=0.3.4

Some files were not shown because too many files have changed in this diff Show More