Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / method

_build_rows

codeintel.indexer.CodeIndexer._build_rows

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (7)
SymbolFileResolved by
raw_urlgit_source.pyunique name
_PreparedChunkindexer.pysame file
_utcnowindexer.pysame file
langindexer.pysame file
body_excerpttext.pythrough an import
search_texttext.pythrough an import
semantic_summarytext.pythrough an import
Called by (1)
SymbolFileResolved by
_index_batchindexer.pysame file
Inside (1)
SymbolFileResolved by
CodeIndexerindexer.pysame file
codeintel.indexer.CodeIndexer._build_rowsbackend/app/codeintel/indexer.py, lines 392–451Open source
    def _build_rows(self, repo_id, ref: RepoRef, commit: str, entry: TreeEntry, text: str,                    parsed: ParseResult, stats: IndexStats) -> tuple[Resource, list[_PreparedChunk]]:        lang = stats.lang(parsed.language)        lang.files += 1        if parsed.parser == "line-fallback":            lang.fallback_files += 1            lang.fallback_reasons[parsed.fallback_reason or "unknown"] += 1        else:            lang.ast_files += 1        line_count = text.count("\n") + (0 if text.endswith("\n") else 1)        stats.source_bytes_indexed += entry.size        stats.lines_indexed += line_count        now = _utcnow()        resource = Resource(            title=entry.path,            description=f"{parsed.language} source file",            source=ref.canonical_url,            identifier=entry.path,            coverage=commit,            type="code_file",            format=f"text/x-{parsed.language}",            language=parsed.language[:16],            subject=[parsed.language],            relation=[f"repository:{ref.canonical_url}"],            ingestion_status="completed",            ingestion_completed_at=now,            repository_id=repo_id,            content_sha=entry.blob_sha,            is_stale=False,            last_indexed_sha=commit,            last_indexed_at=now,        )        raw_url = ref.raw_url(commit, entry.path)        module_name = parsed.symbols[0].qualified_name if parsed.symbols else ""        chunks: list[_PreparedChunk] = []        source_lines = text.splitlines()        descriptions = dict(self.db.execute(            select(ChunkDescription.symbol_name, ChunkDescription.description)            .where(ChunkDescription.content_sha == entry.blob_sha)        ).all())        for idx, sym in enumerate(parsed.symbols[:MAX_SYMBOLS_PER_FILE]):            summary = semantic_summary(sym, language=parsed.language, path=entry.path, module_name=module_name,                                       body=body_excerpt(source_lines, sym),                                       description=descriptions.get(sym.qualified_name[:512], ""))            meta = {                "path": entry.path,                "name": sym.name,                "parent": sym.parent,                "calls": sym.calls,            }            if sym.signature:                meta["signature"] = sym.signature[:500]            if sym.docstring:                meta["docstring"] = sym.docstring[:2000]            if parsed.parser == "line-fallback":                meta["fallback_reason"] = parsed.fallback_reason            if parsed.partial:                meta["partial_parse"] = True

Shows the first 60 of 86 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
def _build_rows(self, repo_id, ref: RepoRef, commit: str, entry: TreeEntry, text: str, parsed: ParseResult, stats: IndexStats) -> tuple[Resource, list[_PreparedChunk]]:
File
backend/app/codeintel/indexer.py
Lines
392–477
Parser
python-ast
Git blob
e8fdfa7b5545e821f7649d68cfadd2aae85b89d0
Call sites
25 named, 11 resolved, 14 left unlinked
Outside this subset
4 more edges reach code outside the graph shown here

Read it on GitHub at this commit