本文整理汇总了Java中com.googlecode.cqengine.resultset.ResultSet.size方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.size方法的具体用法?Java ResultSet.size怎么用?Java ResultSet.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.cqengine.resultset.ResultSet
的用法示例。
在下文中一共展示了ResultSet.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asCollection
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
* Returns a Collection-like view of the given ResultSet.
* <p/>
* The collection simply delegates to the ResultSet, which in turn will reflect
* any changes made to the underlying IndexedCollection by other threads.
* For example consecutive calls to the size() method
* may return different values if objects are added to or removed from the IndexedCollection.
*
* @param resultSet The ResultSet to wrap
* @return A Collection-like view of the given ResultSet
*/
public static <O> Collection<O> asCollection(final ResultSet<O> resultSet) {
return new AbstractCollection<O>() {
@Override
public Iterator<O> iterator() {
return resultSet.iterator();
}
@Override
public int size() {
return resultSet.size();
}
@Override
public boolean contains(Object o) {
@SuppressWarnings("unchecked")
O object = (O)o;
return resultSet.contains(object);
}
@Override
public boolean isEmpty() {
return resultSet.isEmpty();
}
};
}
示例2: show
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
* Shows the first n results from the ResultSet r,
* or shows all if the size of the result set is less than n
* @param r
* @param n
*/
private static void show(ResultSet<Resident> r, int n) {
int size = (r.size() > n) ? n : r.size();
if (size > 0) {
System.out.println("Showing "+size+" results:");
for (Resident resident : r) {
System.out.println(" " + resident);
if (--size <= 0) break;
}
}
}
示例3: testNewResultSet_Size
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_Size() throws Exception{
// Mocks
ConnectionManager connectionManager = mock(ConnectionManager.class);
Connection connection = mock(Connection.class);
PreparedStatement preparedStatement = mock(PreparedStatement.class);
java.sql.ResultSet resultSet = mock(java.sql.ResultSet.class);
// Behaviour
when(connectionManager.getConnection(any(SQLiteIndex.class), anyQueryOptions())).thenReturn(connection);
when(connection.prepareStatement("SELECT COUNT(1) AS countDistinct FROM (SELECT objectKey FROM " + TABLE_NAME + " WHERE value = ? GROUP BY objectKey);")).thenReturn(preparedStatement);
when(preparedStatement.executeQuery()).thenReturn(resultSet);
when(resultSet.getStatement()).thenReturn(preparedStatement);
when(resultSet.next()).thenReturn(true);
when(resultSet.getInt(1)).thenReturn(3);
ResultSet<Car> carsWithAbs = new SQLiteIndex<String, Car, Integer>(
Car.FEATURES,
OBJECT_TO_ID,
ID_TO_OBJECT,
"")
.retrieve(equal(Car.FEATURES, "abs"), createQueryOptions(connectionManager));
assertNotNull(carsWithAbs);
int size = carsWithAbs.size();
assertEquals(3, size);
verify(connection, times(0)).close();
}
示例4: testNewResultSet_FilterQuery_Size
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_FilterQuery_Size() throws Exception{
// Mocks
FilterQuery<Car, String> filterQuery = mockFilterQuery();
ConnectionManager connectionManager = mock(ConnectionManager.class);
Connection connection = mock(Connection.class);
Statement statement = mock(PreparedStatement.class);
java.sql.ResultSet resultSet = mock(java.sql.ResultSet.class);
// Behaviour//
when(connectionManager.getConnection(any(SQLiteIndex.class), anyQueryOptions())).thenReturn(connection);
when(connection.createStatement()).thenReturn(statement);
when(statement.executeQuery("SELECT objectKey, value FROM " + TABLE_NAME + " ORDER BY objectKey;")).thenReturn(resultSet);
when(resultSet.getStatement()).thenReturn(statement);
when(resultSet.next()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false);
when(resultSet.getInt(1)).thenReturn(1).thenReturn(1).thenReturn(2).thenReturn(3).thenReturn(4).thenReturn(5);
when(resultSet.getString(2)).thenReturn("abs").thenReturn("gps").thenReturn("airbags").thenReturn("abs").thenReturn("").thenReturn("gps");
ResultSet<Car> carsWithAbs = new SQLiteIndex<String, Car, Integer>(
Car.FEATURES,
OBJECT_TO_ID,
ID_TO_OBJECT,
"")
.retrieve(filterQuery, createQueryOptions(connectionManager));
assertNotNull(carsWithAbs);
int size = carsWithAbs.size();
assertEquals(3, size);
verify(connection, times(0)).close();
}
示例5: runQueryCountResults_CQEngineStatistics
import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Override
public int runQueryCountResults_CQEngineStatistics() {
ResultSet<Car> results = indexedCollection.retrieve(query);
return results.size();
}