-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: more flexible Function interface for non-String args #57
Comments
Thanks for the detailed issue! yes I think having a way to read arguments in a CustomFunction interface makes sense, instead of just passing them all as strings. |
Closed by #61 :) |
Please make a release with this @npurushe And how did @dhleong solve the matchinfo parsing with this feature? Which type did you use? |
Yep, it's kotlin. That code was the workaround for using the old Strings interface, and doesn't actually work super well in all cases, which is why I submitted the PR. If you use the code from #61, it's much simpler. The // for a call like rank(matchinfo(index, 'nlpx')):
val buffer = ByteBuffer.wrap(args.getBlob(0))
val totalDocsCount = buffer.int // 'n'
val documentSize = buffer.int // 'l'
val phrases = buffer.int // 'p'
val hitCount = buffer.int // 'x[0]'
buffer.int // skip x[1]
val docsWithHits = buffer.int // 'x[2]' |
Also, since I may have misunderstood your question and maybe you were actually not sure what the kotlin was doing, the The |
Thanks a lot!! |
I believe the sqlite docs say it's native order.
…On Sun, Feb 25, 2018, 2:55 AM Morten Holmgaard ***@***.***> wrote:
Thanks a lot!!
It works great with getBlob. I have spend a lot of hours to try to make
the SQLiteCustomFunction work with matchinfo.
Do you know if we should use ByteOrder.nativeOrder() make sure to support
all devices or just ByteOrder.LITTLE_ENDIAN for the sqlite blob?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#57 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAx0FnDUQvv6C16MTEA2HjFi0x4OBt3fks5tYRIIgaJpZM4RdOpa>
.
|
In particular, accessing
matchinfo()
in a customrank()
function is a bit tricky. I see #39 suggests just writing it in C and I may eventually want to do that, but for now I have a rather hacky workaround:This works, but for each call to
rank()
it allocates the String, the Byte Array it contains, the String Array to hold the String, the Byte Array copy from the String, and the IntArray that ultimately holds the results. This is because the Int32s from sqlite'smatchinfo()
get packed into a UTF-16 string. xerial's JDBC client calls into some native functions to access the passed arguments directly, to avoid all those "middle man" allocations.Now, lacking this sort of implementation on Android I can't benchmark to check if the allocation overhead would be worse than the JNI overhead, but that is my suspicion. A
Function2
interface would also be more intuitive for these use cases, and avoids clients having to deal with NDK, which I think fits with the original goals for this project.My hacky workaround seems to be performing okay for my dataset right now, but I wanted to put up this proposal to test the waters and see how difficult you guys think it'd be, and whether it's something you'd even be interested in. I'd be interesting in working on this myself, but I'm pretty busy with other parts of my project and it's not yet critical for me, so I didn't want to start without a nod of interest, and maybe a nudge in the right direction ;)
The text was updated successfully, but these errors were encountered: