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


Java ResultSet类代码示例

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


ResultSet类属于com.googlecode.cqengine.resultset包,在下文中一共展示了ResultSet类的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: getCollectionStream

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Override public Stream<Restaurant> getCollectionStream(Repository repository) {
    Query<EntityHandle<AddressChanged>> geoRestrictions = and(
            lessThanOrEqualTo(AddressChanged.BOUNDING_BOX_10K_LAT_START, address.latitude()),
            lessThanOrEqualTo(AddressChanged.BOUNDING_BOX_10K_LONG_START, address.longitude()),
            greaterThanOrEqualTo(AddressChanged.BOUNDING_BOX_10K_LAT_END, address.latitude()),
            greaterThanOrEqualTo(AddressChanged.BOUNDING_BOX_10K_LONG_END, address.longitude()));
    Query<EntityHandle<AddressChanged>> isRestaurant = existsIn(
            repository.getIndexEngine().getIndexedCollection(RestaurantRegistered.class),
            AddressChanged.REFERENCE_ID, RestaurantRegistered.ID);
    Query<EntityHandle<AddressChanged>> latestEntity =
            isLatestEntity(repository.getIndexEngine().getIndexedCollection(AddressChanged.class),
                           (v) -> equal(AddressChanged.REFERENCE_ID, v.get().reference()),
                           AddressChanged.TIMESTAMP);
    Query<EntityHandle<AddressChanged>> query = and(latestEntity, geoRestrictions, isRestaurant);
    ResultSet<EntityHandle<AddressChanged>> resultSet = repository.query(AddressChanged.class, query);
    return streamOf(resultSet)
            .map(h -> new Restaurant(repository, h.get().reference()))
            .onClose(resultSet::close);
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:20,代码来源:Restaurant.java

示例3: openingHours

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
public Map<Integer, List<OpeningHours>> openingHours() {
    return
    Arrays.stream(DayOfWeek.values())
          .map(dow -> {
              Query<EntityHandle<WorkingHoursChanged>> scope = QueryFactory.and(equal(WorkingHoursChanged
                                                                                          .REFERENCE_ID, getId()),
                                                                              equal(WorkingHoursChanged.DAY_OF_WEEK, dow));
              Query<EntityHandle<WorkingHoursChanged>> query =
                      scoped(scope, max(WorkingHoursChanged.TIMESTAMP));
              try (ResultSet<EntityHandle<WorkingHoursChanged>> resultSet =
                           getRepository().query(WorkingHoursChanged.class, query)) {
                  return resultSet.uniqueResult().get();
              }
              })
            .collect(Collectors.toMap(e -> e.dayOfWeek().getValue(), WorkingHoursChanged::openDuring));
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:17,代码来源:Restaurant.java

示例4: withQuantizerOnAttribute

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
public static <A extends Comparable<A>, O extends Entity> NavigableIndex<A, O>
       withQuantizerOnAttribute(DataSource dataSource, Quantizer<A> quantizer, Attribute<O, A> attribute) {
    return new NavigableIndex<A, O>(dataSource, (Attribute<O, A>) serializableComparable(attribute)) {
        @Override public boolean isQuantized() {
            return true;
        }

        @Override protected A getQuantizedValue(A attributeValue) {
            return quantizer.getQuantizedValue(attributeValue);
        }

        @Override
        public ResultSet<EntityHandle<O>> retrieve(Query<EntityHandle<O>> query, QueryOptions queryOptions) {
            ResultSet<EntityHandle<O>> rs = super.retrieve(query, queryOptions);
            return new QuantizedResultSet<>(rs, query, queryOptions);
        }
    };
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:19,代码来源:NavigableIndex.java

示例5: dropInvalidIndex_a4d6771

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
private void dropInvalidIndex_a4d6771(Connection connection) throws SQLException {
    if (getAttribute().getAttributeType() == HybridTimestamp.class) {
        try (PreparedStatement s = connection
                .prepareStatement("SELECT count(column_name) from information_schema.columns where " +
                                      "lower(table_name) = lower(?) AND lower(column_name) = 'key' " +
                                      " AND lower(data_type) != 'numeric'")) {
            s.setString(1, tableName);
            try (java.sql.ResultSet rs = s.executeQuery()) {
                if (rs.next()) {
                    if (rs.getInt(1) > 0) {
                        try (PreparedStatement drop = connection.prepareStatement("DROP TABLE " + tableName)) {
                            drop.executeUpdate();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:20,代码来源:NavigableIndex.java

示例6: apply

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@SneakyThrows
@Override public Stream<Event> apply(Class<? extends Entity> entity) {
Layout<? extends Entity> layout = Layout.forClass(entity);
    byte[] fingerprint = layout.getHash();
    Query<EntityHandle<EntityLayoutIntroduced>> query = equal(EntityLayoutIntroduced.FINGERPRINT, fingerprint);
    try (ResultSet<EntityHandle<EntityLayoutIntroduced>> resultSet = repository
            .query(EntityLayoutIntroduced.class,
                   query)) {
        if (resultSet.isEmpty()) {
            return Stream.of(new EntityLayoutIntroduced(fingerprint, Optional.of(layout)));
        } else {
            return Stream.empty();
        }
    }


}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:18,代码来源:IntroduceEntityLayouts.java

示例7: streamExceptionIndexing

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Test
@SneakyThrows
public void streamExceptionIndexing() {
    IndexedCollection<EntityHandle<TestEvent>> coll = indexEngine.getIndexedCollection(TestEvent.class);
    coll.clear();
    UUID eventUUID = UUID.randomUUID();
    StreamExceptionCommand command = StreamExceptionCommand.builder().eventUUID(eventUUID).build();
    CompletableFuture<Void> future = repository.publish(command);
    while (!future.isDone()) { Thread.sleep(10); } // to avoid throwing an exception
    assertTrue(future.isCompletedExceptionally());
    // result() was not called
    assertFalse(command.isResultCalled());
    try (ResultSet<EntityHandle<CommandTerminatedExceptionally>> resultSet = repository
            .query(CommandTerminatedExceptionally.class,
                   and(all(CommandTerminatedExceptionally.class),
                       existsIn(
                               indexEngine.getIndexedCollection(EventCausalityEstablished.class),
                               CommandTerminatedExceptionally.ID, EventCausalityEstablished.EVENT)))) {
        assertEquals(resultSet.size(), 1);
    }
    assertTrue(journal.get(command.uuid()).isPresent());
    assertFalse(journal.get(eventUUID).isPresent());
    assertTrue(repository.query(TestEvent.class, equal(TestEvent.ATTR, "test")).isEmpty());
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:25,代码来源:RepositoryTest.java

示例8: matchesSimpleAttribute

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Override
protected boolean matchesSimpleAttribute(SimpleAttribute<O, HybridTimestamp> attribute, O object, QueryOptions
        queryOptions) {
    Query<O> actualQuery = query == null ? queryFunction.apply(object) : query;
    Optional<Boolean> terminatedQuery = terminatedQuery(object, actualQuery, queryOptions);
    if (terminatedQuery.isPresent()) {
        return terminatedQuery.get();
    }
    HybridTimestamp value = attribute.getValue(object, queryOptions);
    IndexedCollection<O> collection = (IndexedCollection<O>) getCollection(queryOptions);
    try (ResultSet<O> resultSet = collection.retrieve(and(
            actualQuery,
            greaterThan(timestampAttribute, value)))) {
        return matches(resultSet, actualQuery, object, queryOptions);
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:17,代码来源:IsLatestEntity.java

示例9: matchesNonSimpleAttribute

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Override
protected boolean matchesNonSimpleAttribute(Attribute<O, HybridTimestamp> attribute, O object, QueryOptions
        queryOptions) {
    Query<O> actualQuery = query == null ? queryFunction.apply(object) : query;
    Optional<Boolean> terminatedQuery = terminatedQuery(object, actualQuery, queryOptions);
    if (terminatedQuery.isPresent()) {
        return terminatedQuery.get();
    }
    Iterable<HybridTimestamp> values = attribute.getValues(object, queryOptions);
    List<Query<O>> conditions = StreamSupport.stream(values.spliterator(), false)
                                             .map(v -> greaterThan(timestampAttribute, v))
                                             .collect(Collectors.toList());
    Query<O> timestampQuery = conditions.size() == 1 ? conditions.get(0) : new Or<>(conditions);
    IndexedCollection<O> collection = (IndexedCollection<O>) getCollection(queryOptions);
    try (ResultSet<O> resultSet = collection.retrieve(and(
            actualQuery,
            timestampQuery))) {
        return matches(resultSet, actualQuery, object, queryOptions);
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:21,代码来源:IsLatestEntity.java

示例10: test

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Test @SneakyThrows
public void test() {
    UUID uuid = UUID.randomUUID();
    repository.publish(new TestCommand("test1", uuid)).get();
    Query<EntityHandle<TestEvent>> query = isLatestEntity(equal(TestEvent.REFERENCE_ID, uuid),
                                                          TestEvent.TIMESTAMP);
    try (ResultSet<EntityHandle<TestEvent>> resultSet = repository.query(TestEvent.class, query)) {
        assertEquals(resultSet.size(), 1);
        assertEquals(resultSet.uniqueResult().get().test(), "test1");
    }
    repository.publish(new TestCommand("test2", uuid)).get();
    try (ResultSet<EntityHandle<TestEvent>> resultSet = repository.query(TestEvent.class, query)) {
        assertEquals(resultSet.size(), 1);
        assertEquals(resultSet.uniqueResult().get().test(), "test2");
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:17,代码来源:IsLatestEntityTest.java

示例11: testMassive

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Test @SneakyThrows
public void testMassive() {
    UUID uuid = UUID.randomUUID();
    for (int i = 0; i < 10000; i++ ) {
        repository.publish(new TestCommand("test" + (i + 1), uuid)).get();
    }
    Query<EntityHandle<TestEvent>> query = isLatestEntity(equal(TestEvent.REFERENCE_ID, uuid),
                                                          TestEvent.TIMESTAMP);
    long t1 = System.nanoTime();
    try (ResultSet<EntityHandle<TestEvent>> resultSet = repository.query(TestEvent.class, query)) {
        assertEquals(resultSet.size(), 1);
        assertEquals(resultSet.uniqueResult().get().test(), "test10000");
        long t2 = System.nanoTime();
        long time = TimeUnit.SECONDS.convert(t2 - t1, TimeUnit.NANOSECONDS);
        if (time > 1) {
            System.err.println("Warning: [IsLatestEntityTest.testMassive] isLatestEntity is slow, took " + time +
                                       " seconds");
        }
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:21,代码来源:IsLatestEntityTest.java

示例12: testFunction

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Test @SneakyThrows
public void testFunction() {
    UUID uuid = UUID.randomUUID();
    repository.publish(new TestCommand("test1", uuid)).get();
    repository.publish(new TestCommand("test2", uuid)).get();
    UUID uuidN = UUID.randomUUID();
    repository.publish(new TestCommand("testN1", uuidN)).get();
    repository.publish(new TestCommand("testN2", uuidN)).get();

    Query<EntityHandle<TestEvent>> query = isLatestEntity((h) -> equal(TestEvent.REFERENCE_ID, h.get().reference()),
                                                          TestEvent.TIMESTAMP);
    try (ResultSet<EntityHandle<TestEvent>> resultSet = repository.query(TestEvent.class, query)) {
        assertEquals(resultSet.size(), 2);
        List<EntityHandle<TestEvent>> result = Iterables.toList(resultSet);
        assertTrue(Iterators.any(result.iterator(), e -> e.get().test().contentEquals("test2")));
        assertTrue(Iterators.any(result.iterator(), e -> e.get().test().contentEquals("testN2")));
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:19,代码来源:IsLatestEntityTest.java

示例13: testMassive

import com.googlecode.cqengine.resultset.ResultSet; //导入依赖的package包/类
@Test @SneakyThrows
public void testMassive() {
    UUID uuid = UUID.randomUUID();
    for (int i = 0; i < 100000; i++ ) {
        repository.publish(new IsLatestEntityTest.TestCommand("test" + (i + 1), uuid)).get();
    }
    Query<EntityHandle<IsLatestEntityTest.TestEvent>> query = scoped(equal(IsLatestEntityTest.TestEvent
                                                                                   .REFERENCE_ID, uuid),
                                                                     max(IsLatestEntityTest.TestEvent.TIMESTAMP));
    long t1 = System.nanoTime();
    try (ResultSet<EntityHandle<IsLatestEntityTest.TestEvent>> resultSet = repository.query(IsLatestEntityTest.TestEvent.class, query)) {
        assertEquals(resultSet.size(), 1);
        assertEquals(resultSet.uniqueResult().get().test(), "test100000");
        long t2 = System.nanoTime();
        long time = TimeUnit.SECONDS.convert(t2 - t1, TimeUnit.NANOSECONDS);
        if (time > 1) {
            System.err.println("Warning: [MinMaxTest.testMassive] is slow, took " + time +
                                       " seconds");
        }
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:22,代码来源:MinMaxTest.java

示例14: 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

示例15: 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


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