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


Java ResultSet.close方法代码示例

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


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

示例1: retrieve

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void retrieve() {
    IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();

    // Add some indexes...
    UniqueIndex index = onAttribute(Car.FEATURES);
    cars.addIndex(index);
    index.clear(noQueryOptions());

    // Add some objects to the collection...
    cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
    cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));

    ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
    assertEquals(radio.size(), 1);
    radio.close();
    ResultSet<EntityHandle<Car>> unknown = cars.retrieve(equal(Car.FEATURES, "unknown"));
    assertEquals(unknown.size(), 0);
    unknown.close();
    index.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:22,代码来源:UniqueIndexTest.java

示例2: indexingExistingData

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexingExistingData() {
    IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();
    UniqueIndex index = onAttribute(Car.FEATURES);
    index.clear(noQueryOptions());

    // Add some objects to the collection...
    cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
    cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));

    // Add some indexes...
    cars.addIndex(index);

    ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
    assertEquals(radio.size(), 1);
    radio.close();
    ResultSet<EntityHandle<Car>> unknown = cars.retrieve(equal(Car.FEATURES, "unknown"));
    assertEquals(unknown.size(), 0);
    unknown.close();
    index.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:22,代码来源:UniqueIndexTest.java

示例3: reindexData

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void reindexData() {
    IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();
    UniqueIndex index = onAttribute(Car.FEATURES);
    index.clear(noQueryOptions());

    // Add some objects to the collection...
    cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
    cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));


    cars.addIndex(index);

    IndexedCollection<EntityHandle<Car>> cars1 = new ConcurrentIndexedCollection<>();
    UniqueIndex index1 = onAttribute(Car.FEATURES);
    cars1.addAll(cars);

    cars1.addIndex(index1);

    ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
    assertEquals(radio.size(), 1);
    radio.close();

    index.clear(noQueryOptions());
    index1.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:27,代码来源:UniqueIndexTest.java

示例4: indexQuantization_SpanningTwoBucketsMidRange

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexQuantization_SpanningTwoBucketsMidRange() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
                                                              Car.CAR_ID);
    index.clear(noQueryOptions());
    collection.addIndex(index);
    collection.addAll(CarFactory.createCollectionOfCars(100));

    // Merge cost should be 20 because this query spans 2 buckets (each containing 10 objects)...
    ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 47, 53));
    assertEquals(resultSet.getMergeCost(), 20);
    resultSet.close();

    // 7 objects match the query (between is inclusive)...
    resultSet = collection.retrieve(between(Car.CAR_ID, 47, 53));
    assertEquals(resultSet.size(), 7);
    resultSet.close();

    // The matching objects are...
    List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 47, 53));
    assertEquals(carIdsFound, asList(47, 48, 49, 50, 51, 52, 53));
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:24,代码来源:NavigableIndexTest.java

示例5: indexQuantization_FirstBucket

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexQuantization_FirstBucket() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
                                                              Car.CAR_ID);
    index.clear(noQueryOptions());
    collection.addIndex(index);
    collection.addAll(CarFactory.createCollectionOfCars(100));

    // Merge cost should be 10, because objects matching this query are in a single bucket...
    ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 2, 4));
    assertEquals(resultSet.getMergeCost(), 10);
    resultSet.close();

    // 3 objects match the query...
    resultSet = collection.retrieve(between(Car.CAR_ID, 2, 4));
    assertEquals(resultSet.size(), 3);
    resultSet.close();

    List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 2, 4));
    assertEquals(carIdsFound, asList(2, 3, 4));
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:23,代码来源:NavigableIndexTest.java

示例6: indexQuantization_LastBucket

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexQuantization_LastBucket() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
                                                              Car.CAR_ID);
    index.clear(noQueryOptions());
    collection.addIndex(index);
    collection.addAll(CarFactory.createCollectionOfCars(100));

    // Merge cost should be 10, because objects matching this query are in a single bucket...
    ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 96, 98));
    assertEquals(resultSet.getMergeCost(), 10);
    resultSet.close();

    // 3 objects match the query...
    resultSet = collection.retrieve(between(Car.CAR_ID, 96, 98));
    assertEquals(resultSet.size(), 3);
    resultSet.close();

    List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 96, 98));
    assertEquals(carIdsFound, asList(96, 97, 98));
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:23,代码来源:NavigableIndexTest.java

示例7: indexQuantization_ComplexQuery

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexQuantization_ComplexQuery() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
                                                              Car.CAR_ID);
    index.clear(noQueryOptions());
    collection.addIndex(index);
    collection.addAll(CarFactory.createCollectionOfCars(100));
    Query<EntityHandle<Car>> query = and(between(Car.CAR_ID, 96, 98), greaterThan(Car.CAR_ID, 95));

    // 3 objects match the query...
    ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(query);
    assertEquals(resultSet.size(), 3);
    resultSet.close();

    List<Integer> carIdsFound = retrieveCarIds(collection, query);
    assertEquals(carIdsFound, asList(96, 97, 98));

    // Merge cost should be 10, because objects matching this query are in a single bucket...
    resultSet = collection.retrieve(query);
    assertEquals(resultSet.getMergeCost(), 10);
    resultSet.close();
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:24,代码来源:NavigableIndexTest.java

示例8: retrieveEqual

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void retrieveEqual() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    KeyStatisticsIndex<String, EntityHandle<Car>> MANUFACTURER_INDEX =
            (KeyStatisticsIndex<String, EntityHandle<Car>>) onAttribute(Car.MANUFACTURER);
    MANUFACTURER_INDEX.clear(noQueryOptions());

    collection.addIndex(MANUFACTURER_INDEX);

    collection.addAll(CarFactory.createCollectionOfCars(10));

    ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(Car.MANUFACTURER, "Honda"));
    assertTrue(cars.isNotEmpty());
    assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));

    cars.close();
    MANUFACTURER_INDEX.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:19,代码来源:EqualityIndexTest.java

