Git Product home page Git Product logo

Comments (7)

npurushe avatar npurushe commented on August 25, 2024

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.

from sqlite-android.

dhleong avatar dhleong commented on August 25, 2024

Closed by #61 :)

from sqlite-android.

mortenholmgaard avatar mortenholmgaard commented on August 25, 2024

Please make a release with this @npurushe

And how did @dhleong solve the matchinfo parsing with this feature? Which type did you use?
I have some problems getting the matchinfo parsed correctly (signed/unsinged types! and more)
I the code you added in the inital case, kotlin? I am having trouble with this line in java: longBuf.get().toInt()

from sqlite-android.

dhleong avatar dhleong commented on August 25, 2024

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 matchinfo() function returns a Blob that you can wrap in a ByteBuffer:

          // 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]'

from sqlite-android.

dhleong avatar dhleong commented on August 25, 2024

Also, since I may have misunderstood your question and maybe you were actually not sure what the kotlin was doing, the .toInt() there was just casting the result of longBuf.get() to an int; Kotlin doesn't let you just cast between primitive types; you have to explicitly convert them.

The .int calls in the above example code actually compile to .getInt() calls on the ByteBuffer. It's part of Kotlin's automatic conversion of getters and setters to "properties."

from sqlite-android.

mortenholmgaard avatar mortenholmgaard commented on August 25, 2024

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?

from sqlite-android.

dhleong avatar dhleong commented on August 25, 2024

from sqlite-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.