コード例 #1
0
MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats)
{
    _ns = MongoNamespace(QString::fromStdString(stats.getStringField("ns")));
    _sizeBytes = stats.getIntField("size");
    _count = stats.getIntField("count");
    _storageSizeBytes = stats.getIntField("storageSize");
}
コード例 #2
0
ファイル: joint.cpp プロジェクト: jacquelinekay/reveal
//-----------------------------------------------------------------------------
bool joint_c::fetch( Reveal::Core::joint_ptr joint, mongo::BSONObj bson ) {

  assert( joint );

  joint->id = bson.getField( FIELD_ID ).String();

  mongo::BSONObj bson_q = bson.getObjectField( FIELD_STATE_POSITION );
  std::vector<mongo::BSONElement> v_q;
  bson_q.elems( v_q );

  for( unsigned i = 0; i < v_q.size(); i++ )
    joint->state.q( i, v_q[i].Double() );

  mongo::BSONObj bson_dq = bson.getObjectField( FIELD_STATE_VELOCITY );

  std::vector<mongo::BSONElement> v_dq;
  bson_dq.elems( v_dq );

  for( unsigned i = 0; i < v_dq.size(); i++ )
    joint->state.dq( i, v_dq[i].Double() );

  mongo::BSONObj bson_u = bson.getObjectField( FIELD_CONTROL );
  std::vector<mongo::BSONElement> v_u;
  bson_u.elems( v_u );

  for( unsigned i = 0; i < v_u.size(); i++ )
    joint->control.u( i, v_u[i].Double() );

  return true;
}
コード例 #3
0
ファイル: utils.cpp プロジェクト: alanw/mongo
 mongo::BSONObj JSSleep(const mongo::BSONObj &args){
     assert( args.nFields() == 1 );
     assert( args.firstElement().isNumber() );
     int ms = int( args.firstElement().number() );
     sleepms( ms );
     return undefined_;
 }
コード例 #4
0
ファイル: repo_bson.cpp プロジェクト: wsdflink/3drepobouncer
RepoBSON::RepoBSON(
	const mongo::BSONObj &obj,
	const std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> &binMapping)
	: mongo::BSONObj(obj),
	bigFiles(binMapping)
{
	std::vector<std::pair<std::string, std::string>> existingFiles;

	if (bigFiles.size() > 0)
	{
		mongo::BSONObjBuilder builder, arrbuilder;

		for (const auto & pair : bigFiles)
		{
			//append field name :file name
			arrbuilder << pair.first << pair.second.first;
		}

		if (obj.hasField(REPO_LABEL_OVERSIZED_FILES))
		{
			arrbuilder.appendElementsUnique(obj.getObjectField(REPO_LABEL_OVERSIZED_FILES));
		}


		builder.append(REPO_LABEL_OVERSIZED_FILES, arrbuilder.obj());
		builder.appendElementsUnique(obj);

		*this = builder.obj();
		bigFiles = binMapping;
	}
	


}
コード例 #5
0
Datum return_bson(const mongo::BSONObj& b)
{
    std::size_t bson_size = b.objsize() + VARHDRSZ;
    bytea* new_bytea = (bytea *) palloc(bson_size);
    SET_VARSIZE(new_bytea, bson_size);
    std::memcpy(VARDATA(new_bytea), b.objdata(), b.objsize());
    PG_RETURN_BYTEA_P(new_bytea);
}
コード例 #6
0
    MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats):_ns(QString::fromStdString(stats.getStringField("ns")))
    {
        // if "size" and "storageSize" are of type Int32 or Int64, they
        // will be converted to double by "numberDouble()" function.
        _sizeBytes = stats.getField("size").numberDouble();
        _storageSizeBytes = stats.getField("storageSize").numberDouble();

        _count = stats.getIntField("count");
    }
