Google Protocol Buffers in mobile projects

25 %
75 %
Information about Google Protocol Buffers in mobile projects
Technology

Published on March 3, 2014

Author: KostiaDombrovsky

Source: slideshare.net

• • • •

• • • •

Язык описания структур данных Типы данных: • • • • • bytes

message Product { required string name required int32 id optional int32 price optional bool starred = 1; = 2; = 3; = 4; enum OrderStatus {Ordered = 0; Shipped = 1; Idle = 2;} optional OrderStatus status = 5; message ProductReview { required int32 id = 1; optional string reviewer = 2; optional string review = 3; required in32 rating = 4; } repeated ProductReview reviews = 6; }

Подготовка к использованию GPB в проекте • • • protoc --proto_path=src -objc_out=build/gen src/shop.proto • • • •

Как использовать GPB в проекте? Очень просто!!!

Создание нового объекта Product_Builder* builder = [Product builder]; [builder setId: 0]; [builder setName: @"BMW M5"]; [builder setStatus: Product_OrderStatusShipped]; Product_ProductReview_Builder* reviewBuilder = [Product_ProductReview builder]; [reviewBuilder setId: 0]; [reviewBuilder setReviewer: @"Kostia Dombrovsky"]; [reviewBuilder setRating: 5]; [reviewBuilder setReview: @"Every BMW rocks!"]; [builder addReviews: [reviewBuilder build]]; Product* product = [builder build];

Сериализация и десериализация Product* product = [builder build]; NSData* serializedData = [product data]; product = [Product parseFromData: serializedData]; Изменение объекта Product_Builder* builder = [Product builderWithPrototype: product]; [builder setId: 9000]; product = [builder build];

Достоинства GPB Простота использования Скорость работы (от 20 до 100 раз быстрее чем XML, быстрее чем JSON) Меньший объём (от 3 до 10 раз меньше чем XML, до 2х раз меньше чем JSON) База в 1 триллион твитов 15 10 Size (Petabyte) 5 0 XML GPB

Недостатки GPB Отсутствие наследования Отсутствие возможности изменять объекты

Спасибо за внимание! Вопросы?

Add a comment

Related presentations

Related pages

Protocol Buffer Basics: C++ | Protocol Buffers | Google ...

... working with protocol buffers. ... applications/projects. ... for your buffers instead. Some engineers at Google have come to ...
Read more

protobuf/java at master · google/protobuf · GitHub

Projects 0 Wiki Pulse ... flag to reduce generated code size for mobile. protobuf ... google.com/protocol-buffers/ Contact GitHub;
Read more

Protocol Buffer Basics: Go | Protocol Buffers | Google ...

This tutorial provides a basic Go programmer's introduction to working with protocol buffers, ... applications/projects. ... MOBILE = 0 ; HOME ...
Read more

protobuf-dt | Eclipse Plugins, Bundles and Products ...

Protobuf-dt is a new Eclipse ... This plug-in has been heavily tested by Google employees in many different projects through ... google, Protocol buffers,
Read more

Google Protocol buffers in Qt5 Android Project · Issue #96 ...

Thanks for your reply Michael . I actually found a way to build the required libraries for Google Protocol buffers. I using an Android.mk file and config.h ...
Read more

Google Protocol Buffers - ChandanProgrammingDocs

Documentation : programming problems ... Access restriction: Class is not accessible due to restriction on required library
Read more

Interview: Google Protocol Buffer Plugin for NetBeans IDE ...

... Google Protocol Buffer Plugin for ... for working with Google Protocol Buffers. Certification projects are, ... tutorials via Google, ...
Read more

Protocol Buffer Basics: C++ - Notes - Google Sites

Home‎ > ‎Google Protocol Buffers‎ > ‎ ... Why Use Protocol Buffers? ... enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; ...
Read more

Why to reinvent the wheel ? - Google Groups

MOBILE = 0 ; HOME = 1; ... You received this message because you are subscribed to the Google Groups "Protocol Buffers ... One of my last projects in the ...
Read more