![KryoNet](https://raw.github.com/wiki/EsotericSoftware/kryo/images/logo.jpg)
[![Build Status](https://jenkins.inoio.de/buildStatus/icon?job=kryo)](https://jenkins.inoio.de/job/kryo/)
Kryo is a fast and efficient object graph serialization framework for Java. The goals of the project are speed, efficiency, and an easy to use API. The project is useful any time objects need to be persisted, whether to a file, database, or over the network.
Kryo can also perform automatic deep and shallow copying/cloning. This is direct copying from object to object, not object->bytes->object.
This documentation is for v2+ of Kryo. See [V1Documentation](https://github.com/EsotericSoftware/kryo/wiki/Documentation-for-Kryo-version-1.x) for v1.x.
If you are planning to use Kryo for network communication, the [KryoNet](https://github.com/EsotericSoftware/kryonet) project may prove useful.
## Contents
- [New in release 3.0.0](#new-in-release-300)
- [Installation](#installation)
- [Integration with Maven](#integration-with-maven)
- [Using Kryo without Maven](#using-kryo-without-maven)
- [Quickstart](#quickstart)
- [IO](#io)
- [Unsafe-based IO](#unsafe-based-io)
- [Serializers](#serializers)
- [Registration](#registration)
- [Default serializers](#default-serializers)
- [FieldSerializer](#fieldserializer)
- [KryoSerializable](#kryoserializable)
- [Class fields annotations](#class-fields-annotations)
- [Java Serialization](#using-standard-java-serialization)
- [Reading and writing](#reading-and-writing)
- [References](#references)
- [Object creation](#object-creation)
- [Copying/cloning](#copyingcloning)
- [Context](#context)
- [Compression and encryption](#compression-and-encryption)
- [Chunked encoding](#chunked-encoding)
- [Compatibility](#compatibility)
- [Interoperability](#interoperability)
- [Stack size](#stack-size)
- [Threading](#threading)
- [Pooling Kryo instances](#pooling-kryo-instances)
- [Logging](#logging)
- [Scala](#scala)
- [Objective-C](#objective-c)
- [Benchmarks](#benchmarks)
- [Projects using Kryo](#projects-using-kryo)
- [Contact / Mailing list](#contact--mailing-list)
## New in release 3.0.0
The 3.0.0 release fixes many reported issues and improves stability and performance. The maven groupId is changed from `com.esotericsoftware.kryo` to `com.esotericsoftware`. The Unsafe-based IO serialization format was changed and is incompatible with previous versions (therefore the new major version), the standard serialization format is still compatible.
See [ChangeLog](https://github.com/EsotericSoftware/kryo/blob/master/CHANGES.md) for more details about this release.
## Installation
Kryo JARs are available on the [releases page](https://github.com/EsotericSoftware/kryo/releases) and at [Maven Central](http://search.maven.org/#browse|1975274176). Latest snapshots of Kryo including snapshot builds of master are in the [Sonatype Repository](https://oss.sonatype.org/content/repositories/snapshots/com/esotericsoftware/kryo/kryo).
### Integration with Maven
To use the official release of Kryo, please use the following snippet in your pom.xml
```xml
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>3.0.1</version>
</dependency>
```
If you experience issues because you already have a different version of asm in your classpath, you can use the kryo-shaded jar which has its version of asm included, relocated in a different package:
```xml
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
<version>3.0.1</version>
</dependency>
```
If you want to test the latest snapshot of Kryo, please use the following snippet in your pom.xml
```xml
<repository>
<id>sonatype-snapshots</id>
<name>sonatype snapshots repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>3.0.1-SNAPSHOT</version>
</dependency>
```
### Using Kryo without Maven
If you use Kryo without Maven, be aware that Kryo jar file has a couple of external dependencies, whose JARs you need to add to your classpath as well. These dependencies are [MinLog logging library](https://github.com/EsotericSoftware/minlog/) and [Objenesis library](https://code.google.com/p/objenesis/).
## Quickstart
Jumping ahead to show how the library is used:
```java
Kryo kryo = new Kryo();
// ...
Output output = new Output(new FileOutputStream("file.bin"));
SomeClass someObject = ...
kryo.writeObject(output, someObject);
output.close();
// ...
Input input = new Input(new FileInputStream("file.bin"));
SomeClass someObject = kryo.readObject(input, SomeClass.class);
input.close();
```
The Kryo class orchestrates serialization. The Output and Input classes handle buffering bytes and optionally flushing to a stream.
The rest of this document details how this works and advanced usage of the library.
## IO
The Output class is an OutputStream that writes data to a byte array buffer. This buffer can be obtained and used directly, if a byte array is desired. If the Output is given an OutputStream, it will flush the bytes to the stream when the buffer becomes full. Output has many methods for efficiently writing primitives and strings to bytes. It provides functionality similar to DataOutputStream, BufferedOutputStream, FilterOutputStream, and ByteArrayOutputStream.
Because Output buffers when writing to an OutputStream, be sure to call `flush()` or `close()` after writing is complete so the buffered bytes are written to the underlying stream.
The Input class is an InputStream that reads data from a byte array buffer. This buffer can be set directly, if reading from a byte array is desired. If the Input is given an InputStream, it will fill the buffer from the stream when the buffer is exhausted. Input has many methods for efficiently reading primitives and strings from bytes. It provides functionality similar to DataInputStream, BufferedInputStream, FilterInputStream, and ByteArrayInputStream.
To read from a source or write to a target other than a byte array, simply provide the appropriate InputStream or OutputStream.
## Unsafe-based IO
Kryo provides additional IO classes, which are based on the functionalities exposed by the sun.misc.Unsafe class. These classes are UnsafeInput, UnsafeOutput. They are derived from Kryo's Input and Output classes and therefore can be used as a drop-in replacement on those platforms, which properly support sun.misc.Unsafe.
For the case you need to serialize to or deserialize from direct-memory ByteBuffers or even off-heap memory, there are two dedicated classes UnsafeMemoryInput and UnsafeMemoryOutput whose instances can be used for this purpose instead of the usual Input and Output classes.
Using Unsafe-based IO may result in a quite significant performance boost (sometimes up-to an order of magnitude), depending on your application. In particular, it helps a lot when serializing large primitive arrays as part of your object graphs.
### ** DISCLAIMER ABOUT USING UNSAFE-BASED IO **
*Unsafe-based IO is not 100% compatible with Kryo's Input and Output streams when it comes to the binary format of serialized data.*
This means that data written by Unsafe-based output streams can be read only by Unsafe-based input streams, but not by usual Input streams. The same applies on the opposite direction: data written by usual Output streams cannot be correctly read by Unsafe-based input streams.
It should be safe to use Unsafe IO streams as long as both serialization and deserialization are using them and are executed on the same processor architecture (more precisely, if the endianness and internal representation of native integer and floating point types is the same).
Unsafe IO was extensively tested on X86 hardwar
没有合适的资源?快使用搜索试试~ 我知道了~
bazel-0.11.1.tar_3.gz
0 下载量 97 浏览量
2024-04-06
10:27:35
上传
评论
收藏 71.54MB GZ 举报
温馨提示
Bazel 是一个多语言、开源的构建工具,旨在支持大型软件项目的自动化构建和测试。Bazel 的设计理念着重于提高构建的速度和可靠性,同时支持多平台构建。它支持多种编程语言,包括但不限于 Java、C++、Python 和 Go。Bazel 使用一种名为 BUILD 的高级构建语言来描述项目的构建过程,使得构建配置既灵活又易于理解。 Bazel 的核心特性之一是其强大的依赖分析和管理能力。通过精确地跟踪项目中每个组件的依赖关系,Bazel 能够确保构建的增量性和确定性。这意味着当源代码发生变化时,Bazel 只会重新构建受到影响的部分,从而显著提高构建效率。此外,Bazel 支持远程缓存,允许跨多个构建共享部分构建结果,进一步加速构建过程。 Bazel 还特别注重于构建的可重复性。通过将构建环境封装化,Bazel 确保了构建过程不会受到外部环境的影响,从而使得构建结果在不同环境中是一致的。这一点对于确保软件质量和便于问题追踪尤为重要。
资源推荐
资源详情
资源评论
收起资源包目录
bazel-0.11.1.tar_3.gz (2000个子文件)
StdRedirect.c 3KB
realpath.c 3KB
dummy.c 1KB
dummy-sandbox.c 1022B
docs_style.css 685B
zip_headers.h 23KB
transient_bytes.h 11KB
input_jar_scan_entries_test.h 9KB
token_stream.h 8KB
launcher.h 5KB
output_jar.h 5KB
combiners.h 4KB
util.h 4KB
java_launcher.h 4KB
file.h 4KB
desugar_checking.h 4KB
unix_jni.h 3KB
mapped_file.h 3KB
launcher_util.h 3KB
zlib_interface.h 3KB
input_jar.h 3KB
options.h 3KB
process-tools.h 2KB
linux-sandbox-options.h 2KB
test_util.h 2KB
process-wrapper-legacy.h 2KB
logging.h 2KB
test_util.h 2KB
data_parser.h 2KB
process-wrapper-options.h 1KB
macros.h 1KB
windows_test_util.h 1KB
python_launcher.h 1KB
bash_launcher.h 1KB
diag.h 1KB
jni-util.h 964B
BlazeFramework.h 883B
linux-sandbox.h 763B
linux-sandbox-pid1.h 752B
process-wrapper.h 708B
Multiplier.h 707B
user-manual.html 165KB
query.html 56KB
build-ref.html 34KB
test-encyclopedia.html 22KB
documentation.html 14KB
command-line-reference-prefix.html 5KB
footer.html 3KB
header.html 2KB
footer-content.html 2KB
head.html 1KB
search.html 496B
default.html 417B
redirect.html 137B
command-line-reference-suffix.html 23B
MemoizingEvaluatorTest.java 204KB
AndroidBinaryTest.java 174KB
ObjcRuleTestCase.java 153KB
ParallelEvaluatorTest.java 99KB
SkylarkDefinedAspectsTest.java 95KB
SkylarkRuleContextTest.java 82KB
SkylarkRuleImplementationFunctionsTest.java 82KB
OptionsParserTest.java 79KB
BuildViewTestCase.java 79KB
AndroidLibraryTest.java 79KB
ObjcLibraryTest.java 75KB
BlazeOptionHandlerTest.java 71KB
JavaSkylarkApiTest.java 66KB
FileFunctionTest.java 64KB
CcToolchainFeaturesTest.java 64KB
SkylarkIntegrationTest.java 62KB
SkylarkRuleClassFunctionsTest.java 60KB
AppleBinaryTest.java 60KB
AndroidDataMergerTest.java 57KB
BuildViewTest.java 57KB
DataResourceXmlTest.java 53KB
SkylarkEvaluationTest.java 52KB
ConstraintsTest.java 52KB
ParserTest.java 52KB
CcLibraryConfiguredTargetTest.java 52KB
ObjcSkylarkTest.java 50KB
TreeArtifactBuildTest.java 50KB
CrosstoolConfigurationLoaderTest.java 49KB
ExperimentalStateTrackerTest.java 48KB
FileSystemTest.java 46KB
FilesetEntryFunctionTest.java 45KB
TargetPatternEvaluatorTest.java 45KB
PackageFactoryTest.java 44KB
BazelJ2ObjcLibraryTest.java 43KB
ConfigurableAttributesTest.java 43KB
MethodLibraryTest.java 43KB
JavacTurbineTest.java 42KB
ConfigSettingTest.java 42KB
RuleClassTest.java 41KB
CcCommonTest.java 39KB
RecursiveFilesystemTraversalFunctionTest.java 38KB
GrpcRemoteExecutionClientTest.java 38KB
BuildEventStreamerTest.java 38KB
FilesystemValueCheckerTest.java 37KB
Desugar.java 36KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
程序员Chino的日记
- 粉丝: 3708
- 资源: 5万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- metrics-server:0.6.1镜像包
- 自动化测试相关技术文档
- 瓶罐分类84-YOLO(v5至v9)、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 基于ssm的阅微文学网站的设计与开发源代码(java+vue+mysql+说明文档+LW).zip
- 基于ssm的社区医疗保健监控系统源代码(java+vue+mysql+说明文档+LW).zip
- 基于ssm的校园闲置物品交易平台源代码(java+jsp+mysql+说明文档+LW).zip
- SVID_20241217_195814_1.mp4
- PenTablet_5.2.4-5.zip
- 这是此文章所使用的sql
- 瓶子瓶罐子检测4-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功