@@ -95,7 +95,7 @@ fn convert_repository_graph(
9595 specs : & ConverterSpecs ,
9696) -> Result < ConvertedGraphData , ArrowError > {
9797 Ok ( ConvertedGraphData {
98- branch : convert_branch_row ( envelope) ?,
98+ branch : convert_branch_row ( envelope, & specs . branch ) ?,
9999 directories : convert_directories ( graph, ids, envelope, & specs. directory ) ?,
100100 files : convert_files ( graph, ids, envelope, & specs. file ) ?,
101101 definitions : convert_definitions ( graph, ids, envelope, & specs. definition ) ?,
@@ -111,7 +111,7 @@ fn convert_semantic_graph(
111111 specs : & ConverterSpecs ,
112112) -> Result < ConvertedGraphData , ArrowError > {
113113 Ok ( ConvertedGraphData {
114- branch : convert_empty_branch ( ) ?,
114+ branch : convert_empty_branch ( & specs . branch ) ?,
115115 directories : convert_empty_directories ( envelope, & specs. directory ) ?,
116116 files : convert_empty_files ( envelope, & specs. file ) ?,
117117 definitions : convert_definitions ( graph, ids, envelope, & specs. definition ) ?,
@@ -330,46 +330,6 @@ fn convert_imports(
330330 } )
331331}
332332
333- fn branch_specs ( ) -> Vec < ColumnSpec > {
334- vec ! [
335- ColumnSpec {
336- name: "id" . into( ) ,
337- col_type: ColumnType :: Int ,
338- nullable: false ,
339- } ,
340- ColumnSpec {
341- name: "traversal_path" . into( ) ,
342- col_type: ColumnType :: Str ,
343- nullable: false ,
344- } ,
345- ColumnSpec {
346- name: "project_id" . into( ) ,
347- col_type: ColumnType :: Int ,
348- nullable: false ,
349- } ,
350- ColumnSpec {
351- name: "name" . into( ) ,
352- col_type: ColumnType :: Str ,
353- nullable: false ,
354- } ,
355- ColumnSpec {
356- name: "is_default" . into( ) ,
357- col_type: ColumnType :: Bool ,
358- nullable: false ,
359- } ,
360- ColumnSpec {
361- name: "_version" . into( ) ,
362- col_type: ColumnType :: TimestampMicros ,
363- nullable: false ,
364- } ,
365- ColumnSpec {
366- name: "_deleted" . into( ) ,
367- col_type: ColumnType :: Bool ,
368- nullable: false ,
369- } ,
370- ]
371- }
372-
373333struct BranchRow < ' a > {
374334 id : i64 ,
375335 env : & ' a IndexerEnvelope ,
@@ -390,14 +350,14 @@ impl AsRecordBatch for BranchRow<'_> {
390350 }
391351}
392352
393- fn convert_branch_row ( env : & IndexerEnvelope ) -> Result < RecordBatch , ArrowError > {
353+ fn convert_branch_row ( env : & IndexerEnvelope , branch_specs : & [ ColumnSpec ] ) -> Result < RecordBatch , ArrowError > {
394354 let branch_id = compute_branch_id ( env. project_id , & env. branch ) ;
395- BranchRow :: to_record_batch ( & [ BranchRow { id : branch_id, env } ] , & branch_specs ( ) , & ( ) )
355+ BranchRow :: to_record_batch ( & [ BranchRow { id : branch_id, env } ] , branch_specs, & ( ) )
396356}
397357
398- fn convert_empty_branch ( ) -> Result < RecordBatch , ArrowError > {
358+ fn convert_empty_branch ( branch_specs : & [ ColumnSpec ] ) -> Result < RecordBatch , ArrowError > {
399359 let rows: Vec < BranchRow < ' _ > > = Vec :: new ( ) ;
400- BranchRow :: to_record_batch ( & rows, & branch_specs ( ) , & ( ) )
360+ BranchRow :: to_record_batch ( & rows, branch_specs, & ( ) )
401361}
402362
403363fn convert_repository_edges (
@@ -665,6 +625,7 @@ fn build_tag_properties(ontology: &Ontology) -> TagProperties {
665625}
666626
667627pub struct ConverterSpecs {
628+ branch : Vec < ColumnSpec > ,
668629 directory : Vec < ColumnSpec > ,
669630 file : Vec < ColumnSpec > ,
670631 definition : Vec < ColumnSpec > ,
@@ -676,6 +637,7 @@ pub struct ConverterSpecs {
676637impl ConverterSpecs {
677638 pub fn from_ontology ( ontology : & Ontology ) -> Self {
678639 Self {
640+ branch : entity_specs ( ontology, "Branch" ) ,
679641 directory : entity_specs ( ontology, "Directory" ) ,
680642 file : entity_specs ( ontology, "File" ) ,
681643 definition : entity_specs ( ontology, "Definition" ) ,
0 commit comments