@@ -31,6 +31,9 @@ corresponding serialization APIs to persisting them on-disk or for transport.
3131- [ Try it] ( #try-it )
3232 - [ Versions] ( #versions )
3333- [ Who are using slim] ( #who-are-using-slim )
34+ - [ Slim internal] ( #slim-internal )
35+ - [ Protobuf data structures] ( #protobuf-data-structures )
36+ - [ Regenerating protobuf code] ( #regenerating-protobuf-code )
3437- [ Feedback and contributions] ( #feedback-and-contributions )
3538- [ Authors] ( #authors )
3639- [ License] ( #license )
@@ -469,52 +472,61 @@ a newer version `y`.
469472
470473
471474<!-- TODO add FAQ -->
472- <!-- TODO add serialization explanation, on-disk data structure etc. -->
473475
474476## Who are using slim
475477
476478<span > <span > ![ ] [ baishancloud-favicon ] </span > <span > [ baishancloud] [ ] </span > </span >
477479
478- <!-- ## Slim internal -->
480+ ## Slim internal
479481
480- <!-- ### Built With -->
482+ ### Protobuf data structures
481483
482- <!-- - [protobuf][] - Define on-disk data-structure and serialization engine. -->
483- <!-- - [dep][] - Dependency Management. -->
484- <!-- - [semver][] - For versioning data-structure. -->
484+ Slim uses [ protobuf] [ ] to define its on-disk data structures and as its
485+ serialization engine. All ` .proto ` files use ** proto3** syntax.
485486
486- <!-- ### Directory Layout -->
487+ The protobuf definitions are in the following files:
487488
488- <!-- We follow the: [golang-standards-project-layout][]. -->
489+ - ` array/bitmap.proto ` : ` Bits ` – a bitmap with rank index, used as the
490+ building block for sparse arrays.
489491
490- <!-- [> TODO read the doc and add more standards <] -->
492+ - ` array/array.proto ` : ` Array32 ` – a 32-bit sparse array backed by bitmaps
493+ and offset tables.
491494
492- <!-- - `vendor/`: dependency packages. -->
493- <!-- - `prototype/`: on-disk data-structure. -->
494- <!-- - `docs/`: documents about design, trade-off, etc -->
495- <!-- - `tools/`: documents about design, trade-off, etc -->
496- <!-- - `expamples/`: documents about design, trade-off, etc -->
495+ - ` trie/slim.proto ` : ` Bitmap ` , ` VLenArray ` , and ` Slim ` – the core trie
496+ structures. ` Slim ` stores node-type bitmaps, inner-node label bitmaps,
497+ short-bitmap tables, inner/leaf prefixes, and serialized leaf values.
497498
498- <!-- Other directories are sub-package. -->
499+ These structures are serialized with ` proto.Marshal() ` and deserialized with
500+ ` proto.Unmarshal() ` from the [ ` github.com/golang/protobuf ` ] [ protobuf-go ]
501+ package (v1.3.1).
499502
503+ ### Regenerating protobuf code
500504
501- <!-- ### Versioning -->
505+ The generated Go files (` *.pb.go ` ) should ** not** be edited by hand. To
506+ regenerate them after modifying a ` .proto ` file:
502507
503- <!-- We use [SemVer](http://semver.org/) for versioning. -->
508+ 1 . Install ` protoc ` (the Protocol Buffers compiler).
509+ See [ protoc installation] [ protoc-install ] .
504510
505- <!-- For the versions available, see the [tags on this repository](https://github.com/your/project/tags). -->
511+ 2 . Install the Go protobuf plugin:
506512
507- <!-- ### Data structure explained -->
508- <!-- [> TODO <] -->
513+ ``` sh
514+ go install github.com/golang/protobuf/protoc-gen-go@latest
515+ ```
509516
510- <!-- ## Limitation -->
511- <!-- [> TODO <] -->
517+ 3. Re-generate the Go source:
512518
519+ ` ` ` sh
520+ # array package (has a go:generate directive in array/gen.go)
521+ go generate ./array/...
513522
514- <!-- - [ ] bitrie: 1 byte-per-key implementation. -->
515- <!-- - [ ] balanced bitrie: which gives better worst-case performance . -->
516- <!-- - [ ] generalised API as a drop-in replacement for map etc. -->
523+ # trie package
524+ cd trie && protoc --proto_path= . --go_out=. slim.proto
525+ ` ` `
517526
527+ > ** Note:** ` trie/slim.proto` was originally built with ` protoc-gen-go`
528+ > ** v1.2.0** . When regenerating, make sure the generated code is compatible
529+ > with the module dependency ` github.com/golang/protobuf v1.3.1` .
518530
519531# # Feedback and contributions
520532
@@ -657,6 +669,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
657669
658670[dep]: https://github.com/golang/dep
659671[protobuf]: https://github.com/protocolbuffers/protobuf
672+ [protobuf-go]: https://github.com/golang/protobuf
660673[semver]: http://semver.org/
661674
662675[protoc-install]: http://google.github.io/proto-lens/installing-protoc.html
0 commit comments