| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

Scala数据序列化:Scalavro

Scalavro 是一个使用反射技术实现的 Avro 库。

Avro是一个数据序列化系统,设计用于支持大 批量数据交换的应用。它的主要特点有:支持二进制序列化方式,可以便捷,快速地处理大量数据;动态语言友好,Avro提供的机制使动态语言可以方便地处理 Avro数据。

Apache Avro ™ is a data serialization system.

Avro provides:

  • Rich data structures.
  • A compact, fast, binary data format.
  • A container file, to store persistent data.
  • Remote procedure call (RPC).
  • Simple integration with dynamic languages. Code generation is not required to read or write data files nor to use or implement RPC protocols. Code generation as an optional optimization, only worth implementing for statically typed languages.

示例代码:

import com.gensler.scalavro.types.AvroType  import scala.util.{ Try, Success, Failure }    // obtaining an instance of AvroType  val intSeqType = AvroType[Seq[Int]]    // obtaining an Avro schema for a given AvroType  intSeqType.schema    // obtaining an AvroTypeIO object for a given AvroType (via the `io` method)  val io: AvroTypeIO[Seq[Int]] = intSeqType.io    // binary I/O  io.write(Seq(1, 2, 3), outputStream)  val Sucess(readResult) = io read inputStream    // json I/O  val json = io writeJson Seq(1, 2, 3) // [1,2,3]  val Success(readResult) = io readJson json

项目主页:http://www.open-open.com/lib/view/home/1385260701432

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1385260701432.html
Scalavro Scala开发