本文整理了Java中com.couchbase.lite.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:com.couchbase.lite.Query
类名称:Query
[英]Represents a query of a CouchbaseLite 'view', or of a view-like resource like _all_documents.
[中]表示对CouchbaseLite“视图”或类似“所有文档”的视图资源的查询。
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
/**
* Creates a one-shot query with the given map function. This is equivalent to creating an
* anonymous View and then deleting it immediately after querying it. It may be useful during
* development, but in general this is inefficient if this map will be used more than once,
* because the entire view has to be regenerated from scratch every time.
*/
protected Query slowQuery(Mapper map) {
return new Query(this, map);
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
/**
* Constructor
*/
@InterfaceAudience.Private
/* package */ LiveQuery(Query query) {
super(query.getDatabase(), query);
runningState = new AtomicBoolean(false);
}
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
@InterfaceAudience.Private
private QueryOptions getQueryOptions() {
QueryOptions queryOptions = new QueryOptions();
queryOptions.setStartKey(getStartKey());
queryOptions.setEndKey(getEndKey());
queryOptions.setStartKey(getStartKey());
queryOptions.setKeys(getKeys());
queryOptions.setSkip(getSkip());
queryOptions.setLimit(getLimit());
queryOptions.setReduce(!isMapOnly());
queryOptions.setReduceSpecified(true);
queryOptions.setGroupLevel(getGroupLevel());
queryOptions.setPrefixMatchLevel(getPrefixMatchLevel());
queryOptions.setDescending(isDescending());
queryOptions.setIncludeDocs(shouldPrefetch());
queryOptions.setUpdateSeq(true);
queryOptions.setInclusiveStart(inclusiveStart);
queryOptions.setInclusiveEnd(inclusiveEnd);
queryOptions.setStale(getIndexUpdateMode());
queryOptions.setAllDocsMode(getAllDocsMode());
queryOptions.setStartKeyDocId(getStartKeyDocId());
queryOptions.setEndKeyDocId(getEndKeyDocId());
queryOptions.setPostFilter(getPostFilter());
return queryOptions;
}
代码示例来源:origin: couchbaselabs/mini-hacks
void setupUserQuery() {
/** Update the labels of the Recycler View */
keyTextView.setText("Name (id)");
valueTextView.setText("Conflicts");
LiveQuery liveQuery = storageManager.database.getView(StorageManager.USER_RATINGS_VIEW).createQuery().toLiveQuery();
adapter = new RatingsAdapter(this, liveQuery, storageManager.database);
recyclerView.setAdapter(adapter);
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
@InterfaceAudience.Private
private QueryOptions getQueryOptions() {
QueryOptions queryOptions = new QueryOptions();
queryOptions.setStartKey(getStartKey());
queryOptions.setEndKey(getEndKey());
queryOptions.setStartKey(getStartKey());
queryOptions.setKeys(getKeys());
queryOptions.setSkip(getSkip());
queryOptions.setLimit(getLimit());
queryOptions.setReduce(!isMapOnly());
queryOptions.setReduceSpecified(true);
queryOptions.setGroupLevel(getGroupLevel());
queryOptions.setPrefixMatchLevel(getPrefixMatchLevel());
queryOptions.setDescending(isDescending());
queryOptions.setIncludeDocs(shouldPrefetch());
queryOptions.setUpdateSeq(true);
queryOptions.setInclusiveStart(inclusiveStart);
queryOptions.setInclusiveEnd(inclusiveEnd);
queryOptions.setStale(getIndexUpdateMode());
queryOptions.setAllDocsMode(getAllDocsMode());
queryOptions.setStartKeyDocId(getStartKeyDocId());
queryOptions.setEndKeyDocId(getEndKeyDocId());
queryOptions.setPostFilter(getPostFilter());
return queryOptions;
}
代码示例来源:origin: couchbaselabs/mini-hacks
void setupUniqueQuery() {
/** Update the labels of the Recycler View */
keyTextView.setText("Rating");
valueTextView.setText("Total");
LiveQuery liveQuery = storageManager.database.getView(StorageManager.UNIQUE_RATINGS_VIEW).createQuery().toLiveQuery();
liveQuery.setGroupLevel(1); // use group level to aggregate by key (i.e. the rating value)
liveQuery.setDescending(true);
adapter = new RatingsAdapter(liveQuery, this);
recyclerView.setAdapter(adapter);
}
代码示例来源:origin: couchbaselabs/GrocerySync-Android
private void startLiveQuery(com.couchbase.lite.View view) throws Exception {
final ProgressDialog progressDialog = showLoadingSpinner();
if (liveQuery == null) {
liveQuery = view.createQuery().toLiveQuery();
liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
public void changed(final LiveQuery.ChangeEvent event) {
runOnUiThread(new Runnable() {
public void run() {
grocerySyncArrayAdapter.clear();
for (Iterator<QueryRow> it = event.getRows(); it.hasNext();) {
grocerySyncArrayAdapter.add(it.next());
}
grocerySyncArrayAdapter.notifyDataSetChanged();
progressDialog.dismiss();
}
});
}
});
liveQuery.start();
}
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
/**
* Creates a one-shot query with the given map function. This is equivalent to creating an
* anonymous View and then deleting it immediately after querying it. It may be useful during
* development, but in general this is inefficient if this map will be used more than once,
* because the entire view has to be regenerated from scratch every time.
*/
protected Query slowQuery(Mapper map) {
return new Query(this, map);
}
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
/**
* Constructor
*/
@InterfaceAudience.Private
/* package */ LiveQuery(Query query) {
super(query.getDatabase(), query);
runningState = new AtomicBoolean(false);
}
代码示例来源:origin: couchbaselabs/mini-hacks
private void setupQuery() {
Database database = null;
try {
database = manager.getExistingDatabase("todo");
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
if (database != null) {
LiveQuery liveQuery = database.createAllDocumentsQuery().toLiveQuery();
liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
@Override
public void changed(final LiveQuery.ChangeEvent event) {
runOnUiThread(new Runnable() {
@Override
public void run() {
docCountLabel.setText(String.valueOf(event.getRows().getCount()));
}
});
}
});
liveQuery.start();
}
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
/**
* Returns a query that matches all documents in the database.
* This is like querying an imaginary view that emits every document's ID as a key.
*/
@InterfaceAudience.Public
public Query createAllDocumentsQuery() {
return new Query(this, (View) null);
}
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
@Override
public void run() {
try {
if (!getDatabase().isOpen()) {
throw new IllegalStateException("The database has been closed.");
}
String viewName = (view != null) ? view.getName() : null;
QueryOptions options = getQueryOptions();
List<Long> outSequence = new ArrayList<Long>();
List<QueryRow> rows = database.queryViewNamed(viewName, options, outSequence);
long sequenceNumber = outSequence.get(0);
QueryEnumerator enumerator = new QueryEnumerator(database, rows, sequenceNumber);
onComplete.completed(enumerator, null);
} catch (Throwable t) {
Log.e(Log.TAG_QUERY, "Exception caught in runAsyncInternal", t);
onComplete.completed(null, t);
}
}
});
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
/**
* Creates a new query object for this view. The query can be customized and then executed.
*/
@InterfaceAudience.Public
public Query createQuery() {
return new Query(database, this);
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
@Override
public void run() {
try {
if (!getDatabase().isOpen()) {
throw new IllegalStateException("The database has been closed.");
}
String viewName = (view != null) ? view.getName() : null;
QueryOptions options = getQueryOptions();
List<Long> outSequence = new ArrayList<Long>();
List<QueryRow> rows = database.queryViewNamed(viewName, options, outSequence);
long sequenceNumber = outSequence.get(0);
QueryEnumerator enumerator = new QueryEnumerator(database, rows, sequenceNumber);
onComplete.completed(enumerator, null);
} catch (Throwable t) {
Log.e(Log.TAG_QUERY, "Exception caught in runAsyncInternal", t);
onComplete.completed(null, t);
}
}
});
代码示例来源:origin: com.couchbase.lite/couchbase-lite-java-core
/**
* Returns a query that matches all documents in the database.
* This is like querying an imaginary view that emits every document's ID as a key.
*/
@InterfaceAudience.Public
public Query createAllDocumentsQuery() {
return new Query(this, (View) null);
}
代码示例来源:origin: couchbase/couchbase-lite-java-core
/**
* Creates a new query object for this view. The query can be customized and then executed.
*/
@InterfaceAudience.Public
public Query createQuery() {
return new Query(database, this);
}
内容来源于网络,如有侵权,请联系作者删除!