コード例 #7
0
ファイル: utils.cpp プロジェクト: AK-Dominator/mongo
    static BSONObj native_sleep( const mongo::BSONObj& args, void* data ) {
        uassert( 16259,
                 "sleep takes a single numeric argument -- sleep(milliseconds)",
                 args.nFields() == 1 && args.firstElement().isNumber() );
        sleepmillis( static_cast<long long>( args.firstElement().number() ) );

        BSONObjBuilder b;
        b.appendUndefined( "" );
        return b.obj();
    }
コード例 #8
0
ファイル: trial.cpp プロジェクト: jacquelinekay/reveal
//-----------------------------------------------------------------------------
bool trial_c::map( Reveal::Core::trial_ptr& trial, mongo::BSONObj obj ) { 

  trial = Reveal::Core::trial_ptr( new Reveal::Core::trial_c() );

  trial->scenario_id = obj.getField( "scenario_id" ).String();
  trial->t = obj.getField( "t" ).Double();

  model_c::fetch( trial, obj );

  return true;
}
コード例 #9
0
/** Good if one primary and rest secondaries and arbiters */
static bool goodReplStatus (mongo::BSONObj &info) {
	if (!info.getField("ok").trueValue()) return false;
	vector<mongo::BSONElement> ms = info.getField("members").Array();
	bool primary = false;
	for (unsigned i = 0; i < ms.size(); i++) {
		int state = ms[i].Obj().getIntField("state");
		if (state == 1) {primary = true; continue;}
		if (state != 2 && state != 7) return false;
	}
	return primary;
}
コード例 #10
0
ファイル: transform_computable.cpp プロジェクト: timn/fawkes
std::list<mongo::BSONObj> TransformComputable::compute_transform(mongo::BSONObj query, std::string collection)
{
  //get positions in other frames
  BSONObjBuilder query_other_frames;
  query_other_frames.appendElements(query.removeField("frame").removeField("allow_tf"));
  query_other_frames.append("frame", fromjson("{$exists:true}"));
  QResCursor cur = robot_memory_->query(query_other_frames.obj(), collection);

  //transform them is possible
  std::list<mongo::BSONObj> res;
  std::string target_frame = query.getField("frame").String();
  while(cur->more())
  {
    BSONObj pos = cur->next();
    if(pos.hasField("frame") && pos.hasField("translation") && pos.hasField("rotation"))
    {
      std::string src_frame = pos.getField("frame").String();
      Time now(0, 0);
      if(tf_->can_transform(target_frame.c_str(), src_frame.c_str(), now))
      {
        BSONObjBuilder res_pos;
        std::vector<BSONElement> src_trans = pos.getField("translation").Array();
        std::vector<BSONElement> src_rot = pos.getField("rotation").Array();
        fawkes::tf::Transform pose_tf(fawkes::tf::Quaternion(src_rot[0].Double(), src_rot[1].Double(), src_rot[2].Double(), src_rot[3].Double()),
          fawkes::tf::Vector3(src_trans[0].Double(), src_trans[1].Double(), src_trans[2].Double()));
        fawkes::tf::Stamped<fawkes::tf::Pose> src_stamped_pose(pose_tf, Time(0, 0), src_frame.c_str());
        fawkes::tf::Stamped<fawkes::tf::Pose> res_stamped_pose;
        tf_->transform_pose(target_frame.c_str(), src_stamped_pose, res_stamped_pose);

        res_pos.appendElements(pos.removeField("frame").removeField("translation").removeField("rotation").removeField("_id"));
        res_pos.append("frame", target_frame);
        res_pos.append("allow_tf", true);
        BSONArrayBuilder arrb_trans;
        arrb_trans.append(res_stamped_pose.getOrigin().x());
        arrb_trans.append(res_stamped_pose.getOrigin().y());
        arrb_trans.append(res_stamped_pose.getOrigin().z());
        res_pos.append("translation", arrb_trans.arr());
        BSONArrayBuilder arrb_rot;
        arrb_rot.append(res_stamped_pose.getRotation().x());
        arrb_rot.append(res_stamped_pose.getRotation().y());
        arrb_rot.append(res_stamped_pose.getRotation().z());
        arrb_rot.append(res_stamped_pose.getRotation().w());
        res_pos.append("rotation", arrb_rot.arr());
        res.push_back(res_pos.obj());
      }
//      else
//      {
//        logger_->log_info(name_, "Cant transform %s to %s", src_frame.c_str(), target_frame.c_str());
//      }
    }
  }
  return res;
}
コード例 #11
0
ファイル: processer.cpp プロジェクト: keyboard-man/kelp
void Processer::DoHost(const std::string& grid,const std::string& cluster,mongo::BSONObj& host)
{
	std::string host_id;
	std::cout << host << std::endl;
	if(host.hasField("host_ID") && host.hasField("heartbeat"))
	{
        //deal the record with host level
        //do not need to cut it off
        DBModules::iterator iter = db_modules_.begin();
        for(;iter!=db_modules_.end();++iter)
        {
            iter->handler(host.objdata(),host.objsize(),NULL);
        }

	//	host_id = host.getStringField("host_ID");
	//	std::vector<mongo::BSONElement> ele;
	//	host.elems(ele);
	//	for(int i=0;i<ele.size();i++)
	//	{
	//		if((!strcmp(ele[i].fieldName(),"host_ID")) || 
	//				(!strcmp(ele[i].fieldName(),"heartbeat")))
	//		{
	//			continue;
	//		}
	//		else
	//		{
	//			std::string ds_name = ele[i].fieldName();
	//			std::string path;
	//			if(grid!="")
	//				path = grid + '/' + cluster + '/' + host_id;
	//			else
	//				path = cluster + '/' + host_id;
	//			mongo::BSONObj obj = ele[i].wrap();
	//			std::cout << obj << std::endl;

	//			std::list<void(*)(const char*,int,const char*)>::iterator iter;
	//			iter = callback_[ds_name].begin();
	//			for(;iter!=callback_[ds_name].end();++iter)
	//			{
	//				(*iter)(obj.objdata(),obj.objsize(),path.c_str());
	//			}
	//		}
	//	}
	}
	else
	{
		std::stringstream oss;
		oss << "This data is illegal! Drop!!";
		LOG4CXX_WARN(log_,oss.str());
	}
}
コード例 #12
0
ファイル: solution.cpp プロジェクト: jacquelinekay/reveal
//-----------------------------------------------------------------------------
bool solution_c::map( Reveal::Core::solution_ptr& solution, mongo::BSONObj obj, Reveal::Core::solution_c::type_e type ) { 
  solution = Reveal::Core::solution_ptr( new Reveal::Core::solution_c( type ) );

  if( type == Reveal::Core::solution_c::CLIENT )
    solution->experiment_id = obj.getField( "experiment_id" ).String();
  solution->scenario_id = obj.getField( "scenario_id" ).String();
  solution->t = obj.getField( "t" ).Double();
  if( type == Reveal::Core::solution_c::CLIENT )
    solution->real_time = obj.getField( "real_time" ).Double();

  model_c::fetch( solution, obj );

  return true;
}
コード例 #13
0
std::string CjsonExporter::toCjson(const mongo::BSONObj &mongoChemObj)
{
  // Follow the database link and convert to CJSON.
  MongoDatabase *db = MongoDatabase::instance();
  if (!db)
    return "";

  mongo::BSONObj structure = mongoChemObj.getObjectField("3dStructure");
  if (!structure.hasField("$ref") || !structure.hasField("$id")
      || !structure.getField("$id").isSimpleType()) {
    return "";
  }
  std::auto_ptr<mongo::DBClientCursor> cursor =
      db->query(db->databaseName() + "." + structure.getStringField("$ref"),
                QUERY("_id" << structure.getField("$id").OID()), 1);
  mongo::BSONObj object;
  if (cursor->more())
    object = cursor->next();
  else
    return "";

  std::vector<std::string> toCopy;
  toCopy.push_back("name");
  toCopy.push_back("inchi");
  toCopy.push_back("formula");
  toCopy.push_back("properties");
  mongo::BSONObjBuilder builder;

  for (size_t i = 0; i < toCopy.size(); i++) {
    mongo::BSONElement field = mongoChemObj.getField(toCopy[i]);
    if (!field.eoo())
      builder.append(field);
  }
  toCopy.clear();
  toCopy.push_back("atoms");
  toCopy.push_back("bonds");
  for (size_t i = 0; i < toCopy.size(); i++) {
    mongo::BSONElement field = object.getField(toCopy[i]);
    if (!field.eoo())
      builder.append(field);
  }

  // Add the chemical JSON version field.
  builder.append("chemical json", 0);

  mongo::BSONObj obj = builder.obj();

  return obj.jsonString(mongo::Strict);
}
コード例 #14
0
ファイル: stitch_support.cpp プロジェクト: hanumantmk/mongo
    stitch_support_v1_update(mongo::ServiceContext::UniqueClient client,
                             mongo::BSONObj updateExpr,
                             mongo::BSONArray arrayFilters,
                             stitch_support_v1_matcher* matcher,
                             stitch_support_v1_collator* collator)
        : client(std::move(client)),
          opCtx(this->client->makeOperationContext()),
          updateExpr(updateExpr.getOwned()),
          arrayFilters(arrayFilters.getOwned()),
          matcher(matcher),
          updateDriver(new mongo::ExpressionContext(
              opCtx.get(), collator ? collator->collator.get() : nullptr)) {
        std::vector<mongo::BSONObj> arrayFilterVector;
        for (auto&& filter : this->arrayFilters) {
            arrayFilterVector.push_back(filter.embeddedObject());
        }
        this->parsedFilters = uassertStatusOK(mongo::ParsedUpdate::parseArrayFilters(
            arrayFilterVector, this->opCtx.get(), collator ? collator->collator.get() : nullptr));

        // Initializing the update as single-document allows document-replacement updates.
        bool multi = false;

        updateDriver.parse(this->updateExpr, parsedFilters, multi);

        uassert(51037,
                "Updates with a positional operator require a matcher object.",
                matcher || !updateDriver.needMatchDetails());
    }
