Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (47 sloc) 1.38 KB
/* We use core data for three things:
A persistent object graph of the light-index
A throwaway object graph between full-index and html-generation
We can switch to basic sqlite for persistence. All that is required is modifying IGKScraper to execute SQL rather than create NSManagedObjects.
Likewise we can switch over querying to sqlite by rewriting all NSPredicates as SQL.
To replace the object graph, we can write a generalised NSObject graph library based on KVC. This would be a KVC-based and entirely in-memory multi-key object graph.
@interface GGNode : NSObject
NSDictionary *keyvalues;
- (id)valueForKey:(id)key;
- (id)setValue:(id)value forKey:(id)key;
@implementation GGNode
- (id)valueForKey:(id)key
id value = [keyvalues objectForKey:key];
if (value)
return value;
return [self valueForUndefinedKey:key];
- (id)setValue:(id)value forKey:(id)key
if (value && key)
[keyvalues setValue:value forKey:key];
@interface IGKRecord : GGNode
NSString *tableName;
uint64_t ident;
+ (id)reverseKeyForToMany:(id)key;
@implementation IGKRecord
- (id)valueForUndefinedKey:(id)undef
NSString *reverseKey = [IGKRecord reverseKeyForToMany:key];
if (!reverseKey)
return nil;
NSString *query = [NSString stringWithFormat:@"SELECT id FROM %@ WHERE %@=%llu", tableName, reverseKey, ident];