示例9: byteArrayEquality

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void byteArrayEquality() {
    IndexedCollection<EntityHandle<Car>> collection = createIndexedCollection(Car.class);
    SimpleAttribute<Car, byte[]> attr = new SimpleAttribute<Car, byte[]>(Car.class,
                                                                        (Class<EntityHandle<Car>>) ((Class<?>)getClass()),
                                                                        byte[].class, "bytearray") {

        @Override public byte[] getValue(Car object, QueryOptions queryOptions) {
            return object.getManufacturer().getBytes();
        }
    };
    HashIndex index = onAttribute(attr);
    index.clear(noQueryOptions());

    collection.addIndex(index);

    collection.addAll(CarFactory.createCollectionOfCars(10));

    ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(attr, "Honda".getBytes()));
    assertTrue(cars.isNotEmpty());
    assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));

    cars.close();
    index.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:26,代码来源:EqualityIndexTest.java

示例10: retrieveHas

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void retrieveHas() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    KeyStatisticsIndex<String, EntityHandle<Car>> MANUFACTURER_INDEX =
            (KeyStatisticsIndex<String, EntityHandle<Car>>) onAttribute(Car.MANUFACTURER);
    MANUFACTURER_INDEX.clear(noQueryOptions());
    collection.addIndex(MANUFACTURER_INDEX);

    Set<EntityHandle<Car>> coll = CarFactory.createCollectionOfCars(10);
    collection.addAll(coll);

    ResultSet<EntityHandle<Car>> cars = collection.retrieve(has(Car.MANUFACTURER));
    assertTrue(cars.isNotEmpty());
    assertEquals(cars.size(), coll.size());

    cars.close();
    MANUFACTURER_INDEX.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:19,代码来源:EqualityIndexTest.java

示例11: indexExistingData

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Test
public void indexExistingData() {
    IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
    KeyStatisticsIndex<String, EntityHandle<Car>> MANUFACTURER_INDEX =
            (KeyStatisticsIndex<String, EntityHandle<Car>>) onAttribute(Car.MANUFACTURER);
    MANUFACTURER_INDEX.clear(noQueryOptions());

    collection.addAll(CarFactory.createCollectionOfCars(10));

    collection.addIndex(MANUFACTURER_INDEX);

    ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(Car.MANUFACTURER, "Honda"));
    assertTrue(cars.isNotEmpty());
    assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));

    cars.close();
    MANUFACTURER_INDEX.clear(noQueryOptions());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:19,代码来源:EqualityIndexTest.java

示例12: where

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
/**
 * Returns all the elements contained in the internal
 * collection that match the given {@link Query}
 * @param <Q>
 * @param obj
 * @return a {@link Stream} of results
 */
@Override @SuppressWarnings({ "unchecked", "rawtypes" })
public <Q> Stream<T> where(Q obj) {
    if(obj instanceof Query){
        Query<T> query = (Query<T>)obj;
        ResultSet rs =coll.retrieve(query);
        
        try(Stream<T> stream = StreamSupport.stream(rs.spliterator(),false)){
            List<T> buf = stream.collect(Collectors.toList());
            return buf.stream();
        }
        finally{
            rs.close();
        }
    }
    
    throw new IllegalArgumentException(getClass().getName() +" does not support " + obj.getClass().getName() + " for querying");
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:25,代码来源:CacheReadOperation.java

示例13: iterator

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Override
public CloseableIterator<O> iterator(QueryOptions queryOptions) {
    final ResultSet<O> rs = backingIndex.retrieve(has(primaryKeyAttribute), queryOptions);
    final Iterator<O> i = rs.iterator();
    class CloseableIteratorImpl extends UnmodifiableIterator<O> implements CloseableIterator<O> {

        @Override
        public boolean hasNext() {
            return i.hasNext();
        }

        @Override
        public O next() {
            return i.next();
        }

        @Override
        public void close() {
            rs.close();
        }
    }
    return new CloseableIteratorImpl();
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:24,代码来源:SQLiteObjectStore.java

示例14: retainAll

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Override
public boolean retainAll(Collection<?> c, QueryOptions queryOptions) {
    // Note: this could be optimized...
    Collection<O> objectsToRemove = new ArrayList<O>();
    ResultSet<O> allObjects = backingIndex.retrieve(has(primaryKeyAttribute), queryOptions);
    try {
        for (O object : allObjects) {
            if (!c.contains(object)) {
                objectsToRemove.add(object);
            }
        }
    }
    finally {
        allObjects.close();
    }
    return backingIndex.removeAll(ObjectSet.fromCollection(objectsToRemove), queryOptions);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:18,代码来源:SQLiteObjectStore.java

示例15: run

import com.googlecode.cqengine.resultset.ResultSet; //导入方法依赖的package包/类
@Override
public void run() {
    sequenceLog.add(taskName + " started and about to access collection");
    ResultSet<Car> backgroundResults = collection.retrieve(between(Car.CAR_ID, 40, 59));
    Iterator<Car> iterator = backgroundResults.iterator();
    int count = 0;
    for (; iterator.hasNext() && count < 5; count++) {
        iterator.next();
    }
    sequenceLog.add(taskName + " pausing mid-read");
    sleep(millisecondsToPauseMidRequest);
    sequenceLog.add(taskName + " resuming read");
    while (iterator.hasNext()) {
        iterator.next();
        count++;
    }
    backgroundResults.close();
    sequenceLog.add(taskName + " finished reading " + count + " items");
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:20,代码来源:OffHeapPersistenceConcurrencyTest.java


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