本文整理汇总了Java中com.couchbase.lite.QueryEnumerator类的典型用法代码示例。如果您正苦于以下问题:Java QueryEnumerator类的具体用法?Java QueryEnumerator怎么用?Java QueryEnumerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryEnumerator类属于com.couchbase.lite包,在下文中一共展示了QueryEnumerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: searchAllPostsOrderByDate
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
protected List<Post> searchAllPostsOrderByDate() {
List<Post> postList = new ArrayList<>();
try {
Query query = couchDbPost.createAllDocumentsQuery();
query.setAllDocsMode(Query.AllDocsMode.ONLY_CONFLICTS);
QueryEnumerator result = query.run();
for (Iterator<QueryRow> it = result; it.hasNext();) {
QueryRow row = it.next();
postList.add(fillPost(row.getDocument(), row.getDocumentId()));
}
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
Collections.sort(postList, new PostComparator());
return postList;
}
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:18,代码来源:CouchbaseLite.java
示例2: loadInBackground
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
public List<QueryRow> loadInBackground() {
try {
List<QueryRow> ret = new ArrayList<QueryRow>();
QueryEnumerator enumerator = query.run();
if (enumerator != null) {
while (enumerator.hasNext()) {
QueryRow row = enumerator.next();
ret.add(row);
}
}
return ret;
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:17,代码来源:DataLoader.java
示例3: getContactDocumentByEmail
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public Document getContactDocumentByEmail(String email) {
Query query = contactView.createQuery();
query.setStartKey(email);
query.setEndKey(email);
QueryEnumerator enumerator;
try {
enumerator = query.run();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
Document ret = null;
if (enumerator.hasNext()) {
QueryRow row = enumerator.next();
ret = row.getDocument();
}
return ret;
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:18,代码来源:DataServiceImpl.java
示例4: getMessagesByGame
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public List<Document> getMessagesByGame(String modelId) {
Query query = messageByGameView.createQuery();
query.setStartKey(modelId);
query.setEndKey(modelId);
QueryEnumerator enumerator;
try {
enumerator = query.run();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
List<Document> ret = new ArrayList<>();
while (enumerator.hasNext()) {
QueryRow row = enumerator.next();
ret.add(row.getDocument());
}
Collections.sort(ret, new Comparator<Document>() {
@Override
public int compare(Document left, Document right) {
return ((String) left.getProperty("id")).compareTo((String) right.getProperty("id"));
}
});
return ret;
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:24,代码来源:DataServiceImpl.java
示例5: getGameDocumentByModelId
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public Document getGameDocumentByModelId(String id) {
Query query = gameView.createQuery();
query.setStartKey(id);
query.setEndKey(id);
query.setEndKey(id);
QueryEnumerator enumerator;
try {
enumerator = query.run();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
Document ret = null;
if (enumerator.hasNext()) {
QueryRow row = enumerator.next();
ret = row.getDocument();
}
return ret;
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:19,代码来源:DataServiceImpl.java
示例6: getGamesByContactQuery
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public Query getGamesByContactQuery(String email) {
final Query gameQueryByContact = gameIdsByContactView.createQuery();
gameQueryByContact.setStartKey(email);
gameQueryByContact.setEndKey(email);
gameQueryByContact.setDescending(true);
gameQueryByContact.setGroupLevel(1);
Query gameQuery = gameView.createQuery();
try {
List<Object> keys = Collections.emptyList();
if (gameQueryByContact != null) {
QueryEnumerator run = gameQueryByContact.run();
if (run != null) {
QueryRow next = run.next();
if (next != null) {
keys = (List<Object>) next.getValue();
}
}
}
gameQuery.setKeys(keys);
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
return gameQuery;
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:26,代码来源:DataServiceImpl.java
示例7: queryCities
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
private void queryCities() {
final Query query = database.getView(CITIES_VIEW).createQuery();
query.setGroupLevel(1);
LiveQuery liveQuery = query.toLiveQuery();
liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
@Override
public void changed(LiveQuery.ChangeEvent event) {
try {
QueryEnumerator enumeration = query.run();
for (QueryRow row : enumeration) {
Log.d("CityExplorer", "Row is " + row.getValue() + " and key " + row.getKey());
}
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
}
});
liveQuery.start();
}
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:23,代码来源:SyncManager.java
示例8: initialize_firstRunPreCouchbase
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Test
public void initialize_firstRunPreCouchbase() throws CouchbaseLiteException, IOException {
Context context = InstrumentationRegistry.getTargetContext();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
preferences.edit().putInt("pref_version_code", 23).apply();
PuzzleType.initialize(context);
Query puzzleTypesQuery = App.getDatabase(context).getView("puzzletypes").createQuery();
QueryEnumerator rows = puzzleTypesQuery.run();
for (QueryRow row : rows) {
Log.d("Test", row.getDocument().getUserProperties().toString());
//Actual stuff to test?
}
}
开发者ID:plusCubed,项目名称:plusTimer,代码行数:18,代码来源:PuzzleTypeTest.java
示例9: deleteList
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
private void deleteList(final Document list) {
Application application = (Application) getApplication();
final Query query = application.getTasksView().createQuery();
query.setDescending(true);
List<Object> startKeys = new ArrayList<Object>();
startKeys.add(list.getId());
startKeys.add(new HashMap<String, Object>());
List<Object> endKeys = new ArrayList<Object>();
endKeys.add(list.getId());
query.setStartKey(startKeys);
query.setEndKey(endKeys);
mDatabase.runInTransaction(new TransactionalTask() {
@Override
public boolean run() {
try {
QueryEnumerator tasks = query.run();
while (tasks.hasNext()) {
QueryRow task = tasks.next();
task.getDocument().getCurrentRevision().deleteDocument();
}
list.delete();
} catch (CouchbaseLiteException e) {
Log.e(Application.TAG, "Cannot delete list", e);
return false;
}
return true;
}
});
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:34,代码来源:ListActivity.java
示例10: migrateGuestData
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public static boolean migrateGuestData(final Database guestDb, final Document profile) {
boolean success = true;
final Database userDB = profile.getDatabase();
if (guestDb.getLastSequenceNumber() > 0 && userDB.getLastSequenceNumber() == 0) {
success = userDB.runInTransaction(new TransactionalTask() {
@Override
public boolean run() {
try {
QueryEnumerator rows = guestDb.createAllDocumentsQuery().run();
for (QueryRow row : rows) {
Document doc = row.getDocument();
Document newDoc = userDB.getDocument(doc.getId());
newDoc.putProperties(doc.getUserProperties());
List<Attachment> attachments = doc.getCurrentRevision().getAttachments();
if (attachments.size() > 0) {
UnsavedRevision rev = newDoc.getCurrentRevision().createRevision();
for (Attachment attachment : attachments) {
rev.setAttachment(
attachment.getName(),
attachment.getContentType(),
attachment.getContent());
}
rev.save();
}
}
// Delete guest database:
guestDb.delete();
} catch (CouchbaseLiteException e) {
Log.e(Application.TAG, "Error when migrating guest data to user", e);
return false;
}
return true;
}
});
}
return success;
}
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:39,代码来源:UserProfile.java
示例11: searchPostsByAuthor
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
protected List<Post> searchPostsByAuthor(final Author author) {
List<Post> postList = new ArrayList<>();
try {
com.couchbase.lite.View viewsByAuthor = couchDbPost.getView("viewsByAuthor");
viewsByAuthor.setMap(new Mapper() {
@Override
public void map(Map<String, Object> document, Emitter emitter) {
emitter.emit(author.getKey(), document);
}
}, "1.0");
Query query = viewsByAuthor.createQuery();
List<Object> keyArray = new ArrayList<>();
keyArray.add(author.getKey());
query.setKeys(keyArray);
QueryEnumerator rowEnum = query.run();
for (; rowEnum.hasNext(); ) {
QueryRow row = rowEnum.next();
postList.add(fillPost(row.getDocument(), row.getDocumentId()));
}
} catch (Exception e){
e.printStackTrace();
}
return postList;
}
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:30,代码来源:CouchbaseLite.java
示例12: deleteData
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public void deleteData() {
try {
for (QueryEnumerator en = database.createAllDocumentsQuery().run(); en.hasNext(); ) {
QueryRow row = en.next();
row.getDocument().delete();
}
database.compact();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:12,代码来源:DataServiceImpl.java
示例13: queryItemsByIds
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
/**
* 查询指定的json对象,以字符串形式返回
* view 查询的version 为1
*
* @param ids
* @param dataType
* @return
*/
@Override
public List<Map<String, Object>> queryItemsByIds(final String dataType, Object... ids) {
List<Map<String, Object>> datas = new ArrayList<>();
View phoneView = mDatabase.getView(dataType);
if (phoneView != null) {
//建立索引,只建立一次
indexView(phoneView, dataType);
Query query = phoneView.createQuery();
query.setKeys(Arrays.<Object>asList(ids));
query.setLimit(ids.length);
try {
QueryEnumerator qe = query.run();
for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
QueryRow row = it.next();
Document doc = row.getDocument();
Map<String, Object> map = doc.getProperties();
if (map != null && map.size() > 0) {
datas.add(map);
}
}
} catch (Exception e) {
LogUtils.e(e);
}
}
return datas;
}
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:45,代码来源:CouchBaseStorage.java
示例14: queryItemsByTypes
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
public List<Map<String, Object>> queryItemsByTypes(final String dataType) {
List<Map<String, Object>> datas = new ArrayList<>();
View phoneView = mDatabase.getView(dataType);
if (phoneView != null) {
//建立索引,只建立一次
indexView(phoneView, dataType);
Query query = phoneView.createQuery();
try {
QueryEnumerator qe = query.run();
for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
QueryRow row = it.next();
Document doc = row.getDocument();
Map<String, Object> map = doc.getProperties();
if (map != null && map.size() > 0) {
datas.add(map);
}
}
} catch (Exception e) {
LogUtils.e(e);
String s = e.getMessage();
}
}
return datas;
}
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:34,代码来源:CouchBaseStorage.java
示例15: getAllDocumentIds
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
List<String> getAllDocumentIds(String databaseId) {
Timber.d("getAllDocumentIds: %s", databaseId);
ManagerOptions managerOptions = new ManagerOptions();
managerOptions.setReadOnly(true);
DatabaseOptions databaseOptions = new DatabaseOptions();
databaseOptions.setReadOnly(true);
com.couchbase.lite.Database database = null;
try {
// TODO: Create LiveQuery on this?
// TODO: Open manager/database and cache result - could be expensive operation
Manager manager = new Manager(new AndroidContext(mContext), managerOptions);
database = manager.openDatabase(databaseId, databaseOptions);
List<String> docIds = new ArrayList<>();
QueryEnumerator result = database.createAllDocumentsQuery().run();
while (result.hasNext()) {
QueryRow row = result.next();
docIds.add(row.getDocumentId());
}
return docIds;
} catch (Exception e) {
return Collections.emptyList();
} finally {
if (database != null) {
database.close();
}
}
}
开发者ID:RobotPajamas,项目名称:Stetho-Couchbase,代码行数:32,代码来源:CouchbasePeerManager.java
示例16: delete
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
private void delete() {
try {
QueryEnumerator en = database.createAllDocumentsQuery().run();
while (en.hasNext()) {
QueryRow row = en.next();
row.getDocument().delete();
}
} catch (CouchbaseLiteException e) {
throw new RuntimeException("Cannot delete object from CouchBase Lite.");
}
}
开发者ID:realm,项目名称:realm-java-benchmarks,代码行数:12,代码来源:TestCouch.java
示例17: testSum
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
public void testSum() {
setUp();
Benchmark benchmark = new Benchmark() {
@Override
public void setUp() {
delete();
addObjects();
verify();
}
@Override
public void tearDown() {
delete();
}
@Override
public void run() {
long age = 0;
Query query = database.createAllDocumentsQuery();
try {
QueryEnumerator en = query.run();
for (Iterator<QueryRow> it = en; it.hasNext(); ) {
QueryRow row = it.next();
age += ((Integer) row.getDocument().getProperty("age")).longValue();
}
} catch (CouchbaseLiteException e) {
throw new RuntimeException("Cannot retrieve object.");
}
}
};
measurements.put(TEST_SUM, benchmark.execute(warmupIterations, testIterations));
tearDown();
}
开发者ID:realm,项目名称:realm-java-benchmarks,代码行数:37,代码来源:TestCouch.java
示例18: deleteAll
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
private void deleteAll() throws CouchbaseLiteException {
// query all documents, mark them as deleted
Query query = database.createAllDocumentsQuery();
QueryEnumerator result = query.run();
database.beginTransaction();
while (result.hasNext()) {
QueryRow row = result.next();
row.getDocument().purge();
}
database.endTransaction(true);
}
开发者ID:greenrobot,项目名称:android-database-performance,代码行数:12,代码来源:PerfTestCouchbase.java
示例19: getData
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
@Override
public void getData() {
openDb();
ArrayList<DbTestRecordModel> modelList = new ArrayList<>();
Query query = database.createAllDocumentsQuery();
query.setAllDocsMode(Query.AllDocsMode.ALL_DOCS);
try {
QueryEnumerator result = query.run();
for(Iterator<QueryRow> it = result; it.hasNext();) {
QueryRow row = it.next();
Document record = database.getDocument(row.getDocumentId());
DbTestRecordModel recordModel = new DbTestRecordModel();
recordModel.setNewId(record.getId());
recordModel.setName((String) record.getProperty("name"));
recordModel.setAge(21);
recordModel.setAddress((String) record.getProperty("address"));
modelList.add(recordModel);
}
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
cachedData = modelList;
closeDb();
}
开发者ID:koustuvsinha,项目名称:benchmarker,代码行数:29,代码来源:DbCouchHelper.java
示例20: getContactAdapter
import com.couchbase.lite.QueryEnumerator; //导入依赖的package包/类
public ArrayAdapter<Map<String, Object>> getContactAdapter() {
if (adapter == null) {
QueryEnumerator runner = null;
try {
runner = dataService.getEffectiveContactQuery().run();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
adapter = new ArrayAdapter<Map<String, Object>>(this,
android.R.layout.simple_spinner_item,
android.R.id.text1) {
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
View view = convertView;
if (view == null) {
view = super.getView(position, convertView, parent);
}
Map<String, Object> item = getItem(position);
((TextView) view.findViewById(android.R.id.text1)).setText(item.get("email").toString());
return view;
};
@Override
public View getDropDownView(int position,
View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = super.getDropDownView(position, convertView, parent);
}
Map<String, Object> item = getItem(position);
((TextView) view.findViewById(android.R.id.text1)).setText(item.get("email").toString());
return view; //TODO Gotta add the dropdowns to a scrollable view different than a ListView because there's almost no way of finding the pos and item in the father to
}
};
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
while (runner.hasNext()) {
adapter.add(runner.next().getDocument().getProperties());
}
}
return adapter;
}
开发者ID:eduyayo,项目名称:gamesboard,代码行数:42,代码来源:NewGameActivity.java
注:本文中的com.couchbase.lite.QueryEnumerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论