Scalavro- Scala数据序列化
Scala 其他开发相关
共0Star
详细介绍
Scalavro 是一个使用反射技术实现的 Avro 库。
Avro是一个数据序列化系统,设计用于支持大
批量数据交换的应用。它的主要特点有:支持二进制序列化方式,可以便捷,快速地处理大量数据;动态语言友好,Avro提供的机制使动态语言可以方便地处理
Avro数据。
示例代码:
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
-
0 Star
-
1933 Star
-
120 Star
-
0 Star
-
144 Star
-
0 Star
-
0 Star
-
1 Star
-
41 Star
-
0 Star