Testing ith ForestDB

152 views
Skip to first unread message

Frederic Yesid Peña Sánchez

unread,
Mar 5, 2015, 11:40:39 AM3/5/15
to mobile-c...@googlegroups.com
Hi.

I've built CBL-iOS for doing tests on ForestDB, as our application experiments concurrency issues and several crashes because of that concurrency.

XCode complains about CBLLiveQuery.fullTextRanking not available.

There is some insight about the "restricted" functionality of FullTextSearch on ForestDB?

Thanks!!

Jens Alfke

unread,
Mar 5, 2015, 2:24:42 PM3/5/15
to mobile-c...@googlegroups.com

On Mar 5, 2015, at 8:40 AM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

XCode complains about CBLLiveQuery.fullTextRanking not available.
There is some insight about the "restricted" functionality of FullTextSearch on ForestDB?

I had to implement FTS from scratch on top of ForestDB, instead of being able to use the very mature implementation inside SQLite, and it doesn’t have all the features yet. :( I’ve just filed #618 to remind us about that.

The wiki page points out that ‘snippets’ aren’t available, but I forgot to add fullTextRanking; I’ll fix that.

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 5, 2015, 4:19:22 PM3/5/15
to mobile-c...@googlegroups.com
I'm facing other issue:

I have cloned and built the master branch of couchbase-lite-ios, copied the ".framework" and forest storage librearies and linked them.

But now when my application starts, fails at this function:

_db = [manager databaseNamed:@"platform_app_mobile" error:&error];

With the exception:

EXC_BAD_ADDRESS code=EXC_ARM_DA_ALIGN address=0x177a7164

Do i built wrong the library? (used Continous iOS schema)

Thanks

Jens Alfke

unread,
Mar 5, 2015, 4:28:40 PM3/5/15
to mobile-c...@googlegroups.com
I’d need to see the entire stack to diagnose this. Xcode might not be showing you the entire stack (there are controls at the bottom of the stack navigator to configure this.) To get a backtrace you can paste into an email or bug report, enter “bt” in the console.

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 5, 2015, 4:50:31 PM3/5/15
to mobile-c...@googlegroups.com
Hi Jens.

This is a gist from the stacktrace: https://gist.github.com/razorblade446/3d9fddb84fbf23917ce8

I note it tries to acess an atomic_val_add_64 but my iPad Mini is 1st gen (no x64) so it might be the issue, but no idea how to specify the platform for library.

I will try to restrict my app only for armv7, but that probably will impact newer devices performance...

Jens Alfke

unread,
Mar 5, 2015, 5:18:58 PM3/5/15
to mobile-c...@googlegroups.com

On Mar 5, 2015, at 1:50 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

I note it tries to acess an atomic_val_add_64 but my iPad Mini is 1st gen (no x64) so it might be the issue, but no idea how to specify the platform for library.

My suspicion is that ForestDB may not work correctly in 32-bit ARM at the moment. The CPU exception is
EXC_BAD_ACCESS (code=EXC_ARM_DA_ALIGN, address=0x18083b34)
Looks like the CPU is complaining about invalid data alignment — I know ARM is much stricter about this than x86. Since it’s operating on an 8-byte value I think that means it needs to be 8-byte aligned, and that address isn’t. There’s probably something that needs to be fixed about the struct alignment in the calling code; I’ll let the ForestDB team know.

(We haven’t gotten to formal testing of the ForestDB-based CBL yet; when we do it’ll include 32-bit as well as 64-bit. For now the only devices I’ve tested on both run 64-bit…)

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 5, 2015, 5:21:45 PM3/5/15
to mobile-c...@googlegroups.com
Umm ok, i will test on a iPad Mini 2nd gen (x64) tomorrow, i will keep in touch.

There is some insight on how to fix it by myself (some sparing time this night after college).

Frederic Yesid Peña Sánchez

unread,
Mar 6, 2015, 9:10:31 AM3/6/15
to mobile-c...@googlegroups.com
I notice the issue is with atomic gcc functions, may them be rewritten to access alignment issues?? (custom built forestdb may be?)

Jens Alfke

unread,
Mar 6, 2015, 12:57:48 PM3/6/15
to mobile-c...@googlegroups.com
ForestDB has a struct used for atomic operations, and it contains a 64-bit integer that the compiler somehow isn’t 8-byte aligning. This causes a crash on ARM. The ForestDB team fixed it last night (by adding a compiler attribute to force alignment) and I’ve merged it into Couchbase Lite’s master branch now.

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 9, 2015, 11:15:32 AM3/9/15
to mobile-c...@googlegroups.com
Good morning.

Some of my views depende on FullTextSearch, i already read that forest support is limited in FTS, but what things on FTS are possible with Forest at the moment??

Jens Alfke

unread,
Mar 9, 2015, 11:29:51 AM3/9/15
to mobile-c...@googlegroups.com

On Mar 9, 2015, at 8:15 AM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Some of my views depende on FullTextSearch, i already read that forest support is limited in FTS, but what things on FTS are possible with Forest at the moment??

What it says on the wiki: everything but snippets and rankings.

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 9, 2015, 2:25:35 PM3/9/15
to mobile-c...@googlegroups.com
Thanks.

I've tried adding the modifier on launch "-CBLStorageType ForestDB" but my app reports this at startup:

### Couchbase Lite 1.1 (unofficial) ###
Couchbase Lite using SQLite version 3.7.13 (2012-07-17 17:46:21 65035912264e3acbced5a3e16793327f0a2f17bb)

Should it say "ForestDB" instead??

Frederic Yesid Peña Sánchez

unread,
Mar 9, 2015, 2:30:47 PM3/9/15
to mobile-c...@googlegroups.com
Sorry my incomplete post, but also when i try

CBLManager.storageType = @"ForestDB";

XCode complains:

Property "storageType" not found in object type 'CBLManager'

I see it's defined in a category "CBLManager+Internals.h" but does it mean i have to do anything else to enable ForestDB?

Jens Alfke

unread,
Mar 9, 2015, 2:53:30 PM3/9/15
to mobile-c...@googlegroups.com

On Mar 9, 2015, at 11:25 AM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Couchbase Lite using SQLite version 3.7.13 (2012-07-17 17:46:21 65035912264e3acbced5a3e16793327f0a2f17bb)
Should it say "ForestDB" instead??

Hm, that message comes from initialization of the SQLite storage class. I agree it’s confusing. It should probably instead appear the first time the class is instantiated.

The best way to see what storage type is being used for which database is to enable logs for the `CBLDatabase` key (-LogCBLDatabase YES).

Property "storageType" not found in object type ‘CBLManager'

Oops; looks like that hasn’t been made public yet. But using args "-CBLStorageType ForestDB” should work for now.

—Jens

Frederic Yesid Peña Sánchez

unread,
Mar 9, 2015, 4:15:13 PM3/9/15
to mobile-c...@googlegroups.com
Thanks, i was already using ForestDB (the message of SQLite is misleading)

Now, going back to FTS, i'm not using snippets, and disabled FullTextRanking.

But the results of the Query gives me wrong, (or may be i'm doing wrong)

The same view works for SQLite backend:

[vistaRutasContactosMedicosFTS setMapBlock:^(NSDictionary *doc, CBLMapEmitBlock emit) {
        if([doc[@"type"] isEqualToString:@"RuteroMedicos"] && [doc[@"estado_contacto"] integerValue] != 4 && [doc[@"estado_contacto"] integerValue] != 2){
           
            NSString *datoTexto = [NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@ %@", doc[@"codigo_contacto"], doc[@"nombres"], doc[@"apellidos"], doc[@"nombre_especialidad"], doc[@"direccion_visita"], doc[@"categoria_color"], doc[@"categoria_nombre"]];
           
            // Tokenizar y generar keys
           
            CLSNSLog(@"CTK: %@", CBLTextKey(datoTexto));
           
            emit(CBLTextKey(datoTexto), @([doc[@"ruta_visita"] integerValue]));
        }
    } version:@"1.8"];


But when in use by ForestDB, it returns :

1 => "1509-2 VENNESE  TURRES  FEDERICO LLERAS 0 #999999 Sin categoria"


for key => value respectively.

Any lights on how to correctly use FTS on ForestDB (the minimum it haves)

Thanks

Frederic Yesid Peña Sánchez

unread,
Mar 10, 2015, 10:33:08 AM3/10/15
to mobile-c...@googlegroups.com

Jens Alfke

unread,
Mar 10, 2015, 12:50:10 PM3/10/15
to mobile-c...@googlegroups.com

On Mar 9, 2015, at 1:15 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Any lights on how to correctly use FTS on ForestDB (the minimum it haves)

Ugh, looks like the full-text indexing is messed up. I started looking at the code for it just now, but I’m in the middle of a different task right now so I can’t fix it immediately. Please file an issue on Github and I’ll try to take care of it later this week. Sorry about that!

—Jens

Jens Alfke

unread,
Mar 10, 2015, 6:55:09 PM3/10/15
to mobile-c...@googlegroups.com
I got the indexing fixed — full-text ForestDB indexes weren't storing the emitted value.

But I think the way you're querying the view is wrong. It looks like you're using a regular (startKey/endKey/etc.) query; to query a full-text view you need to set the fullTextQuery string instead. The weird stuff you're seeing is internal data that my (sort of hacky) FTS implementation emits into the view; if you query with fullTextQuery it will know to interpret that data correctly.

So try pulling the master branch and updating your code to set fullTextQuery, and let me know how it goes!

--Jens

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 10:39:26 AM4/9/15
to mobile-c...@googlegroups.com
Thank you, i'll try.

One last question, although this is not related to forest, but i would like to bind CBL to my app, so to avoid doing double compile-delete-copy library to my app.

There is some insight on how to include CBL as dependency for my iOS app, so one click-build-all?

Thanks

Jens Alfke

unread,
Apr 9, 2015, 11:50:54 AM4/9/15
to mobile-c...@googlegroups.com

On Apr 9, 2015, at 7:39 AM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

There is some insight on how to include CBL as dependency for my iOS app, so one click-build-all?

I think this will work, but I haven’t tried it —
  • Drag the CBL Xcode project into your app’s Xcode project
  • Go to your app target’s Dependencies build phase and add the CBL project’s “CBL iOS” target
  • Go to the Link Binary With Libraries build phase, press “+”, and add the “Couchbase Lite.framework” from the “CBL iOS” target.

—Jens

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 1:56:54 PM4/9/15
to mobile-c...@googlegroups.com
So theoretically:




--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/EutJZlBUfe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/406919D2-0269-423E-9ACB-4ECC8FF79A52%40couchbase.com.

For more options, visit https://groups.google.com/d/optout.

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 3:35:48 PM4/9/15
to mobile-c...@googlegroups.com
Couchbase compiles well, but my project complains about "CouchbaseLite.h" headers...

Ive tried all, but no idea where to tell Xcode to find the static target headers

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 5:16:57 PM4/9/15
to mobile-c...@googlegroups.com
Well after several intents, some advance

Removed CBL iOS and added "CouchbaseLite.framework iOS" to target dependency

Now the problem is the ForestDB as several linker errors appear about not available symbols for armv7

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CBLSpecialKey", referenced from:
      objc-class-ref in libCBLForestDBStorage.a(CBL_ForestDBViewStorage.o)
  "_OBJC_CLASS_$_CBL_Attachment", referenced from:
      objc-class-ref in libCBLForestDBStorage.a(CBL_ForestDBStorage.o)

Jens Alfke

unread,
Apr 9, 2015, 6:30:35 PM4/9/15
to mobile-c...@googlegroups.com

On Apr 9, 2015, at 12:35 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Couchbase compiles well, but my project complains about "CouchbaseLite.h" headers...

Then you’ll need to find your target's “Framework Search Paths” build setting and add the path of the directory containing CouchbaseLite.framework. (Xcode should have added it automatically, but maybe it didn’t.)

—Jens

Jens Alfke

unread,
Apr 9, 2015, 6:34:03 PM4/9/15
to mobile-c...@googlegroups.com
On Apr 9, 2015, at 2:16 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Removed CBL iOS and added "CouchbaseLite.framework iOS" to target dependency

That’s a different framework — it’s a true dynamic framework (as on OS X), not one containing a static library. If you use it, your app will only run on iOS 8+. It’s fine to use it, as long as you’re OK with losing support for earlier OSs.

Now the problem is the ForestDB as several linker errors appear about not available symbols for armv7

Also, the ForestDB code is built into that dynamic framework so you shouldn’t link the separate library into your target.

—Jens

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 6:34:03 PM4/9/15
to mobile-c...@googlegroups.com
After struggling i faced with going back to the standar approach (copy framework from couchbase archive)

But now i'm facing again with several linker errors about "armv7" symbol not available (took libraries from "Archive"):


Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CBLSpecialKey", referenced from:
      objc-class-ref in libCBLForestDBStorage.a(CBL_ForestDBViewStorage.o)
  "_OBJC_CLASS_$_CBL_Attachment", referenced from:
      objc-class-ref in libCBLForestDBStorage.a(CBL_ForestDBStorage.o)

This happens when linking ForestDB storage...

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/EutJZlBUfe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 6:35:40 PM4/9/15
to mobile-c...@googlegroups.com
Uhm sounds interesting, but why it complains about "codesigning"?


--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/EutJZlBUfe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 6:37:56 PM4/9/15
to mobile-c...@googlegroups.com
I'm fine with the backwars compatiblity, as we enforce to use the latest iOS version (very little userbase ~100 users)

Jens Alfke

unread,
Apr 9, 2015, 6:47:28 PM4/9/15
to mobile-c...@googlegroups.com

On Apr 9, 2015, at 3:35 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Uhm sounds interesting, but why it complains about "codesigning"?

A dynamic framework contains a separate binary, which also needs to be code-signed. (OS X developers are used to this, but if you’ve only been developing for iOS it’s never come up because you were never allowed to have multiple binaries until iOS 8…)

Xcode 6 is supposed to automatically code-sign embedded frameworks, though. Maybe there’s a build setting that controls that which you need to enable? Or else you can add a new build phase to run the codesign tool. (Do a web-search for something like “os x codesign framework” and you should find some info.)

—Jens

Frederic Yesid Peña Sánchez

unread,
Apr 9, 2015, 7:14:06 PM4/9/15
to mobile-c...@googlegroups.com
I've finally embedded the framework (ios 8.3)

you say it does not need to add the libCblForestStorageDB.a but it complains when trying to switch storage...

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/EutJZlBUfe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.

Frederic Yesid Peña Sánchez

unread,
Apr 14, 2015, 9:15:59 PM4/14/15
to mobile-c...@googlegroups.com
Hello, i've tried the FTS fix, but keep getting wrong values

Usually getting and array('string','desired value') instead of 'desired_value'...


El jueves, 9 de abril de 2015, 18:14:06 (UTC-5), Frederic Yesid Peña Sánchez escribió:
I've finally embedded the framework (ios 8.3)

you say it does not need to add the libCblForestStorageDB.a but it complains when trying to switch storage...
2015-04-09 17:47 GMT-05:00 Jens Alfke <je...@couchbase.com>:

On Apr 9, 2015, at 3:35 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Uhm sounds interesting, but why it complains about "codesigning"?

A dynamic framework contains a separate binary, which also needs to be code-signed. (OS X developers are used to this, but if you’ve only been developing for iOS it’s never come up because you were never allowed to have multiple binaries until iOS 8…)

Xcode 6 is supposed to automatically code-sign embedded frameworks, though. Maybe there’s a build setting that controls that which you need to enable? Or else you can add a new build phase to run the codesign tool. (Do a web-search for something like “os x codesign framework” and you should find some info.)

—Jens

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/EutJZlBUfe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchbase+unsubscribe@googlegroups.com.

Jens Alfke

unread,
Apr 14, 2015, 10:15:15 PM4/14/15
to mobile-c...@googlegroups.com

On Apr 14, 2015, at 6:15 PM, Frederic Yesid Peña Sánchez <freder...@gmail.com> wrote:

Hello, i've tried the FTS fix, but keep getting wrong values
Usually getting and array('string','desired value') instead of 'desired_value'...

Please file a bug report. With full details (more than what you gave above.) Thanks!

—Jens

Frederic Yesid Peña Sánchez

unread,
Apr 15, 2015, 10:08:13 AM4/15/15
to mobile-c...@googlegroups.com
Hi Jens

I've filled a Bug, this is the link:

https://github.com/couchbase/couchbase-lite-ios/issues/662
Reply all
Reply to author
Forward
0 new messages