本文整理汇总了Java中com.googlecode.cqengine.IndexedCollection.clear方法的典型用法代码示例。如果您正苦于以下问题:Java IndexedCollection.clear方法的具体用法?Java IndexedCollection.clear怎么用?Java IndexedCollection.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.cqengine.IndexedCollection
的用法示例。
在下文中一共展示了IndexedCollection.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: timestamping
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
@SneakyThrows
public void timestamping() {
IndexedCollection<EntityHandle<TestEvent>> coll = indexEngine.getIndexedCollection(TestEvent.class);
coll.clear();
IndexedCollection<EntityHandle<RepositoryTestCommand>> coll1 = indexEngine
.getIndexedCollection(RepositoryTestCommand.class);
coll1.clear();
repository.publish(RepositoryTestCommand.builder().build()).get();
TestEvent test = coll.retrieve(equal(TestEvent.ATTR, "test")).uniqueResult().get();
assertNotNull(test.timestamp());
RepositoryTestCommand test1 = coll1.retrieve(equal(RepositoryTestCommand.ATTR, "test")).uniqueResult().get();
assertNotNull(test1.timestamp());
assertTrue(test.timestamp().compareTo(test1.timestamp()) > 0);
}
示例2: commandTimestamping
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
@SneakyThrows
public void commandTimestamping() {
HybridTimestamp timestamp = new HybridTimestamp(timeProvider);
timestamp.update();
RepositoryTestCommand command1 = RepositoryTestCommand.builder().value("forced")
.timestamp(timestamp)
.build();
RepositoryTestCommand command2 = RepositoryTestCommand.builder().build();
IndexedCollection<EntityHandle<RepositoryTestCommand>> coll1 = indexEngine
.getIndexedCollection(RepositoryTestCommand.class);
coll1.clear();
repository.publish(command2).get();
repository.publish(command1).get();
RepositoryTestCommand test1 = coll1.retrieve(equal(RepositoryTestCommand.ATTR, "forced")).uniqueResult().get();
RepositoryTestCommand test2 = coll1.retrieve(equal(RepositoryTestCommand.ATTR, "test")).uniqueResult().get();
assertTrue(test1.timestamp().compareTo(test2.timestamp()) < 0);
assertTrue(repository.getTimestamp().compareTo(test1.timestamp()) > 0);
assertTrue(repository.getTimestamp().compareTo(test2.timestamp()) > 0);
}
示例3: eventTimestamping
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
@SneakyThrows
public void eventTimestamping() {
IndexedCollection<EntityHandle<TestEvent>> coll = indexEngine
.getIndexedCollection(TestEvent.class);
coll.clear();
HybridTimestamp timestamp = new HybridTimestamp(timeProvider);
timestamp.update();
TimestampingEventCommand command = TimestampingEventCommand.builder().eventTimestamp(timestamp).build();
repository.publish(command).get();
TestEvent test = coll.retrieve(equal(TestEvent.ATTR, "test")).uniqueResult().get();
assertTrue(test.timestamp().compareTo(command.timestamp()) < 0);
assertTrue(repository.getTimestamp().compareTo(test.timestamp()) > 0);
TestEvent followup = coll.retrieve(equal(TestEvent.ATTR, "followup")).uniqueResult().get();
assertTrue(test.timestamp().compareTo(followup.timestamp()) < 0);
assertTrue(repository.getTimestamp().compareTo(followup.timestamp()) > 0);
}
示例4: indexing
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
@SneakyThrows
public void indexing() {
IndexedCollection<EntityHandle<TestEvent>> coll = indexEngine.getIndexedCollection(TestEvent.class);
coll.clear();
IndexedCollection<EntityHandle<RepositoryTestCommand>> coll1 = indexEngine
.getIndexedCollection(RepositoryTestCommand.class);
coll1.clear();
repository.publish(RepositoryTestCommand.builder().build()).get();
assertTrue(coll.retrieve(equal(TestEvent.ATTR, "test")).isNotEmpty());
assertTrue(coll.retrieve(equal(TestEvent.ATTR_DEP, "test")).isNotEmpty());
assertTrue(coll.retrieve(contains(TestEvent.ATTR, "es")).isNotEmpty());
assertEquals(coll.retrieve(equal(TestEvent.ATTR, "test")).uniqueResult().get().string(), "test");
assertEquals(coll.retrieve(equal(TestEvent.ATTRS, "test")).uniqueResult().get().string(), "test");
assertEquals(coll.retrieve(equal(TestEventExtraIndices.ATTRL, Arrays.asList("test"))).uniqueResult().get().string(),
"test");
assertTrue(coll.retrieve(equal(TestEventExtraIndices.ATTRL, Arrays.asList("test1"))).isEmpty());
assertTrue(coll1.retrieve(equal(RepositoryTestCommand.ATTR, "test")).isNotEmpty());
assertTrue(coll1.retrieve(contains(RepositoryTestCommand.ATTR, "es")).isNotEmpty());
}
示例5: streamExceptionIndexing
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的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());
}
示例6: queryOptionsInIndices
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
@SneakyThrows
public void queryOptionsInIndices() {
IndexedCollection<EntityHandle<TestEventWithQueryOptions>> coll =
indexEngine.getIndexedCollection(TestEventWithQueryOptions.class);
coll.clear();
repository.publish(TestEventWithQueryOptionsCommand.builder().build()).get();
assertTrue(coll.retrieve(equal(TestEventWithQueryOptions.ATTR, "test")).isNotEmpty());
}
示例7: testCompositePersistence_EndToEnd
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
/**
* Tests a configuration where the collection is stored off-heap, one index is on-disk, and one index is on-heap.
*/
@Test
public void testCompositePersistence_EndToEnd() {
OffHeapPersistence<Car, Integer> offHeapPersistence = OffHeapPersistence.onPrimaryKey(Car.CAR_ID);
DiskPersistence<Car, Integer> diskPersistence = DiskPersistence.onPrimaryKey(Car.CAR_ID);
IndexedCollection<Car> collection = new ConcurrentIndexedCollection<Car>(CompositePersistence.of(
offHeapPersistence,
diskPersistence,
singletonList(OnHeapPersistence.onPrimaryKey(Car.CAR_ID))
));
collection.addIndex(DiskIndex.onAttribute(Car.MANUFACTURER));
collection.addIndex(OffHeapIndex.onAttribute(Car.MODEL));
collection.addIndex(NavigableIndex.onAttribute(Car.PRICE));
collection.addAll(CarFactory.createCollectionOfCars(1000));
ResultSet<Car> results = null;
try {
results = collection.retrieve(
and(
or(
equal(Car.MANUFACTURER, "Ford"),
equal(Car.MODEL, "Avensis")
),
lessThan(Car.PRICE, 6000.0)
)
);
Assert.assertEquals(300, results.size());
Assert.assertTrue(offHeapPersistence.getBytesUsed() > 4096); // example: 163840
Assert.assertTrue(diskPersistence.getBytesUsed() > 4096); // example: 30720
}
finally {
CloseableRequestResources.closeQuietly(results);
collection.clear();
offHeapPersistence.close();
diskPersistence.getFile().delete();
}
}