hillegass / bnrpersistence Goto Github PK
View Code? Open in Web Editor NEWA set of classes which use Tokyo Cabinet to save and load Objective-C objects
Home Page: http://weblog.bignerdranch.com/
License: MIT License
A set of classes which use Tokyo Cabinet to save and load Objective-C objects
Home Page: http://weblog.bignerdranch.com/
License: MIT License
Does full-text search work on the iPhone?
I tried editing the PhoneSpeedTest Project, the simple insert function in particular:
- (IBAction)simpleInsertTC:(id)sender
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"BNRPersistence: Inserting %d songs",SONG_COUNT);
uint64_t start = mach_absolute_time();
NSString *path = docPathWithName(@"rah");
BNRStore *store = [self newStoreWithPath:path];
NSError *err;
BNRTCIndexManager *indexManager =
[[BNRTCIndexManager alloc]
initWithPath:docPathWithName(@"rah") error:&err];
if (!indexManager) {
NSLog(@"error = %@", [err localizedDescription]);
exit(EXIT_FAILURE);
}
[store setIndexManager:indexManager];
[indexManager release];
[store addClass:[Song class]];
NSMutableArray *songs = [[NSMutableArray alloc] initWithCapacity:SONG_COUNT];
for (int i = 0; i < SONG_COUNT; i++) {
Song *song = [[Song alloc] init];
[song setTitle:[NSString stringWithFormat:@"Test Song %d", i]];
[song setSeconds:i];
[songs addObject:song];
[store insertObject:song];
[song release];
}
NSError *error;
BOOL success = [store saveChanges:&error];
if (!success) {
NSLog(@"error = %@", [error localizedDescription]);
return;
}
// Interestingly, it is quicker to release the store before the StoredObjects
[store release];
[songs release];
[pool drain];
uint64_t stop = mach_absolute_time();
[self showLapsedTime:start to:stop];
}
The objects fail to be inserted into the index: tcidbput(ti, rowID, cValue)
returns false
. But all arguments are valid.
- (void)insertObjectInIndexes:(BNRStoredObject *)obj
{
Class c = [obj class];
UInt32 rowID = [obj rowID];
NSSet *indexKeys = [c textIndexedAttributes];
for (NSString *key in indexKeys) {
TCIDB *ti = [self textIndexForClass:c key:key];
NSString *value = [obj valueForKey:key];
const char * cValue = [value cStringUsingEncoding:NSUTF8StringEncoding];
BOOL success = tcidbput(ti, rowID, cValue);
if (!success) {
NSLog(@"Insert of %@ into index (%@, %@) failed", value, NSStringFromClass(c), key);
}
}
}
Is there an easy way to make a fat binary of the tokyo cabinet library? I want to use this in an app that runs on 10.5 and supports ppc as well as Intel. Is it even possible to have a fat .a library? Just wondering if anyone here had encountered this before.
By the way, I've only just started playing with BNRPersistence, but it's quite excellent and I'm currently planning to include it in an upcoming v2 release of mine. Thanks very much for it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.