Skip to content

Commit ac61a5a

Browse files
committed
Optimizing size() to use queryCount by default, added longSize() as well
1 parent d7459d1 commit ac61a5a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/java/picoded/dstack/DataObjectMap.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,26 @@ default String[] getFromKeyName_id(String keyName, String orderByStr, int offset
312312
return retList.toArray(new String[retList.size()]);
313313
}
314314

315+
//
316+
// Query count optimization handling
317+
//--------------------------------------------------------------------------
318+
319+
/**
320+
* Get the size of the current DataObjectMap
321+
**/
322+
@Override
323+
default int size() {
324+
return queryCount(null,null);
325+
}
326+
327+
/**
328+
* Get the size as a long for the DataObjectMap
329+
* This should be used instead of size (to work around int limits)
330+
*/
331+
default long longSize() {
332+
return queryCount(null,null);
333+
}
334+
315335
//
316336
// Get key names handling
317337
//--------------------------------------------------------------------------

0 commit comments

Comments
 (0)