@@ -7,103 +7,19 @@ use std::sync::{Arc, Mutex};
77
88use anyhow:: { Context , Result , anyhow} ;
99use serde:: de:: DeserializeOwned ;
10- use serde:: { Deserialize , Serialize } ;
10+ use serde:: Serialize ;
1111use tempfile:: { Builder , NamedTempFile , TempPath } ;
1212
1313use crate :: chunk_store:: ChunkStore ;
1414
15+ pub use pointer_indexer_types:: {
16+ BranchHead , BranchPolicy , BranchSnapshotPolicy , ChunkMapping , ContentBlob , FilePointer ,
17+ IndexReport , ReferenceRecord , SymbolNamespaceRecord , SymbolRecord , UniqueChunk ,
18+ } ;
19+
1520const NEWLINE : & [ u8 ] = b"\n " ;
1621const BUFFER_FLUSH_BYTES : usize = 512 * 1024 ;
1722
18- // Represents a file's metadata. Content is stored separately.
19- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
20- pub struct ContentBlob {
21- pub hash : String ,
22- pub language : Option < String > ,
23- pub byte_len : i64 ,
24- pub line_count : i32 ,
25- }
26-
27- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
28- pub struct SymbolRecord {
29- pub content_hash : String ,
30- pub name : String ,
31- }
32-
33- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
34- pub struct ReferenceRecord {
35- pub content_hash : String ,
36- pub namespace : Option < String > ,
37- pub name : String ,
38- pub fully_qualified : String ,
39- pub kind : Option < String > ,
40- pub line : usize ,
41- pub column : usize ,
42- }
43-
44- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
45- pub struct SymbolNamespaceRecord {
46- pub namespace : String ,
47- }
48-
49- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
50- pub struct FilePointer {
51- pub repository : String ,
52- pub commit_sha : String ,
53- pub file_path : String ,
54- pub content_hash : String ,
55- }
56-
57- // A report containing all the metadata extracted from a repository.
58- #[ derive( Debug , Clone , Serialize , Deserialize , Default ) ]
59- pub struct IndexReport {
60- pub content_blobs : Vec < ContentBlob > ,
61- pub symbol_records : Vec < SymbolRecord > ,
62- pub file_pointers : Vec < FilePointer > ,
63- pub reference_records : Vec < ReferenceRecord > ,
64- pub branches : Vec < BranchHead > ,
65- }
66-
67- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
68- pub struct BranchSnapshotPolicy {
69- pub interval_seconds : u64 ,
70- pub keep_count : u32 ,
71- }
72-
73- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
74- pub struct BranchPolicy {
75- pub latest_keep_count : u32 ,
76- #[ serde( skip_serializing_if = "Option::is_none" ) ]
77- pub is_live : Option < bool > ,
78- #[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
79- pub snapshot_policies : Vec < BranchSnapshotPolicy > ,
80- }
81-
82- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
83- pub struct BranchHead {
84- pub repository : String ,
85- pub branch : String ,
86- pub commit_sha : String ,
87- #[ serde( skip_serializing_if = "Option::is_none" ) ]
88- pub policy : Option < BranchPolicy > ,
89- }
90-
91- // A unique, deduplicated chunk of text content.
92- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq , Eq , Hash ) ]
93- pub struct UniqueChunk {
94- pub chunk_hash : String ,
95- pub text_content : String ,
96- }
97-
98- // Maps a file's content hash to a sequence of chunks.
99- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
100- pub struct ChunkMapping {
101- pub content_hash : String ,
102- pub chunk_hash : String ,
103- pub chunk_index : usize ,
104- pub chunk_line_count : i32 ,
105- }
106-
10723#[ derive( Debug ) ]
10824struct WriterState {
10925 file : NamedTempFile ,
0 commit comments