• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
    • RDF quality heuristics
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

1.8 Advanced Topics
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Google's Protocol Buffers Library
        • Google's Protocol Buffers
          • Advanced Topics
            • Precompiled Messages
            • Supplying Your Own Host Type Message Sequences

1.8.1 Precompiled Messages

Performance can be significantly improved using a strategy of precompiling the constant portions of your message. Enumerations for example, are excellent candidates for precompilation. Using protobuf_message/3, the precompiled portion of the message is inserted directly in the wire-stream on encode, and is unified with, and removed from the wire-stream on decode. The following shows how the "send_command" example above, can be converted to precompiled form:


:- dynamic precompiled_message/3.

send_precompiled_command(Command, Vector, Msg) :-
        basic_vector(Vector, Proto1),

        precompiled_message(commands(Command), Msg, Tail),

        protobuf_message(protobuf([embedded(3, Proto1)]), Tail).

precompile_commands :-
        abolish(precompiled_message/3),
        forall(protobufs:commands(Key, _),
              ( Proto = protobuf([atom(1, command),
                                  enum(2, commands(Key))]),
                protobuf_message(Proto, Msg, Tail),
                assert(precompiled_message(commands(Key), Msg, Tail))
              )),
        compile_predicates([precompiled_message/3]).

*
*
*
:- initialization
     precompile_commands.

ClioPatria (version V3.1.1-40-g9d9e003)