Introduce flatbuffer (#272)

Co-authored-by: star9029 <hengxings783@gmail.com>
This commit is contained in:
ykiko
2025-10-06 13:10:29 +08:00
committed by GitHub
parent 49caa2d9ba
commit b705560557
6 changed files with 145 additions and 10 deletions

View File

@@ -59,12 +59,12 @@ struct MergedIndex {
/// A map between source file path and its header contexts.
llvm::StringMap<HeaderContexts> contexts;
/// All merged symbol relations.
llvm::DenseMap<SymbolHash, llvm::DenseMap<Relation, roaring::Roaring>> relations;
/// All merged symbol occurrences.
llvm::DenseMap<Occurrence, roaring::Roaring> occurrences;
/// All merged symbol relations.
llvm::DenseMap<SymbolHash, llvm::DenseMap<Relation, roaring::Roaring>> relations;
void remove(llvm::StringRef path);
void merge(llvm::StringRef path, std::uint32_t include, FileIndex& index);

65
include/Index/schema.fbs Normal file
View File

@@ -0,0 +1,65 @@
namespace clice.index.binary;
struct Range {
begin: uint;
end: uint;
}
struct Occurrence {
range: Range;
target: ulong;
}
struct Relation {
kind: int;
padding: int;
range: Range;
target_symbol: ulong;
}
table CacheEntry {
sha256: string;
canonical_id: uint;
}
struct Context {
include_: uint;
canonical_id: uint;
}
table HeaderContexts {
version: uint;
includes: [Context];
}
table HeaderContextsEntry {
path: string;
contexts: HeaderContexts;
}
table OccurrenceEntry {
occurrence: Occurrence;
context: [ubyte];
}
table RelationEntry {
relation: Relation;
context: [ubyte];
}
table SymbolRelationsEntry {
symbol: ulong;
relations: [RelationEntry];
}
table MergedIndex {
max_canonical_id: uint;
canonical_cache: [CacheEntry];
contexts: [HeaderContextsEntry];
occurrences: [OccurrenceEntry];
relations: [SymbolRelationsEntry];
}