Skip to content
This repository
branch: fastsearch
Fetching contributors…

Cannot retrieve contributors at this time

file 65 lines (47 sloc) 1.418 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/* We use core data for three things:
     Persistence
     Querying
     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;

@end

@implementation GGNode

- (id)valueForKey:(id)key
{
id value = [keyvalues objectForKey:key];

if (value)
return value;
else
return [self valueForUndefinedKey:key];
}
- (id)setValue:(id)value forKey:(id)key
{
if (value && key)
[keyvalues setValue:value forKey:key];
}

@end


@interface IGKRecord : GGNode
{
NSString *tableName;
uint64_t ident;
}

+ (id)reverseKeyForToMany:(id)key;

@end

@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];
}

@end
Something went wrong with that request. Please try again.