diff options
| author | Brad Fitzpatrick <bradfitz@android.com> | 2010-03-09 13:18:02 -0800 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@android.com> | 2010-03-09 15:20:21 -0800 |
| commit | 9ffdfa0c238fce3b85741d7f6828fd484cd8f195 (patch) | |
| tree | b187b4936d33363f652e5d0cd5d1d2e9bfa577b7 /core/java/android/database/sqlite | |
| parent | 33d1fdd6aa9ac9b59295756f151a49f2cf520691 (diff) | |
Speed up ContentProvider.query() in simple case by ~30%
When query() uses bulkQuery() and we know we're going to need some
metadata right afterwards (number of rows and column index of _id, if
present), just asked for it in the initial binder transaction instead
of immediately fetching it again.
Also, this defers loading column names until the client asks for them.
This gets down the simpler (and very common) use cases of
ContentProvider.query() down to 3 binder calls:
QUERY_TRANSACTION to android.content.ContentProvider$Transport
GET_CURSOR_WINDOW_TRANSACTION to android.database.CursorToBulkCursorAdaptor
CLOSE_TRANSACTION to android.database.CursorToBulkCursorAdaptor
More can still be done, but this is a good bite-sized first piece.
Change-Id: I7ad45949f53e0097ff18c2478d659f0f36929693
Diffstat (limited to 'core/java/android/database/sqlite')
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteClosable.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/database/sqlite/SQLiteClosable.java b/core/java/android/database/sqlite/SQLiteClosable.java index e589f3411a88..71fa2c2acc0c 100644 --- a/core/java/android/database/sqlite/SQLiteClosable.java +++ b/core/java/android/database/sqlite/SQLiteClosable.java @@ -19,14 +19,15 @@ package android.database.sqlite; import android.database.CursorWindow; /** - * An object create from a SQLiteDatabase that can be closed. + * An object created from a SQLiteDatabase that can be closed. */ -public abstract class SQLiteClosable { +public abstract class SQLiteClosable { private int mReferenceCount = 1; private Object mLock = new Object(); + protected abstract void onAllReferencesReleased(); - protected void onAllReferencesReleasedFromContainer(){} - + protected void onAllReferencesReleasedFromContainer() {} + public void acquireReference() { synchronized(mLock) { if (mReferenceCount <= 0) { @@ -36,7 +37,7 @@ public abstract class SQLiteClosable { mReferenceCount++; } } - + public void releaseReference() { synchronized(mLock) { mReferenceCount--; @@ -45,14 +46,14 @@ public abstract class SQLiteClosable { } } } - + public void releaseReferenceFromContainer() { synchronized(mLock) { mReferenceCount--; if (mReferenceCount == 0) { onAllReferencesReleasedFromContainer(); } - } + } } private String getObjInfo() { |
