Add custom scalar/aggregate functions to SQLite.
SQLite ships with a handful of basic functions, such as UPPER() as a scalar function and MAX() as a aggregate function. We now have several use-cases for adding custom functions, where it's otherwise prohibitively expensive to perform post-processing on the returned Cursor, as that requires copying processed data to yet another MatrixCursor before returning to apps. This change adds the ability for developers to register custom scalar and aggregate functions on databases that they've opened; some contrived examples are scalar functions like REVERSE() for reversing a string, or aggregate functions like STDDEV(). To give developers the most flexibility, we use the Java functional interfaces for defining these operations, as developers may already be familiar with the contracts of those methods. This also opens the door to quickly adapting existing code through utility methods like BinaryOperator.minBy(Comparator). Bug: 142564473 Test: atest CtsDatabaseTestCases:android.database.sqlite.cts.SQLiteDatabaseTest Change-Id: I9fa0e60ec77bab676396729cc9cb8ba8aaf56224
Loading
Please register or sign in to comment