RESOLVED FIXED 73686
IndexedDB: Implement IDBObjectStore.count() and IDBIndex.count()
https://bugs.webkit.org/show_bug.cgi?id=73686
Summary IndexedDB: Implement IDBObjectStore.count() and IDBIndex.count()
Joshua Bell
Reported 2011-12-02 13:11:54 PST
IndexedDB: Implement IDBObjectStore.count() and IDBIndex.count()
Attachments
Patch (54.41 KB, patch)
2011-12-02 13:15 PST, Joshua Bell
no flags
Patch (53.46 KB, patch)
2011-12-05 09:40 PST, Joshua Bell
no flags
Patch (53.25 KB, patch)
2011-12-07 12:39 PST, Joshua Bell
no flags
Patch (53.25 KB, patch)
2011-12-07 13:57 PST, Joshua Bell
no flags
Patch (51.25 KB, patch)
2011-12-09 11:43 PST, Joshua Bell
no flags
Joshua Bell
Comment 1 2011-12-02 13:15:19 PST
Joshua Bell
Comment 2 2011-12-02 13:16:26 PST
Ignore the Chromium public API changes here - they'll land via https://bugs.webkit.org/show_bug.cgi?id=73685 first and then be removed from this patch.
WebKit Review Bot
Comment 3 2011-12-02 13:18:43 PST
Please wait for approval from fishd@chromium.org before submitting because this patch contains changes to the Chromium public API.
Joshua Bell
Comment 4 2011-12-02 13:23:03 PST
This is Part 2 of a two-sided change. In between, I'll land http://codereview.chromium.org/8779003 in Chromium.
David Levin
Comment 5 2011-12-02 13:26:51 PST
Comment on attachment 117675 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=117675&action=review Just a drive by comment. > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:554 > + RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; fwiw, you should be able to pass these directly into createCallbackTask.
Hans Wennborg
Comment 6 2011-12-05 03:57:31 PST
Comment on attachment 117675 [details] Patch Looks good to me! View in context: https://bugs.webkit.org/attachment.cgi?id=117675&action=review > Source/WebCore/storage/IDBIndexBackendImpl.cpp:119 > + RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index->m_backingStore->openIndexCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), IDBCursor::NEXT); maybe use openIndexKeyCursor instead to avoid shipping the corresponding object store values across IPC for each index entry. > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:555 > + if (!transaction->scheduleTask( no need to linebreak
Joshua Bell
Comment 7 2011-12-05 09:11:51 PST
Comment on attachment 117675 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=117675&action=review >> Source/WebCore/storage/IDBIndexBackendImpl.cpp:119 >> + RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index->m_backingStore->openIndexCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), IDBCursor::NEXT); > > maybe use openIndexKeyCursor instead to avoid shipping the corresponding object store values across IPC for each index entry. Great catch, thanks!
Joshua Bell
Comment 8 2011-12-05 09:40:55 PST
Joshua Bell
Comment 9 2011-12-07 11:49:39 PST
abarth@ - can you look at the V8 "binding" change? (Note that IDB is still not supported with JSC)
David Levin
Comment 10 2011-12-07 11:56:22 PST
(In reply to comment #5) > (From update of attachment 117675 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=117675&action=review > > Just a drive by comment. > > > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:554 > > + RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; > > fwiw, you should be able to pass these directly into createCallbackTask. This issue still exists.
Joshua Bell
Comment 11 2011-12-07 12:00:20 PST
(In reply to comment #10) > (In reply to comment #5) > > (From update of attachment 117675 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=117675&action=review > > > > Just a drive by comment. > > > > > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:554 > > > + RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; > > > > fwiw, you should be able to pass these directly into createCallbackTask. > > This issue still exists. Ooops, thanks. I must have cleaned up some instances of that pattern and missed the specific one you pointed out. :P
Joshua Bell
Comment 12 2011-12-07 12:39:35 PST
David Grogan
Comment 13 2011-12-07 13:12:43 PST
Comment on attachment 118253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=118253&action=review > Source/WebCore/ChangeLog:9 > + a single IDBKey. That will require some IDL/binding monkeying and it Do we have a bug open about this? I forgot the details. > Source/WebCore/storage/IDBIndex.h:61 > + PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, 0, ec); } This first method will never be called because there's no binding to it, correct? > LayoutTests/storage/indexeddb/index-count.html:63 > + store = evalAndLog("index = store.index('indexName')"); Should this be "index = "? It looks like the test still works because window.index was stored above.
Joshua Bell
Comment 14 2011-12-07 13:56:34 PST
Comment on attachment 118253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=118253&action=review >> Source/WebCore/ChangeLog:9 >> + a single IDBKey. That will require some IDL/binding monkeying and it > > Do we have a bug open about this? I forgot the details. crbug.com/92046 crbug.com/92047 crbug.com/101384 discuss other methods; I'll file a bug for this method >> Source/WebCore/storage/IDBIndex.h:61 >> + PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, 0, ec); } > > This first method will never be called because there's no binding to it, correct? The KeyRange argument is defined as Optional in the IDL; the generated binding code calls this first method if no arguments are passed on the JavaScript side. >> LayoutTests/storage/indexeddb/index-count.html:63 >> + store = evalAndLog("index = store.index('indexName')"); > > Should this be "index = "? It looks like the test still works because window.index was stored above. Good catch. But actually, in the pattern used in most of our tests: FOO = evalAndLog("BAR = EXPR"); ...both window.FOO and window.BAR end up being set to the result of EXPR. We don't need both, but the inner one is logged and the outer one makes subsequent local uses more readable. So this worked because nothing later was dependent on window.store. Ah, JavaScript global variables...
Joshua Bell
Comment 15 2011-12-07 13:57:56 PST
Joshua Bell
Comment 16 2011-12-09 11:43:29 PST
Joshua Bell
Comment 17 2011-12-09 11:44:33 PST
This should be the final patch (same as previous, just minus the WebKit/chromium/public changes). Needs to wait for the Chromium side to land.
Joshua Bell
Comment 18 2011-12-16 12:13:58 PST
Comment on attachment 118600 [details] Patch Chromium side has landed, should be good to go.
Joshua Bell
Comment 19 2011-12-16 12:15:04 PST
tony@, can you r? cq?
David Grogan
Comment 20 2011-12-16 12:20:54 PST
Comment on attachment 118600 [details] Patch IDB functionality LGTM
Tony Chang
Comment 21 2011-12-16 12:42:13 PST
Comment on attachment 118600 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=118600&action=review > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:566 > + do { > + ++count; > + } while (backingStoreCursor->continueFunction(0)); This seems really inefficient. Is this the only way to get the count?
Joshua Bell
Comment 22 2011-12-16 13:15:22 PST
(In reply to comment #21) > (From update of attachment 118600 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=118600&action=review > > > Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp:566 > > + do { > > + ++count; > > + } while (backingStoreCursor->continueFunction(0)); > > This seems really inefficient. Is this the only way to get the count? LevelDB doesn't have a count primitive, at the moment. We'll need to follow up on that as we do some IDB refactoring.
WebKit Review Bot
Comment 23 2011-12-16 13:27:22 PST
Comment on attachment 118600 [details] Patch Clearing flags on attachment: 118600 Committed r103100: <http://trac.webkit.org/changeset/103100>
WebKit Review Bot
Comment 24 2011-12-16 13:27:29 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.