io.requery.BlockingEntityStore Java Examples
The following examples show how to use
io.requery.BlockingEntityStore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactiveTest.java From requery with Apache License 2.0 | 6 votes |
@Test public void testRunInTransactionFromBlocking() { final BlockingEntityStore<Persistable> blocking = data.toBlocking(); Completable.fromCallable(new Callable<Object>() { @Override public Object call() throws Exception { blocking.runInTransaction(new Callable<Object>() { @Override public Object call() throws Exception { final Person person = randomPerson(); blocking.insert(person); blocking.update(person); return null; } }); return null; } }).subscribe(); assertEquals(1, data.count(Person.class).get().value().intValue()); }
Example #2
Source File: PretixDroid.java From pretixdroid with GNU General Public License v3.0 | 5 votes |
public BlockingEntityStore<Persistable> getData() { if (dataStore == null) { // override onUpgrade to handle migrating to a new version DatabaseSource source = new DatabaseSource(this, Models.DEFAULT, 6); Configuration configuration = source.getConfiguration(); dataStore = new EntityDataStore<Persistable>(configuration); } return dataStore; }
Example #3
Source File: WrappedEntityStore.java From requery with Apache License 2.0 | 5 votes |
@CheckReturnValue public <R> Single<R> runInTransaction(final Function<BlockingEntityStore<T>, R> function) { return Single.fromCallable(new Callable<R>() { @Override public R call() throws Exception { return function.apply(toBlocking()); } }); }
Example #4
Source File: PerfTestRequery.java From android-database-performance with Apache License 2.0 | 5 votes |
private void indexedStringEntityQueriesRun(BlockingEntityStore<Object> database, int count) { // create entities List<IndexedStringEntity> entities = new ArrayList<>(count); String[] fixedRandomStrings = StringGenerator.createFixedRandomStrings(count); for (int i = 0; i < count; i++) { IndexedStringEntity entity = new IndexedStringEntity(); entity.setId((long) i); entity.setIndexedString(fixedRandomStrings[i]); entities.add(entity); } log("Built entities."); // insert entities database.insert(entities); log("Inserted entities."); // query for entities by indexed string at random int[] randomIndices = StringGenerator.getFixedRandomIndices(getQueryCount(), count - 1); startClock(); for (int i = 0; i < getQueryCount(); i++) { int nextIndex = randomIndices[i]; Result<IndexedStringEntity> results = database.select( IndexedStringEntity.class) .where(IndexedStringEntity.INDEXED_STRING.eq( fixedRandomStrings[nextIndex])) .get(); //noinspection unused IndexedStringEntity indexedStringEntity = results.first(); results.close(); } stopClock(Benchmark.Type.QUERY_INDEXED); // delete all entities database.delete(IndexedStringEntity.class).get().value(); log("Deleted all entities."); }
Example #5
Source File: ReactiveEntityStore.java From requery with Apache License 2.0 | 4 votes |
@CheckReturnValue public abstract <R> Single<R> runInTransaction(Function<BlockingEntityStore<T>, R> function);
Example #6
Source File: ReactiveSupport.java From requery with Apache License 2.0 | 4 votes |
public static <S> ReactiveEntityStore<S> toReactiveStore(BlockingEntityStore<S> store) { return new WrappedEntityStore<>(store); }
Example #7
Source File: WrappedEntityStore.java From requery with Apache License 2.0 | 4 votes |
WrappedEntityStore(BlockingEntityStore<T> delegate) { this.delegate = Objects.requireNotNull(delegate); }
Example #8
Source File: WrappedEntityStore.java From requery with Apache License 2.0 | 4 votes |
@Override public BlockingEntityStore<T> toBlocking() { return delegate; }
Example #9
Source File: EntityDataStore.java From requery with Apache License 2.0 | 4 votes |
@Override public BlockingEntityStore<T> toBlocking() { return this; }
Example #10
Source File: ReactorEntityStore.java From requery with Apache License 2.0 | 4 votes |
public ReactorEntityStore(BlockingEntityStore<T> delegate) { this.delegate = Objects.requireNotNull(delegate); }
Example #11
Source File: ReactorEntityStore.java From requery with Apache License 2.0 | 4 votes |
@Override public BlockingEntityStore<T> toBlocking() { return delegate; }
Example #12
Source File: CompletableEntityStore.java From requery with Apache License 2.0 | 4 votes |
public CompletableEntityStore(BlockingEntityStore<T> delegate) { this.delegate = Objects.requireNotNull(delegate); this.executor = Executors.newSingleThreadExecutor(); createdExecutor = true; }
Example #13
Source File: CompletableEntityStore.java From requery with Apache License 2.0 | 4 votes |
public CompletableEntityStore(BlockingEntityStore<T> delegate, Executor executor) { this.delegate = Objects.requireNotNull(delegate); this.executor = Objects.requireNotNull(executor); createdExecutor = false; }
Example #14
Source File: CompletableEntityStore.java From requery with Apache License 2.0 | 4 votes |
@Override public BlockingEntityStore<T> toBlocking() { return delegate; }
Example #15
Source File: PerfTestRequery.java From android-database-performance with Apache License 2.0 | 4 votes |
private void deleteAll(BlockingEntityStore<Object> database) { database.delete(SimpleEntityNotNull.class).get().value(); }