コード例 #15
0
ファイル: metadata.cpp プロジェクト: songjundev/b
void CMetadata::_objBsonToJson(rapidjson::Value& json, mongo::BSONObj& bson)
{
	std::vector<mongo::BSONElement> values;
	bson.elems(values);
	for (uint i = 0; i<values.size(); ++i) {
		this->_fieldBsonToJson(json, values[i].fieldName(), bson);
	}
}
コード例 #16
0
ファイル: metadata.cpp プロジェクト: songjundev/b
void CMetadata::fromBson(mongo::BSONObj& bson)
{
	std::vector<mongo::BSONElement> elements;
	bson.elems(elements);
	for (uint i = 0; i<elements.size(); ++i) {
		this->_fieldBsonToJson(m_members, elements[i].fieldName(), bson);
	}
}
コード例 #17
0
ファイル: stitch_support.cpp プロジェクト: hanumantmk/mongo
 stitch_support_v1_matcher(mongo::ServiceContext::UniqueClient client,
                           const mongo::BSONObj& filterBSON,
                           stitch_support_v1_collator* collator)
     : client(std::move(client)),
       opCtx(this->client->makeOperationContext()),
       matcher(filterBSON.getOwned(),
               new mongo::ExpressionContext(opCtx.get(),
                                            collator ? collator->collator.get() : nullptr)){};
