refactor(server): indexer & worker & sync perf (#15504)

This commit is contained in:
DarkSky
2026-08-21 08:11:37 +08:00
committed by GitHub
parent 8c9aad9a9b
commit c57004ea2c
259 changed files with 16530 additions and 17793 deletions
+67 -12
View File
@@ -154,6 +154,7 @@ export declare class DocStoragePool {
getDocClock(universalId: string, docId: string): Promise<DocClock | null>
getDocIndexedClock(universalId: string, docId: string): Promise<DocIndexedClock | null>
setDocIndexedClock(universalId: string, docId: string, indexedClock: Date, indexerVersion: number): Promise<void>
setDocIndexedClocks(universalId: string, clocks: Array<DocIndexedClock>): Promise<void>
clearDocIndexedClock(universalId: string, docId: string): Promise<void>
getBlob(universalId: string, key: string): Promise<Blob | null>
setBlob(universalId: string, blob: SetBlob): Promise<void>
@@ -172,13 +173,13 @@ export declare class DocStoragePool {
clearClocks(universalId: string): Promise<void>
setBlobUploadedAt(universalId: string, peer: string, blobId: string, uploadedAt?: Date | undefined | null): Promise<void>
getBlobUploadedAt(universalId: string, peer: string, blobId: string): Promise<Date | null>
ftsAddDocument(id: string, indexName: string, docId: string, text: string, index: boolean): Promise<void>
ftsFlushIndex(id: string): Promise<void>
ftsIndexVersion(): Promise<number>
ftsDeleteDocument(id: string, indexName: string, docId: string): Promise<void>
ftsGetDocument(id: string, indexName: string, docId: string): Promise<string | null>
ftsSearch(id: string, indexName: string, query: string): Promise<Array<NativeSearchHit>>
ftsGetMatches(id: string, indexName: string, docId: string, query: string): Promise<Array<NativeMatch>>
indexUpsert(id: string, table: string, document: NativeIndexDocument): Promise<void>
indexFlush(id: string): Promise<void>
indexVersion(): Promise<number>
indexDelete(id: string, table: string, docId: string): Promise<void>
indexSearch(id: string, table: string, query: NativeIndexQuery, options: NativeIndexSearchOptions): Promise<NativeIndexSearchResult>
indexAggregate(id: string, table: string, query: NativeIndexQuery, field: string, limit: number, offset: number, hits?: NativeIndexSearchOptions | undefined | null): Promise<NativeIndexAggregateResult>
indexDeleteByQuery(id: string, table: string, query: NativeIndexQuery): Promise<number>
}
export interface Blob {
@@ -237,15 +238,69 @@ export interface NativeCrawlResult {
summary: string
}
export interface NativeMatch {
start: number
end: number
export interface NativeIndexAggregateResult {
total: number
buckets: Array<NativeIndexBucket>
}
export interface NativeSearchHit {
export interface NativeIndexBucket {
key: string
count: number
score: number
hits: Array<NativeIndexHit>
}
export interface NativeIndexDocument {
id: string
fields: Array<NativeIndexField>
}
export interface NativeIndexField {
field: string
values: Array<string>
}
export interface NativeIndexHighlight {
field: string
values: Array<NativeIndexHighlightValue>
}
export interface NativeIndexHighlightValue {
valueIndex: number
spans: Array<NativeIndexSpan>
}
export interface NativeIndexHit {
id: string
score: number
terms: Array<string>
fields: Array<NativeIndexField>
highlights: Array<NativeIndexHighlight>
}
export interface NativeIndexQuery {
kind: string
field?: string
value?: string
occur?: string
clauses?: Array<NativeIndexQuery>
boost?: number
}
export interface NativeIndexSearchOptions {
limit: number
offset: number
fields: Array<string>
highlights: Array<string>
}
export interface NativeIndexSearchResult {
total: number
hits: Array<NativeIndexHit>
}
export interface NativeIndexSpan {
start: number
end: number
}
export interface SetBlob {