Questions tagged [scalapb]

ScalaPB is a protocol buffer compiler (protoc) plugin for Scala. It generates Scala case classes, parsers and serializers for protocol buffers.

Main features:

Built on top of Google’s protocol buffer compiler to ensure perfect compatibility with the language specification.

Nested updates are easy by using lenses:

val newOrder = order.update(_.creditCard.expirationYear := 2015)

Generated case classes can co-exist alongside the Java-generated code (the class names will not clash). This allows gradual transition from Java to Scala.

Can optionally generate conversion methods between the Java generated version of Protocol Buffers to the Scala generated version. This makes it possible to migrate your project gradually.

Supports for Oneof’s that were introduced in Protocol Buffers 2.6.0.

Learn more here: https://scalapb.github.io/index.html

Source code: https://github.com/scalapb/ScalaPB

104 questions
0
votes
1 answer

Set file-level option to scalapb project

I'm using ScalaPB (version 0.11.1) and plugin sbt-protoc (version 1.0.3) to try to compile an old project with ProtocolBuffers in Scala 2.12. Reading the documentation, I want to set the file property preserve_unknown_fields to false. But my…
0
votes
1 answer

Spark unmarshal proto bytes into readable format

My Spark application receives binary data from Kafka. The data is sent as a byte proto message to Kafka. The proto message is: message Any { string type_url=1; bytes value=2; } With the ScalaPB Library I can deserialize the Any message to its…
0
votes
1 answer

How to define Compile settings in sbt multi-project?

I'm trying to configure a new Scala build using sbt multi-project. I want to use sbt-protoc and in particular ScalaPB which requires this configuration setting: Compile / PB.targets := Seq( scalapb.gen() -> (Compile / sourceManaged).value ) Now…
sentenza
  • 1,608
  • 3
  • 29
  • 51
0
votes
1 answer

How to generate validators file only for message that contains validate rules?

How to generate validator file only for message that contains validates rules ? In the example below, actually sbt compilation generates 4 scala classes: one for protobufA, one for protobufB and one validator message for both. int32 id = 1; …
FTK
  • 43
  • 4
0
votes
0 answers

How to solve problem with compile protobuf in scala project on Windows10?

I have simple code with example protobuf on scala proto file syntax = "proto3"; package grpc.example; message HelloRequest { string msg = 1; int32 code = 2; } message HelloResponse { string msg = 1; } service HelloWorld { rpc hello…
John
  • 103
  • 1
  • 11
0
votes
1 answer

How to add "targets in compile" to a SBT project which is defined with lazy val root = project.in(".")

I have a project: lazy val root = project .in(file(".")) .settings( ... I wish to add ScalaPB to the project and I need to add: PB.targets in Compile := Seq( scalapb.gen(grpc = true) -> (sourceManaged in Compile).value, …
Phil
  • 46,436
  • 33
  • 110
  • 175
0
votes
1 answer

How to define and pass implicit encoder of a particular subtype to AvroSchema

Is it possible to define and pass Encoder[E] for any subtype E (e.g. any E that extends GeneratedEnum class, in the code instance of E is Color) to AvroSchema[C] where C is some case class that contains E as field. case class Color(value: Int)…
fpopic
  • 1,756
  • 3
  • 28
  • 40
0
votes
1 answer

How to integrate sbt-protoc and scalapb with sbt cross build?

I have a library that needs two different versions of "com.thesamet.scalapb" %% "compilerplugin" depending on the Scala version. In my project/scalapb.sbt I have this code: def scalapbVersion(version:String): String = if(version == "2.11") { …
angelcervera
  • 3,699
  • 1
  • 40
  • 68
0
votes
1 answer

SparkSQL with ScalaPB: Error while skipping proto fields while converting from DataFrame to proto dataset

I have the following proto message, that needs to be written through Spark using ScalaPB: message EnforcementData { required int32 id = 1; required int32 source = 2; required int32 flagsEnforceOption = 4; required int32 categoryEnforceOption…
0
votes
1 answer

SparkSQL with ScalaPB: Using MapType in output proto format gives scala.MatchError while calling toByteString

The following is my output message format : message EditorialTextAdEnforcementData { int32 customerId = 1; int32 source = 2; DecisionDetails decisionDetails = 3; int32 flagsEnforceOption = 4; int32 categoryEnforceOption = 5; int32…
0
votes
1 answer

Creating dataframe on proto case class with bcl.DateTime field throws none is not a term exception

I have a case class generated from a .proto file through scalapb, which has a few fields with bcl.DateTime type. The case class definition is as follows: @SerialVersionUID(0L) final case class EditorialAdEntity( customerid: _root_.scala.Int =…
0
votes
0 answers

Running scalapbc command from a thread pool

I am trying to run the scalapb command from a threadpool with each thread running the scalapbc command; When I do that, I get an error of the form : # A fatal error has been detected by the Java Runtime Environment: # # SIGBUS (0x7) at…
Pankaj Sharma
  • 15
  • 1
  • 5
0
votes
1 answer

ScalaPB, proto3: set field to None, no optionalX prefix available

Using the Person and Address message definition in https://scalapb.github.io/generated-code.html syntax = "proto3"; package trexo.scalapb; message Person { string name = 1; int32 age = 2; repeated Address addresses = 3; } message Address { …
Polymerase
  • 6,311
  • 11
  • 47
  • 65
0
votes
0 answers

ScalaPB code generation option for metadata access in method implementation

What option can I set for ScalaPB code generation where the methods for the service implementation have access to metadata? Default options generate something like: override def sayHello(req: HelloRequest) = { ... } And I would like something…
Cassio
  • 1,347
  • 13
  • 15
0
votes
1 answer

Serializing message with protobuf for akka actor which contains serializable data

I have a persistent actor which can receive one type of command Persist(event) where event is a type of trait Event (there are numerous implementations of it). And on success, this reponds with Persisted(event) to the sender. The event itself is…
Niks
  • 4,802
  • 4
  • 36
  • 55