コード例 #18
0
repo::core::RepoNodeTexture::RepoNodeTexture(const mongo::BSONObj &obj)
    : RepoNodeAbstract(obj)
    , data(NULL)
{
	//
	// Width
	//
    if (obj.hasField(REPO_LABEL_WIDTH))
        width = obj.getField(REPO_LABEL_WIDTH).numberInt();

	//
	// Height
	//
    if (obj.hasField(REPO_LABEL_HEIGHT))
        height = obj.getField(REPO_LABEL_HEIGHT).numberInt();

	//
	// Format
	//
	if (obj.hasField(REPO_NODE_LABEL_EXTENSION)) {
		extension = obj.getField(REPO_NODE_LABEL_EXTENSION).str();
		name += "." + extension; // assimp needs full names with extension
	}

	//
	// Bit depth
	//
	//if (obj.hasField(REPO_NODE_LABEL_BIT_DEPTH))
	//	bitDepth = obj.getField(REPO_NODE_LABEL_BIT_DEPTH).numberInt();

	//
	// Data
	//
    if (obj.hasField(REPO_LABEL_DATA) &&
		obj.hasField(REPO_NODE_LABEL_DATA_BYTE_COUNT))
	{

        std::cerr << "Texture" << std::endl;
		data = new std::vector<char>();
		RepoTranscoderBSON::retrieve(
            obj.getField(REPO_LABEL_DATA),
			obj.getField(REPO_NODE_LABEL_DATA_BYTE_COUNT).numberInt(),
			data);
	}	
}
コード例 #19
0
    MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats) : _ns(stats.getStringField("ns"))
    {
        // if "size" and "storageSize" are of type Int32 or Int64, they
        // will be converted to double by "numberDouble()" function.
        _sizeBytes = BsonUtils::getField<mongo::NumberDouble>(stats,"size");
        _storageSizeBytes = BsonUtils::getField<mongo::NumberDouble>(stats,"storageSize");

        // NumberLong because of mongodb can have very big collections
        _count = BsonUtils::getField<mongo::NumberLong>(stats,"count");
    }
コード例 #20
0
ファイル: metadata.cpp プロジェクト: songjundev/b
void CMetadata::fromBson(mongo::BSONObj& bson, std::string key)
{
	rapidjson::Value& member = this->getFieldVal(m_members, key);

	std::vector<mongo::BSONElement> elements;
	bson.elems(elements);
	for (uint i = 0; i<elements.size(); ++i) {
		this->_fieldBsonToJson(member, elements[i].fieldName(), bson);
	}
}
コード例 #21
0
ファイル: MongoClient.cpp プロジェクト: gsimsek/robomongo
    void MongoClient::saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns)
    {
        mongo::BSONElement id = obj.getField("_id");
        mongo::BSONObjBuilder builder;
        builder.append(id);
        mongo::BSONObj bsonQuery = builder.obj();
        mongo::Query query(bsonQuery);

        _dbclient->update(ns.toString(), query, obj, true, false);
        checkLastErrorAndThrow(ns.databaseName());
    }
コード例 #22
0
ファイル: MongoClient.cpp プロジェクト: 2812140729/robomongo
    void MongoClient::saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns)
    {

        mongo::BSONElement id = obj.getField("_id");
        mongo::BSONObjBuilder builder;
        builder.append(id);
        mongo::BSONObj bsonQuery = builder.obj();
        mongo::Query query(bsonQuery);

        _dbclient->update(ns.toString(), query, obj, true, false);
        //_dbclient->save(ns.toString().toStdString(), obj);
    }
コード例 #23
0
ファイル: processer.cpp プロジェクト: keyboard-man/kelp
void Processer::Handle(mongo::BSONObj& bson)
{
	//handle the bson
	//maybe grid-bosn;maybe cluster-bson
	std::string grid_id;

	if(bson.hasField("grid_ID") && bson.hasField("cluster_data"))
	{
		grid_id = bson.getStringField("grid_ID");
		std::vector<mongo::BSONElement> c_ele = bson["cluster_data"].Array();
		for(int i=0;i<c_ele.size();i++)
		{
			mongo::BSONObj obj = c_ele[i].Obj();
			DoCluster(grid_id,obj);
		}
	}
	else
	{
		grid_id = "";
		DoCluster(grid_id,bson);
	}
}
コード例 #24
0
ファイル: user.cpp プロジェクト: glftpd/ebftpd
template <> acl::UserData Unserialize<acl::UserData>(const mongo::BSONObj& obj)
{
  try
  { 
    acl::UserData user;
    user.id = obj["uid"].Int();
    user.name = obj["name"].String();
    UnserializeContainer(obj["ip masks"].Array(), user.ipMasks);
    user.password = obj["password"].String();
    user.salt = obj["salt"].String();
    user.flags = obj["flags"].String();
    user.primaryGid = obj["primary gid"].Int();
    UnserializeContainer(obj["secondary gids"].Array(), user.secondaryGids);
    UnserializeContainer(obj["gadmin gids"].Array(), user.gadminGids);
    
    user.creator = obj["creator"].Int();
    mongo::BSONElement oid;
    obj.getObjectID(oid);
    user.created = ToGregDate(oid.OID().asDateT());
    
    user.homeDir = obj["home dir"].String();
    user.startUpDir = obj["startup dir"].String();
    user.idleTime = obj["idle time"].Int();
    
    if (obj["expires"].type() != mongo::jstNULL)
      user.expires.reset(ToGregDate(obj["expires"].Date()));
    
    user.numLogins = obj["num logins"].Int();
    user.comment = obj["comment"].String();
    user.tagline = obj["tagline"].String();
    user.maxDownSpeed = obj["max down speed"].Long();
    user.maxUpSpeed = obj["max up speed"].Long();
    user.maxSimDown = obj["max sim down"].Int();
    user.maxSimUp = obj["max sim up"].Int();
    user.loggedIn = obj["logged in"].Int();
    if (obj["last login"].type() != mongo::jstNULL)
      user.lastLogin.reset(ToPosixTime(obj["last login"].Date()));
    
    UnserializeMap(obj["ratio"].Array(), "section", "value", user.ratio);
    UnserializeMap(obj["credits"].Array(), "section", "value", user.credits);
    UnserializeMap(obj["weekly allotment"].Array(), "section", "value", user.weeklyAllotment);
    
    return user;
  }
  catch (const mongo::DBException& e)
  {
    LogException("Unserialize user", e, obj);
    throw e;
  }
}
コード例 #25
0
ファイル: processer.cpp プロジェクト: keyboard-man/kelp
void Processer::DoCluster(const std::string& grid,mongo::BSONObj& cluster)
{
	std::string cluster_id;

	if(cluster.hasField("cluster_ID") && cluster.hasField("host_data"))
	{
		cluster_id = cluster.getStringField("cluster_ID");
		std::vector<mongo::BSONElement> h_ele = cluster["host_data"].Array();
		for(int i=0;i<h_ele.size();i++)
		{
			mongo::BSONObj obj = h_ele[i].Obj();
			DoHost(grid,cluster_id,obj);
		}
	}
	else
	{
		std::stringstream oss;
		oss << "This data is illegal! Drop!!";
		LOG4CXX_WARN(log_,oss.str());
		std::cout << cluster << std::endl;
	}

}
コード例 #26
0
ファイル: MongoUser.cpp プロジェクト: Aahanbhatt/robomongo
 MongoUser::MongoUser(const float version, const mongo::BSONObj &obj) :
     _version(version), _readOnly(false)
 {
     _id = obj.getField("_id").OID();
     _name = BsonUtils::getField<mongo::String>(obj, "user");
     _passwordHash = BsonUtils::getField<mongo::String>(obj, "pwd");
     if (_version<minimumSupportedVersion) {
         _readOnly = BsonUtils::getField<mongo::Bool>(obj, "readOnly");
     }     
     else {
         _userSource = BsonUtils::getField<mongo::String>(obj, "userSource");
         std::vector<mongo::BSONElement> roles = BsonUtils::getField<mongo::Array>(obj, "roles");
         for (std::vector<mongo::BSONElement>::const_iterator it = roles.begin(); it != roles.end(); ++it)
         {
             _role.push_back(BsonUtils::bsonelement_cast<std::string>(*it));
         }
     }
 }
コード例 #27
0
ファイル: utils.cpp プロジェクト: DINKIN/mongo
static BSONObj native_tostrictjson(const mongo::BSONObj& args, void* data) {
    uassert(40275,
            "tostrictjson takes a single BSON object argument, and on optional boolean argument "
            "for prettyPrint -- tostrictjson(obj, prettyPrint = false)",
            args.nFields() >= 1 && args.firstElement().isABSONObj() &&
                (args.nFields() == 1 || (args.nFields() == 2 && args["1"].isBoolean())));

    bool prettyPrint = false;
    if (args.nFields() == 2) {
        prettyPrint = args["1"].boolean();
    }
    return BSON("" << tojson(args.firstElement().embeddedObject(), Strict, prettyPrint));
}
コード例 #28
0
ファイル: stitch_support.cpp プロジェクト: hanumantmk/mongo
 stitch_support_v1_projection(mongo::ServiceContext::UniqueClient client,
                              const mongo::BSONObj& pattern,
                              stitch_support_v1_matcher* matcher,
                              stitch_support_v1_collator* collator)
     : client(std::move(client)),
       opCtx(this->client->makeOperationContext()),
       projectionExec(opCtx.get(),
                      pattern.getOwned(),
                      matcher ? matcher->matcher.getMatchExpression() : nullptr,
                      collator ? collator->collator.get() : nullptr),
       matcher(matcher) {
     uassert(51050,
             "Projections with a positional operator require a matcher",
             matcher || !projectionExec.projectRequiresQueryExpression());
     uassert(51051,
             "$textScore, $sortKey, $recordId, $geoNear and $returnKey are not allowed in this "
             "context",
             !projectionExec.hasMetaFields() && !projectionExec.returnKey());
 }
コード例 #29
0
ファイル: joint.cpp プロジェクト: jacquelinekay/reveal
//-----------------------------------------------------------------------------
bool joint_c::fetch( Reveal::Core::model_ptr model, mongo::BSONObj bson_model ) {

  Reveal::Core::joint_ptr joint;
  mongo::BSONObj bson_joints;
  std::vector<mongo::BSONElement> v_joints;

  bson_joints = bson_model.getObjectField( DOCUMENT );
  bson_joints.elems( v_joints );

  for( unsigned i = 0; i < v_joints.size(); i++ ) {
    joint = Reveal::Core::joint_ptr( new Reveal::Core::joint_c() );

    fetch( joint, v_joints[i].Obj() );

    model->joints.push_back( joint );
  }

  return true;
}
コード例 #30
0
ファイル: MongoSchema.cpp プロジェクト: soleo/MongoAnalytics
	int MongoSchema::extractBSON(mongo::BSONObj bo, int& depth, std::string parent){

		if(depth >= m_depth){
			return 0;
		}
		depth++;
		
		for( BSONObj::iterator i = bo.begin(); i.more(); ) { 
			BSONElement e = i.next();
			
			if(skipField(e.fieldName())){
					continue;
				}

			std::string fieldname = parent ;
			fieldname.append(".");
			fieldname.append(e.fieldName());
			if(e.isSimpleType()){
					hashmap::const_iterator keyexsit = m_map.find(fieldname);
					SchemaModel* sm = new SchemaModel();
					if(keyexsit != m_map.end()){
							sm = &m_map[fieldname];
							sm->count ++;
							
					}else{
							sm->count = 1;
							sm->datatype = getType(e);
							m_map[fieldname] = *sm; 
					}
			 }else if(e.isABSONObj()){
					
					extractBSON(e.Obj(), depth, fieldname);
			}
				
		}
		
		return 0;		
	}