refactor(8.0): remove dead/deprecated code (legacy sweep)
- Deleted getIdsForFilterOld() — a 74-line "DEPRECATED old implementation" private method in the metadata index with no callers. - Deleted getEdgesBySource/ByTarget/ByType from FileSystemStorage — three deprecated methods that only `console.warn` + `return []` (stub returns the repo forbids); not called anywhere and not required by any interface. - Removed dead commented-out code fragments (an aspirational find() block in the NLP processor; a stale duplicate `const groups` line in the VFS generator). Build + unit gate green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a52dba2168
commit
b9369f260b
3 changed files with 1 additions and 106 deletions
|
|
@ -189,8 +189,7 @@ export class VFSStructureGenerator {
|
|||
reportProgress('metadata', `Preserved source file: ${options.sourceFilename}`)
|
||||
}
|
||||
|
||||
// Note: groups already calculated above for progress tracking
|
||||
// const groups = this.groupEntities(importResult, options)
|
||||
// `groups` was already computed above (for progress tracking) and is reused here.
|
||||
|
||||
// Create directories and files for each group
|
||||
for (const [groupName, entities] of groups.entries()) {
|
||||
|
|
|
|||
|
|
@ -661,35 +661,6 @@ export class FileSystemStorage extends BaseStorage {
|
|||
return allEdges
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edges by source
|
||||
*/
|
||||
protected async getEdgesBySource(sourceId: string): Promise<Edge[]> {
|
||||
// This method is deprecated and would require loading metadata for each edge
|
||||
// For now, return empty array since this is not efficiently implementable with new storage pattern
|
||||
console.warn('getEdgesBySource is deprecated and not efficiently supported in new storage pattern')
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edges by target
|
||||
*/
|
||||
protected async getEdgesByTarget(targetId: string): Promise<Edge[]> {
|
||||
// This method is deprecated and would require loading metadata for each edge
|
||||
// For now, return empty array since this is not efficiently implementable with new storage pattern
|
||||
console.warn('getEdgesByTarget is deprecated and not efficiently supported in new storage pattern')
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edges by type
|
||||
*/
|
||||
protected async getEdgesByType(type: string): Promise<Edge[]> {
|
||||
// This method is deprecated and would require loading metadata for each edge
|
||||
// For now, return empty array since this is not efficiently implementable with new storage pattern
|
||||
console.warn('getEdgesByType is deprecated and not efficiently supported in new storage pattern')
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an edge from storage
|
||||
|
|
|
|||
|
|
@ -2311,81 +2311,6 @@ export class MetadataIndexManager implements MetadataIndexProvider {
|
|||
return normalized
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED - Old implementation for backward compatibility
|
||||
*/
|
||||
private async getIdsForFilterOld(filter: any): Promise<string[]> {
|
||||
if (!filter || Object.keys(filter).length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
// Handle logical operators
|
||||
if (filter.allOf && Array.isArray(filter.allOf)) {
|
||||
// For allOf, we need intersection of all sub-filters
|
||||
const allIds: string[][] = []
|
||||
for (const subFilter of filter.allOf) {
|
||||
const subIds = await this.getIdsForFilter(subFilter)
|
||||
allIds.push(subIds)
|
||||
}
|
||||
|
||||
if (allIds.length === 0) return []
|
||||
if (allIds.length === 1) return allIds[0]
|
||||
|
||||
// Intersection of all sets
|
||||
return allIds.reduce((intersection, currentSet) =>
|
||||
intersection.filter(id => currentSet.includes(id))
|
||||
)
|
||||
}
|
||||
|
||||
if (filter.anyOf && Array.isArray(filter.anyOf)) {
|
||||
// For anyOf, we need union of all sub-filters
|
||||
const unionIds = new Set<string>()
|
||||
for (const subFilter of filter.anyOf) {
|
||||
const subIds = await this.getIdsForFilter(subFilter)
|
||||
subIds.forEach(id => unionIds.add(id))
|
||||
}
|
||||
return Array.from(unionIds)
|
||||
}
|
||||
|
||||
// Handle regular field filters
|
||||
const criteria = this.convertFilterToCriteria(filter)
|
||||
const idSets: string[][] = []
|
||||
const unindexedFields: string[] = []
|
||||
|
||||
for (const { field, values } of criteria) {
|
||||
const unionIds = new Set<string>()
|
||||
try {
|
||||
for (const value of values) {
|
||||
const ids = await this.getIds(field, value)
|
||||
ids.forEach(id => unionIds.add(id))
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof BrainyError && err.type === 'FIELD_NOT_INDEXED') {
|
||||
unindexedFields.push(field)
|
||||
// Treat as no matches and continue — same semantics as the main
|
||||
// getIdsForFilter() path.
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
idSets.push(Array.from(unionIds))
|
||||
}
|
||||
|
||||
if (unindexedFields.length > 0) {
|
||||
prodLog.warn(
|
||||
`[brainy] find() where-clause referenced unindexed field(s) ` +
|
||||
`${unindexedFields.join(', ')}; their clauses contributed no rows.`
|
||||
)
|
||||
}
|
||||
if (idSets.length === 0) return []
|
||||
if (idSets.length === 1) return idSets[0]
|
||||
|
||||
// Intersection of all field criteria (implicit $and)
|
||||
return idSets.reduce((intersection, currentSet) =>
|
||||
intersection.filter(id => currentSet.includes(id))
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush dirty entries to storage (non-blocking version)
|
||||
* NOTE: Sparse indices are flushed immediately in add/remove operations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue