当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getMergeCost方法代码示例

本文整理汇总了Java中com.googlecode.cqengine.resultset.ResultSet.getMergeCost方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getMergeCost方法的具体用法?Java ResultSet.getMergeCost怎么用?Java ResultSet.getMergeCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.googlecode.cqengine.resultset.ResultSet的用法示例。


在下文中一共展示了ResultSet.getMergeCost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Override
public int compare(ResultSet o1, ResultSet o2) {
    final int o1MergeCost = o1.getMergeCost();
    final int o2MergeCost = o2.getMergeCost();
    if (o1MergeCost < o2MergeCost) {
        return -1;
    }
    else if (o1MergeCost > o2MergeCost) {
        return +1;
    }
    else {
        return 0;
    }
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:15,代码来源:QueryCostComparators.java

示例2: getMergeCost

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns the sum of the merge costs of the the underlying {@code ResultSet}s.
 * @return the sum of the merge costs of the the underlying {@code ResultSet}s
 */
@Override
public int getMergeCost() {
    long mergeCost = 0;
    for (ResultSet<O> resultSet : this.resultSets) {
        mergeCost = mergeCost + resultSet.getMergeCost();
    }
    return (int)Math.min(mergeCost, Integer.MAX_VALUE);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:13,代码来源:ResultSetUnionAll.java

示例3: getMergeCost

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns the merge cost from the underlying {@code ResultSet} with the lowest merge cost.
 * @return the merge cost from the underlying {@code ResultSet} with the lowest merge cost
 */
@Override
public int getMergeCost() {
    if (resultSets.isEmpty()) {
        return 0;
    }
    else {
        ResultSet<O> lowestMergeCostResultSet = resultSets.get(0);
        return lowestMergeCostResultSet.getMergeCost();
    }
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:15,代码来源:ResultSetIntersection.java

示例4: testNewResultSet_GetMergeCost

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_GetMergeCost() 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(objectKey) FROM " + TABLE_NAME + " WHERE value = ?;")).thenReturn(preparedStatement);
    when(preparedStatement.executeQuery()).thenReturn(resultSet);
    when(resultSet.getStatement()).thenReturn(preparedStatement);
    when(resultSet.next()).thenReturn(true);
    when(resultSet.getInt(1)).thenReturn(3);

    // Iterator
    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.getMergeCost();

    assertEquals(3, size);
    verify(connection, times(0)).close();

}
 
开发者ID:npgall,项目名称:cqengine,代码行数:34,代码来源:SQLiteIndexTest.java

示例5: testNewResultSet_FilterQuery_GetMergeCost

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void testNewResultSet_FilterQuery_GetMergeCost() throws Exception{

    // Mocks
    FilterQuery<Car, String> filterQuery = mockFilterQuery();
    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(objectKey) FROM " + TABLE_NAME + " ;")).thenReturn(preparedStatement);
    when(preparedStatement.executeQuery()).thenReturn(resultSet);
    when(resultSet.getStatement()).thenReturn(preparedStatement);
    when(resultSet.next()).thenReturn(true);
    when(resultSet.getInt(1)).thenReturn(3);

    // Iterator
    ResultSet<Car> cars = new SQLiteIndex<String, Car, Integer>(
            Car.FEATURES,
            OBJECT_TO_ID,
            ID_TO_OBJECT,
            "")

            .retrieve(filterQuery, createQueryOptions(connectionManager));

    assertNotNull(cars);
    int mergeCost = cars.getMergeCost();

    assertEquals(3, mergeCost);
    verify(connection, times(0)).close();
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:34,代码来源:SQLiteIndexTest.java


注:本文中的com.googlecode.cqengine.resultset.ResultSet.getMergeCost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。