public FastCursor(CursorWindow window) { this.window = window; count = window.getNumRows(); }
@Override public int getCount() { return window.getNumRows(); }
private void loadAllUnlockOnWindowBounds(Cursor cursor, CursorWindow window, List<T> list) { int windowEnd = window.getStartPosition() + window.getNumRows(); for (int row = 0; ; row++) { list.add(loadCurrent(cursor, 0, false)); row++; if (row >= windowEnd) { window = moveToNextUnlocked(cursor); if (window == null) { break; } windowEnd = window.getStartPosition() + window.getNumRows(); } else { if (!cursor.moveToNext()) { break; } } } }
public CursorWindowAssert hasRowCount(int count) { isNotNull(); int actualCount = actual.getNumRows(); assertThat(actualCount) // .overridingErrorMessage("Expected row count <%s> but was <%s>.", count, actualCount) // .isEqualTo(count); return this; }
window = ((CrossProcessCursor) cursor).getWindow(); if (window != null) { // E.g. Robolectric has no Window at this point if (window.getNumRows() == count) { cursor = new FastCursor(window); useFastCursor = true; } else { DaoLog.d("Window vs. result size: " + window.getNumRows() + "/" + count);
@Test public void shouldFillWindowWithCursor() throws Exception { CursorWindow window = new CursorWindow("name"); MatrixCursor testCursor = new MatrixCursor(new String[] { "a", "b", "c", "d"}); testCursor.addRow(new Object[] { 12, "hello", null, new byte[] {(byte) 0xba, (byte) 0xdc, (byte) 0xaf, (byte) 0xfe} }); testCursor.addRow(new Object[] { 34, "baz", 1.2, null }); testCursor.addRow(new Object[] { 46, "foo", 2.4, new byte[]{} }); DatabaseUtils.cursorFillWindow(testCursor, 0, window); assertThat(window.getNumRows()).isEqualTo(3); assertThat(window.getInt(0, 0)).isEqualTo(12); assertThat(window.getString(0, 1)).isEqualTo("hello"); assertThat(window.getString(0, 2)).isNull(); assertThat(window.getBlob(0, 3)).isEqualTo(new byte[] {(byte) 0xba, (byte) 0xdc, (byte) 0xaf, (byte) 0xfe}); assertThat(window.getInt(1, 0)).isEqualTo(34); assertThat(window.getString(1, 1)).isEqualTo("baz"); assertThat(window.getFloat(1, 2)).isEqualTo(1.2f); assertThat(window.getBlob(1, 3)).isEqualTo(null); assertThat(window.getBlob(2, 3)).isEqualTo(new byte[]{}); } }
@Override public boolean onMove(int oldPosition, int newPosition) { // Make sure the row at newPosition is present in the window if (mWindow == null || newPosition < mWindow.getStartPosition() || newPosition >= (mWindow.getStartPosition() + mWindow.getNumRows())) { fillWindow(newPosition); } return true; }
private void fillWindow(int requiredPos) { awc_clearOrCreateWindow(getDatabase().getPath()); try { if (mCount == NO_COUNT) { int startPos = ExtraUtils.cursorPickFillWindowStartPosition(requiredPos, 0); mCount = mQuery.fillWindow(mWindow, startPos, requiredPos, true); mCursorWindowCapacity = mWindow.getNumRows(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "received count(*) from native_fill_window: " + mCount); } } else { int startPos = ExtraUtils.cursorPickFillWindowStartPosition(requiredPos, mCursorWindowCapacity); mQuery.fillWindow(mWindow, startPos, requiredPos, false); } } catch (RuntimeException ex) { // Close the cursor window if the query failed and therefore will // not produce any results. This helps to avoid accidentally leaking // the cursor window if the client does not correctly handle exceptions // and fails to close the cursor. awc_closeWindow(); throw ex; } }
try { executeForCursorWindow("PRAGMA database_list;", null, window, 0, 0, false, null); for (int i = 1; i < window.getNumRows(); i++) { String name = window.getString(i, 1); String path = window.getString(i, 2);
public FastCursor(CursorWindow window) { this.window = window; count = window.getNumRows(); }
public FastCursor(CursorWindow window) { this.window = window; count = window.getNumRows(); }
@Override public int getCount() { return window.getNumRows(); }
@Override public int getCount() { return window.getNumRows(); }
public FastCursor(CursorWindow window) { this.window = window; count = window.getNumRows(); }
@Override public int getCount() { return window.getNumRows(); }
/** * Gets the number of rows in the data holder. * * @return the number of rows in the data holder. */ public int getCount() { int c = 0; if (windows != null) { for (CursorWindow window : windows) { c += window.getNumRows(); } } return c; }
actualPos = (int)(result >> 32); countedRows = (int)result; filledRows = window.getNumRows(); window.setStartPosition(actualPos); return countedRows;
public CursorWindowAssert hasRowCount(int count) { isNotNull(); int actualCount = actual.getNumRows(); assertThat(actualCount) // .overridingErrorMessage("Expected row count <%s> but was <%s>.", count, actualCount) // .isEqualTo(count); return this; }
private void loadAllUnlockOnWindowBounds(Cursor cursor, CursorWindow window, List<T> list) { int windowEnd = window.getStartPosition() + window.getNumRows(); for (int row = 0; ; row++) { list.add(loadCurrent(cursor, 0, false)); row++; if (row >= windowEnd) { window = moveToNextUnlocked(cursor); if (window == null) { break; } windowEnd = window.getStartPosition() + window.getNumRows(); } else { if (!cursor.moveToNext()) { break; } } } }
@Override public boolean onMove(int oldPosition, int newPosition) { // Make sure the row at newPosition is present in the window if (mWindow == null || newPosition < mWindow.getStartPosition() || newPosition >= (mWindow.getStartPosition() + mWindow.getNumRows())) { fillWindow(newPosition); } return true; }