コード例 #1
0
ファイル: DriverMongo.java プロジェクト: riking/mcore
  @Override
  public Collection<String> getIds(Coll<?> coll) {
    List<String> ret = null;

    DBCollection dbcoll = fixColl(coll);

    DBCursor cursor = dbcoll.find(dboEmpty, dboKeysId);
    try {
      ret = new ArrayList<String>(cursor.count());
      while (cursor.hasNext()) {
        Object remoteId = cursor.next().get(ID_FIELD);
        ret.add(remoteId.toString());
      }
    } finally {
      cursor.close();
    }

    return ret;
  }
コード例 #2
0
ファイル: DriverMongo.java プロジェクト: riking/mcore
  @Override
  public Map<String, Long> getId2mtime(Coll<?> coll) {
    Map<String, Long> ret = null;

    DBCollection dbcoll = fixColl(coll);

    DBCursor cursor = dbcoll.find(dboEmpty, dboKeysIdandMtime);
    try {
      ret = new HashMap<String, Long>(cursor.count());
      while (cursor.hasNext()) {
        BasicDBObject raw = (BasicDBObject) cursor.next();
        Object remoteId = raw.get(ID_FIELD);
        if (!raw.containsField(MTIME_FIELD))
          continue; // This should not happen! But better to ignore than crash?
        Long mtime = raw.getLong(MTIME_FIELD);
        ret.put(remoteId.toString(), mtime);
      }
    } finally {
      cursor.close();
    }

    return ret;
  }
コード例 #3
0
ファイル: DriverMongo.java プロジェクト: riking/mcore
 @Override
 public boolean containsId(Coll<?> coll, String id) {
   DBCollection dbcoll = fixColl(coll);
   DBCursor cursor = dbcoll.find(new BasicDBObject(ID_FIELD, id));
   return cursor.count() != 0;
 }