catalogindex

package
v0.229.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package catalogindex builds a read-only, periodically-rebuildable analytics view of the whole catalog over an in-memory gochickpeas graph. It answers cross-work questions the per-grain scans and the workindex identity layer cannot: which works share a controlled subject authority, and how heavily each authority is used across the corpus.

The view is loaded from a catalog.nq dataset (the `lcat serialize` output), where each bf:Work is a "Work"-labelled node, each bf:subject link is an outgoing "subject" rel to the authority node, and every IRI node carries its own IRI under the "uri" property. Blob grains remain the source of truth; this Snapshot is derived and disposable -- rebuild a fresh one when the catalog changes rather than mutating an existing one.

Subject authorities are the cross-work dimension modelled here because they are IRI-identified and therefore shared across works. Agents are blank nodes scoped to their grain (a MARC feed mints a fresh blank per contribution), so two works by the same author do not share an agent node; author co-occurrence stays a string-keyed concern of the similar package, not a graph query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorityUse

type AuthorityUse struct {
	URI    string `json:"uri"`
	Label  string `json:"label,omitempty"`
	Scheme string `json:"scheme,omitempty"`
	Works  int    `json:"works"`
}

AuthorityUse is one controlled subject authority and how many distinct works in the corpus are subject-linked to it.

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot is an immutable analytics view of one catalog dataset. Build it with Open or FromNQuads; its query methods are safe for concurrent use.

func FromNQuads

func FromNQuads(data []byte) (*Snapshot, error)

FromNQuads builds a Snapshot from an in-memory catalog.nq dataset.

func Open

func Open(path string) (*Snapshot, error)

Open loads a catalog.nq dataset from disk into a Snapshot.

func (*Snapshot) AuthorityUsage

func (s *Snapshot) AuthorityUsage() []AuthorityUse

AuthorityUsage reports every controlled subject authority referenced by at least one work, with the count of distinct works referencing it, sorted by descending use then URI. A subject a single work links more than once (e.g. asserted in both a feed graph and the editorial graph) counts once for that work.

Only controlled authorities are reported -- subjects whose URI resolves to a recognized authority scheme (project.SchemeForURI). Bare-label topics (blank nodes with no URI) and per-grain local subjects (document-relative "#..." fragment IRIs) are omitted: they carry no shared cross-work identity to aggregate, which is the whole point of the tally.

func (*Snapshot) WorksUsingAuthority

func (s *Snapshot) WorksUsingAuthority(uri string) []string

WorksUsingAuthority returns the grain ids of the works subject-linked to the given authority URI, deduplicated and sorted. An unknown or unreferenced URI yields nil. The id is the local part of a work's "#<id>Work" node -- the same id the rest of libcat keys works by.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL