Implementation:Alibaba MNN Protobuf Descriptor Database H
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Reflection |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Header declaring the Protocol Buffers DescriptorDatabase interface and its concrete implementations for managing proto file descriptor collections.
Description
This header defines the abstract DescriptorDatabase interface along with three concrete implementations: SimpleDescriptorDatabase, EncodedDescriptorDatabase, and MergedDescriptorDatabase. The interface provides methods for finding file descriptors by name and for looking up types that contain specific symbols or extensions. MNN vendors this header as part of the protobuf reflection infrastructure required by the TensorFlow and Caffe model converters to dynamically resolve proto schemas during model parsing.
Usage
Vendored dependency used internally by MNN for parsing protobuf-based model formats (TensorFlow, Caffe). Not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File:
3rd_party/protobuf/src/google/protobuf/descriptor_database.h - Lines: 1-391
Signature
namespace google {
namespace protobuf {
class PROTOBUF_EXPORT DescriptorDatabase {
virtual bool FindFileByName(const std::string& filename, FileDescriptorProto* output) = 0;
virtual bool FindFileContainingSymbol(const std::string& symbol_name, FileDescriptorProto* output) = 0;
};
class SimpleDescriptorDatabase : public DescriptorDatabase { ... };
class EncodedDescriptorDatabase : public DescriptorDatabase { ... };
class MergedDescriptorDatabase : public DescriptorDatabase { ... };
} // namespace protobuf
} // namespace google
Import
#include "3rd_party/protobuf/src/google/protobuf/descriptor_database.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | Header-only declarations; defines the DescriptorDatabase abstract interface and implementations |
Outputs
| Name | Type | Description |
|---|---|---|
| DescriptorDatabase | google::protobuf::DescriptorDatabase |
Abstract interface for proto file descriptor storage and lookup |
| SimpleDescriptorDatabase | google::protobuf::SimpleDescriptorDatabase |
In-memory descriptor database backed by hash maps |
Usage Examples
// MNN internal usage
#include "google/protobuf/descriptor_database.h"
google::protobuf::SimpleDescriptorDatabase db;
google::protobuf::DescriptorPool pool(&db);
db.Add(file_proto);
const auto* desc = pool.FindMessageTypeByName("caffe.LayerParameter");