On Fri, Apr 1, 2016 at 6:06 AM, Ranadheer Pulluru <[email protected]>
wrote:

> Hi,
>
> I'm planning to use protobuf for publishing tick data of the financial
> instruments. The consumers can be any of the java/python/node.js
> languages.The tick is expected to contain various fields like (symbol,
> ask_price, bid_price, trade_price, trade_time, trade_size, etc). Basically,
> it is sort of a map from field name to the value, where value type can be
> any of the primitive types. I thought I can define the schema of the Tick
> data structure, using map
> <https://developers.google.com/protocol-buffers/docs/proto3#maps>and Any
> <https://developers.google.com/protocol-buffers/docs/proto3#any>as follows
>
>
> syntax = "proto3";
>
> package tutorial;
>
> import "google/protobuf/any.proto";
>
> message Tick {
>     string subject = 1; // name of the financial instrument - something
> like MSFT, GOOG, etc
>     uint64 timestamp = 2; //millis from epoch signifying the timestamp at
> which the object is constructed at the publisher side.
>     map<string, google.protobuf.Any> fvmap = 3; // the actual map having
> field name and values. Something like {ask_price: 10.5, bid_price: 9.5,
> trade_price: 10, trade_size=5}
> }
>
> Though I'm able to generate the code in different languages for this
> schema, I'm not sure how to populate the values in the *fvmap*.
>
> public class TickTest
> {
>     public static void main(String[] args)
>     {
>         Tick.Builder tick = Tick.newBuilder();
>         tick.setSubject("ucas");
>         tick.setTimestamp(System.currentTimeMillis());
>         Map<String, Any> fvMap = tick.getMutableFvmap();
> //        fvMap.put("ask", value); // Not sure how to pass values like
> 10.5/9.5/10/5 to Any object here.
>     }
> }
>
>
>
> Could you please let me know how to populate the fvMap with different
> fields and values here? Please feel tree to tell me if using map
> <https://developers.google.com/protocol-buffers/docs/proto3#maps>and Any
> <https://developers.google.com/protocol-buffers/docs/proto3#any>is not
> the right choice and if there are any better alternatives.
>
It seems to me a google.protobuf.Struct suites your purpose better:
https://github.com/google/protobuf/blob/master/src/google/protobuf/struct.proto#L51


>
> Thanks
> Ranadheer
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to