本文整理汇总了Java中com.couchbase.client.java.view.ViewQuery类的典型用法代码示例。如果您正苦于以下问题:Java ViewQuery类的具体用法?Java ViewQuery怎么用?Java ViewQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewQuery类属于com.couchbase.client.java.view包,在下文中一共展示了ViewQuery类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: load
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
try {
logger.debug("Loading services");
final Bucket bucket = couchbase.bucket();
final ViewResult allKeys = bucket.query(ViewQuery.from(UTIL_DOCUMENT, ALL_SERVICES_VIEW.name()));
final List<RegisteredService> services = new LinkedList<>();
for (final ViewRow row : allKeys) {
final RawJsonDocument document = row.document(RawJsonDocument.class);
if (document != null) {
final String json = document.content();
logger.debug("Found service: {}", json);
final StringReader stringReader = new StringReader(json);
services.add(registeredServiceJsonSerializer.fromJson(stringReader));
}
}
return services;
} catch (final RuntimeException e) {
logger.error(e.getMessage(), e);
return new LinkedList<>();
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:CouchbaseServiceRegistryDao.java
示例2: shouldQueryView
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Test
public void shouldQueryView() throws IOException {
final BucketManager bucketManager = bucket.bucketManager();
final View view =
DefaultView.create("byFirstname",
IOUtils.toString(getClass().getResourceAsStream("/byfirstname.js")));
final DesignDocument document = DesignDocument.create("person", ImmutableList.of(view));
try {
bucketManager.upsertDesignDocument(document);
repository.save(person);
final ViewQuery query = ViewQuery.from(document.name(), view.name());
query.stale(Stale.FALSE);
query.debug();
query.key(person.getFirstname());
final Iterable<Person> found = repository.queryView(query);
assertEquals(ImmutableList.of(person), found);
} finally {
bucketManager.removeDesignDocument(document.name());
}
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:23,代码来源:SyncRepositoryTest.java
示例3: getAllKeys
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
private Observable<String> getAllKeys() {
String[] viewInfo = checkAndGetViewInfo();
return bucket.async()
.query(ViewQuery.from(viewInfo[0], viewInfo[1]))
.flatMap(new Func1<AsyncViewResult, Observable<AsyncViewRow>>() {
@Override
public Observable<AsyncViewRow> call(AsyncViewResult asyncViewResult) {
return asyncViewResult.rows();
}
})
.map(new Func1<AsyncViewRow, String>() {
@Override
public String call(AsyncViewRow asyncViewRow) {
return asyncViewRow.id();
}
});
}
开发者ID:couchbaselabs,项目名称:couchbase-java-cache,代码行数:19,代码来源:CouchbaseCache.java
示例4: runQuery
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
private int runQuery(final String prefix) {
final ViewResult allKeys = couchbase.bucket().query(
ViewQuery.from(UTIL_DOCUMENT, "all_tickets")
.startKey(prefix)
.endKey(prefix + END_TOKEN)
.reduce());
final Iterator<ViewRow> iterator = allKeys.iterator();
if (iterator.hasNext()) {
final ViewRow res = iterator.next();
return (Integer) res.value();
} else {
return 0;
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:CouchbaseTicketRegistry.java
示例5: getViewResultIteratorForPrefixedTickets
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
private ViewResult getViewResultIteratorForPrefixedTickets(final String prefix) {
LOGGER.debug("Running query on document [{}] and view [{}] with prefix [{}]",
UTIL_DOCUMENT, VIEW_NAME_ALL_TICKETS, prefix);
return this.couchbase.bucket().query(
ViewQuery.from(UTIL_DOCUMENT, VIEW_NAME_ALL_TICKETS)
.startKey(prefix)
.endKey(prefix + END_TOKEN)
.reduce());
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:CouchbaseTicketRegistry.java
示例6: getSongByArtistAsync
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public Observable<Song> getSongByArtistAsync(String query) {
return bucket
.async()
.query(ViewQuery.from("song", "artist").startKey(query).endKey(query + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"))
.limit(100)
.flatMap(AsyncViewResult::rows)
.map(r -> Song.createFromJson(r.value().toString()));
}
开发者ID:alexandrubordei,项目名称:goomusic,代码行数:10,代码来源:CouchbaseSongStore.java
示例7: queryView
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public Observable<T> queryView(final ViewQuery query) {
return Observable.just(query)
.flatMap(bucket::query)
.flatMap(AsyncViewResult::rows)
.flatMap(row -> row.document(RawJsonDocument.class))
.map(deserializer)
.timeout(timeout, unit);
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:10,代码来源:CBAsyncRepository.java
示例8: newQuery
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public ViewQuery newQuery(final String designDoc, final String view) {
final ViewQuery query = ViewQuery.from(designDoc, view);
query.debug(debug);
query.stale(stale);
return query;
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:8,代码来源:SpringQueryService.java
示例9: viewQuery
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void viewQuery() throws Exception {
String gid = "id";
Object entity = new Object() {
String id = gid;
@Override
public String toString() {
return id;
}
};
new MockUnit(AsyncDatastore.class, ViewQuery.class)
.expect(unit -> {
AsyncDatastore store = unit.get(AsyncDatastore.class);
expect(store.query(unit.get(ViewQuery.class)))
.andReturn(just(
new AsyncDatastore.AsyncViewQueryResult<Object>(10,
just(Arrays.asList(entity)))));
})
.run(unit -> {
ViewQueryResult<Object> result = new DatastoreImpl(unit.get(AsyncDatastore.class))
.query(unit.get(ViewQuery.class));
assertEquals(Arrays.asList(entity), result.getRows());
assertEquals(10, result.getTotalRows());
});
}
开发者ID:jooby-project,项目名称:jooby,代码行数:29,代码来源:DatastoreImplTest.java
示例10: executeViewQueryForAllServices
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
private ViewResult executeViewQueryForAllServices() {
return this.couchbase.bucket().query(ViewQuery.from(UTIL_DOCUMENT, ALL_SERVICES_VIEW.name()));
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:4,代码来源:CouchbaseServiceRegistryDao.java
示例11: queryView
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public List<T> queryView(final ViewQuery query) {
return blocking(async.queryView(query).toList()).single();
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:5,代码来源:CBSyncRepository.java
示例12: findAll
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Override
public Observable<T> findAll() {
final ViewQuery query = queries.newQuery(clazz.getSimpleName().toLowerCase(), "all");
query.reduce(false);
return queryView(query);
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:7,代码来源:CBAsyncRepository.java
示例13: shouldReturnQuery
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
@Test
public void shouldReturnQuery() {
final SpringQueryService service = new SpringQueryService(true, Stale.TRUE);
final ViewQuery newQuery = service.newQuery("designDoc", "view");
assertNotNull(newQuery);
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:7,代码来源:SpringQueryServiceTest.java
示例14: queryView
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
/**
* Query a database view.
*
* @param query query to execute
* @return an {@link Observable} which emits the results
*/
Observable<T> queryView(ViewQuery query);
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:8,代码来源:AsyncRepository.java
示例15: queryView
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
/**
* Query view.
*
* @param query query to execute
* @return entities found
*/
List<T> queryView(ViewQuery query);
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:8,代码来源:SyncRepository.java
示例16: newQuery
import com.couchbase.client.java.view.ViewQuery; //导入依赖的package包/类
ViewQuery newQuery(String designDoc, String view);
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:2,代码来源:ViewQueryService.java
注:本文中的com.couchbase.client.java.view.ViewQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论