void QgsWFSTableSelectedCallback::tableSelected( const QString& name ) { QString typeName( QgsSQLStatement::stripQuotedIdentifier( name ) ); QString prefixedTypename( mCaps.addPrefixIfNeeded( typeName ) ); if ( prefixedTypename.isEmpty() ) return; QgsWFSDataSourceURI uri( mURI ); uri.setTypeName( prefixedTypename ); QgsWFSProvider p( uri.uri(), mCaps ); if ( !p.isValid() ) { return; } QList< QgsSQLComposerDialog::PairNameType> fieldList; QString fieldNamePrefix( QgsSQLStatement::quotedIdentifierIfNeeded( typeName ) + "." ); Q_FOREACH ( const QgsField& field, p.fields().toList() ) { QString fieldName( fieldNamePrefix + QgsSQLStatement::quotedIdentifierIfNeeded( field.name() ) ); fieldList << QgsSQLComposerDialog::PairNameType( fieldName, field.typeName() ); } if ( !p.geometryAttribute().isEmpty() ) { QString fieldName( fieldNamePrefix + QgsSQLStatement::quotedIdentifierIfNeeded( p.geometryAttribute() ) ); fieldList << QgsSQLComposerDialog::PairNameType( fieldName, "geometry" ); } fieldList << QgsSQLComposerDialog::PairNameType( fieldNamePrefix + "*", "" ); mDialog->addColumnNames( fieldList, name ); }
void timeVaryingFixedDisplacementFvPatchVectorField::updateCoeffs() { if (this->updated()) { return; } vectorField disp ( patch().size(), timeSeries_(this->db().time().timeOutputValue()) ); if (fieldName() == "DU") { const fvPatchField<vector>& U = patch().lookupPatchField<volVectorField, vector>("U"); disp -= U; } else if (fieldName() != "U") { FatalError << "The displacement field should be U or DU" << exit(FatalError); } fvPatchField<vector>::operator== ( disp ); fixedDisplacementFvPatchVectorField::updateCoeffs(); }
String StructureShape::toJSONString() const { // This returns a JSON string representing an Object with the following properties: // constructorName: 'String' // fields: 'Array<String>' // optionalFields: 'Array<String>' // proto: 'JSON<StructureShape> | null' StringBuilder json; json.append("{"); json.append("\"constructorName\":"); json.append("\""); json.append(m_constructorName); json.append("\""); json.append(","); json.append("\"fields\":"); json.append("["); bool hasAnItem = false; for (auto it = m_fields.begin(), end = m_fields.end(); it != end; ++it) { if (hasAnItem) json.append(","); hasAnItem = true; String fieldName((*it).get()); json.append("\""); json.append(fieldName); json.append("\""); } json.append("]"); json.append(","); json.append("\"optionalFields\":"); json.append("["); hasAnItem = false; for (auto it = m_optionalFields.begin(), end = m_optionalFields.end(); it != end; ++it) { if (hasAnItem) json.append(","); hasAnItem = true; String fieldName((*it).get()); json.append("\""); json.append(fieldName); json.append("\""); } json.append("]"); json.append(","); json.append("\"proto\":"); if (m_proto) json.append(m_proto->toJSONString()); else json.append("null"); json.append("}"); return json.toString(); }
bool QgsSpatiaLiteFeatureIterator::prepareStatement( const QString& whereClause, long limit ) { if ( !mHandle ) return false; try { QString sql = QString( "SELECT %1" ).arg( mHasPrimaryKey ? quotedPrimaryKey() : "0" ); int colIdx = 1; // column 0 is primary key if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) { const QgsAttributeList& fetchAttributes = mRequest.subsetOfAttributes(); for ( QgsAttributeList::const_iterator it = fetchAttributes.constBegin(); it != fetchAttributes.constEnd(); ++it ) { sql += ',' + fieldName( mSource->mFields.field( *it ) ); colIdx++; } } else { // fetch all attributes for ( int idx = 0; idx < mSource->mFields.count(); ++idx ) { sql += ',' + fieldName( mSource->mFields.at( idx ) ); colIdx++; } } if ( mFetchGeometry ) { sql += QString( ", AsBinary(%1)" ).arg( QgsSpatiaLiteProvider::quotedIdentifier( mSource->mGeometryColumn ) ); mGeomColIdx = colIdx; } sql += QString( " FROM %1" ).arg( mSource->mQuery ); if ( !whereClause.isEmpty() ) sql += QString( " WHERE %1" ).arg( whereClause ); if ( limit >= 0 ) sql += QString( " LIMIT %1" ).arg( limit ); if ( sqlite3_prepare_v2( mHandle->handle(), sql.toUtf8().constData(), -1, &sqliteStatement, NULL ) != SQLITE_OK ) { // some error occurred QgsMessageLog::logMessage( QObject::tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( mHandle->handle() ) ), QObject::tr( "SpatiaLite" ) ); return false; } } catch ( QgsSpatiaLiteProvider::SLFieldNotFound ) { rewind(); return false; } return true; }
panzer::GatherBasisCoordinates<EvalT, TRAITS>:: GatherBasisCoordinates(const panzer::PureBasis & basis) { basisName_ = basis.name(); basisCoordinates_ = PHX::MDField<ScalarT,Cell,BASIS,Dim>(fieldName(basisName_),basis.coordinates); this->addEvaluatedField(basisCoordinates_); this->setName("Gather "+fieldName(basisName_)); }
panzer::GatherIntegrationCoordinates<EvalT, Traits>:: GatherIntegrationCoordinates(const panzer::IntegrationRule & quad) { quadDegree_ = quad.cubature_degree; quadCoordinates_ = PHX::MDField<ScalarT,Cell,Point,Dim>(fieldName(quadDegree_),quad.dl_vector); this->addEvaluatedField(quadCoordinates_); this->setName("Gather "+fieldName(quadDegree_)); }
Foam::lduSolverPerformance Foam::amgSolver::solve ( scalarField& x, const scalarField& b, const direction cmpt ) const { // Prepare solver performance lduSolverPerformance solverPerf(typeName, fieldName()); scalar norm = this->normFactor(x, b, cmpt); // Calculate initial residual solverPerf.initialResidual() = gSumMag(amg_.residual(x, b, cmpt))/norm; solverPerf.finalResidual() = solverPerf.initialResidual(); if (!stop(solverPerf)) { do { amg_.cycle(x, b, cmpt); // Re-calculate residual solverPerf.finalResidual() = gSumMag(amg_.residual(x, b, cmpt))/norm; solverPerf.nIterations()++; } while (!stop(solverPerf)); } return solverPerf; }
Foam::lduSolverPerformance Foam::cufflink_DiagPCG_Parallel::solve ( scalarField& x, const scalarField& b, const direction cmpt ) const { if (!Pstream::parRun()) { FatalErrorIn("cufflink:\nMulti-GPU Solver cannot be run serially. Choose the serial version of the solver")<< "Fatal Error"<< abort(FatalError); } OFSolverPerformance OFSP;//container for solver performance #include "../CFL_Headers/getGPUStorage.H" // --- Setup class containing solver performance data lduSolverPerformance solverPerf("cufflink_DiagPCG_Parallel",fieldName()); register label nCells = x.size(); register label NFaces = matrix().lower().size(); OFSP.nCells = nCells; OFSP.nFaces = NFaces; OFSP.debugCusp = false; if (lduMatrix::debug >= 2) { OFSP.debugCusp = true; } //interface gathering //used when launching kernals in machines with multiple gpus int gpusPerMachine = readInt(dict().lookup("gpusPerMachine")); //get all the interface information #include "../CFL_Headers/getInterfaces.H" OFInterfaces.gpusPerMachine = gpusPerMachine; if(!OFInterfaces.checkGPUCount(OFInterfaces.gpusPerMachine)) { FatalErrorIn("checkGPUCount:\nThe number of GPUs per machine is not correct.\nChange the gpusPerMachine variable in fvSolution")<< "Fatal Error"<< abort(FatalError); } //end interface gathering #include "../CFL_Headers/initializeCusp.H" //set the device cudaError_t cudareturn; cudareturn = cudaSetDevice(Pstream::myProcNo() % (gpusPerMachine)); if (cudareturn == cudaErrorInvalidDevice){ perror("cudaSetDevice returned cudaErrorInvalidDevice"); } CFL_DiagPCG_Parallel(&CES, &OFSP, &OFInterfaces);//call the CUDA code to solve the system thrust::copy(CES.X.begin(),CES.X.end(),x.begin());//copy the x vector back to Openfoam solverPerf.initialResidual() = OFSP.iRes;//return initial residual solverPerf.finalResidual() = OFSP.fRes;//return final residual solverPerf.nIterations() = OFSP.nIterations;//return the number of iterations //solverPerf.checkConvergence(tolerance(), relTolerance()) ; what should be passed here and does this waste time? return solverPerf; }
Foam::lduSolverPerformance Foam::gmresSolver::solve ( scalarField& x, const scalarField& b, const direction cmpt ) const { // Prepare solver performance lduSolverPerformance solverPerf(typeName, fieldName()); scalarField wA(x.size()); scalarField rA(x.size()); // Calculate initial residual matrix_.Amul(wA, x, coupleBouCoeffs_, interfaces_, cmpt); // Use rA as scratch space when calculating the normalisation factor scalar normFactor = this->normFactor(x, b, wA, rA, cmpt); if (lduMatrix::debug >= 2) { Info<< " Normalisation factor = " << normFactor << endl; } // Calculate residual forAll (rA, i) { rA[i] = b[i] - wA[i]; }
float* Dorade::getRayData(int &ray, const QString& field) { int fldIndex = -1; for (int j=0; j<(rptr->num_param_desc); j++) { QString fieldName(pptr[j].parm_name); if (fieldName.size() > 8) fieldName.resize(8); fieldName.remove(QRegExp("[\\s+]")); if (field == fieldName) { // Match fldIndex = j; break; } } if (fldIndex < 0) { // No match return NULL; } if (ray<(sptr->num_rays)) { return dptr[fldIndex][ray].data; } else { return NULL; } }
UBool CalendarCaseTest::checkField(Calendar *cal, UCalendarDateFields field, int32_t value, UErrorCode &status) { if(U_FAILURE(status)) return FALSE; int32_t res = cal->get(field, status); if(U_FAILURE(status)) { errln((UnicodeString)"Checking field " + fieldName(field) + " and got " + u_errorName(status)); return FALSE; } if(res != value) { errln((UnicodeString)"FAIL: Checking field " + fieldName(field) + " expected " + value + " and got " + res + UnicodeString("\n")); return FALSE; } else { logln((UnicodeString)"Checking field " + fieldName(field) + " == " + value + UnicodeString("\n")); } return TRUE; }
QString FLManager::formatAssignValue(FLFieldMetaData *fMD, const QVariant &v, const bool upper) { if (!fMD) return "1 = 1"; FLTableMetaData *mtd = fMD->metadata(); QString fieldName(fMD->name()); if (mtd && mtd->isQuery()) { QString prefixTable(mtd->name()); FLSqlQuery *qry = query(mtd->query()); if (qry) { QStringList fL(qry->fieldList()); for (QStringList::Iterator it = fL.begin(); it != fL.end(); ++it) { prefixTable = (*it).section('.', 0, 0); if ((*it).section('.', 1, 1) == fieldName) break; } qry->deleteLater(); } fieldName.prepend(prefixTable + "."); } return formatAssignValue(fieldName, fMD->type(), v, upper); }
Foam::lduSolverPerformance Foam::bicgStabSolver::solve ( scalarField& x, const scalarField& b, const direction cmpt ) const { // Prepare solver performance lduSolverPerformance solverPerf(typeName, fieldName()); scalarField p(x.size()); scalarField r(x.size()); // Calculate initial residual matrix_.Amul(p, x, coupleBouCoeffs_, interfaces_, cmpt); scalar normFactor = this->normFactor(x, b, p, r, cmpt); if (lduMatrix::debug >= 2) { Info<< " Normalisation factor = " << normFactor << endl; } // Calculate residual forAll (r, i) { r[i] = b[i] - p[i]; }
Foam::lduSolverPerformance Foam::cufflink_CG::solve ( scalarField& x, const scalarField& b, const direction cmpt ) const { OFSolverPerformance OFSP;//container for solver performance #include "../CFL_Headers/getGPUStorage.H" // --- Setup class containing solver performance data lduSolverPerformance solverPerf("cufflink_CG",fieldName()); register label nCells = x.size(); register label NFaces = matrix().lower().size(); OFSP.nCells = nCells; OFSP.nFaces = NFaces; OFSP.debugCusp = false; if (lduMatrix::debug >= 2) { OFSP.debugCusp = true; } #include "../CFL_Headers/initializeCusp.H" CFL_CG(&CES, &OFSP);//call the CUDA code to solve the system thrust::copy(CES.X.begin(),CES.X.end(),x.begin());//copy the x vector back to Openfoam solverPerf.initialResidual() = OFSP.iRes;//return initial residual solverPerf.finalResidual() = OFSP.fRes;//return final residual solverPerf.nIterations() = OFSP.nIterations;//return the number of iterations //solverPerf.checkConvergence(tolerance(), relTolerance()) ; what should be passed here and does this waste time? return solverPerf; }
void Q3SqlCursor::sync() { if (isActive() && isValid() && d->lastAt != at()) { d->lastAt = at(); int i = 0; int j = 0; bool haveCalculatedFields = false; for (; i < count(); ++i) { if (!haveCalculatedFields && d->infoBuffer[i].isCalculated()) { haveCalculatedFields = true; } if (QSqlRecord::isGenerated(i)) { QVariant v = QSqlQuery::value(j); if ((v.type() == QVariant::String) && d->infoBuffer[i].isTrim()) { v = qTrim(v.toString()); } QSqlRecord::setValue(i, v); if (QSqlQuery::isNull(j)) QSqlRecord::field(i).clear(); j++; } } if (haveCalculatedFields) { for (i = 0; i < count(); ++i) { if (d->infoBuffer[i].isCalculated()) QSqlRecord::setValue(i, calculateField(fieldName(i))); } } } }
int BSONElement::getGtLtOp() const { const char *fn = fieldName(); if ( fn[0] == '$' && fn[1] ) { if ( fn[2] == 't' ) { if ( fn[1] == 'g' ) { if ( fn[3] == 0 ) return BSONObj::GT; else if ( fn[3] == 'e' && fn[4] == 0 ) return BSONObj::GTE; } else if ( fn[1] == 'l' ) { if ( fn[3] == 0 ) return BSONObj::LT; else if ( fn[3] == 'e' && fn[4] == 0 ) return BSONObj::LTE; } } else if ( fn[2] == 'e' ) { if ( fn[1] == 'n' && fn[3] == 0 ) return BSONObj::NE; } else if ( fn[1] == 'i' && fn[2] == 'n' && fn[3] == 0 ) return BSONObj::opIN; else if ( fn[1] == 'n' && fn[2] == 'i' && fn[3] == 'n' && fn[4] == 0 ) return BSONObj::NIN; else if ( fn[1] == 'a' && fn[2] == 'l' && fn[3] == 'l' && fn[4] == 0 ) return BSONObj::opALL; else if ( fn[1] == 's' && fn[2] == 'i' && fn[3] == 'z' && fn[4] == 'e' && fn[5] == 0 ) return BSONObj::opSIZE; } return BSONObj::Equality; }
const IniConfigT::Str *IniConfigT::Section::getValue(const ConstStrA &field, natural index) const { if (prefix.empty()) { return owner.getValue(section,field,index); } else { StringA fieldName(prefix+field); return owner.getValue(section,fieldName,index); } }
BSONObj BSONElement::embeddedObjectUserCheck() const { if (MONGO_likely(isABSONObj())) return BSONObj(value(), BSONObj::LargeSizeTrait{}); std::stringstream ss; ss << "invalid parameter: expected an object (" << fieldName() << ")"; uasserted(10065, ss.str()); return BSONObj(); // never reachable }
void symbols_init(){ int i; symbols_size = 128; symbols = (Symbol*) malloc(symbols_size * sizeof(Symbol)); for(i=0;i<fieldsCount();i++) symbols_getId(fieldName(i)); }
Status ServerSelectionMetadata::upconvert(const BSONObj& legacyCommand, const int legacyQueryFlags, BSONObjBuilder* commandBob, BSONObjBuilder* metadataBob) { // The secondaryOK option is equivalent to the slaveOk bit being set on legacy commands. BSONObjBuilder ssmBob; if (legacyQueryFlags & QueryOption_SlaveOk) { ssmBob.append(kSecondaryOkFieldName, 1); } // First we need to check if we have a wrapped command. That is, a command of the form // {'$query': { 'commandName': 1, ...}, '$someOption': 5, ....}. Curiously, the field name // of the wrapped query can be either '$query', or 'query'. auto swUnwrapped = unwrapCommand(legacyCommand); if (!swUnwrapped.isOK()) { return swUnwrapped.getStatus(); } BSONObj maybeUnwrapped; bool wasWrapped; std::tie(wasWrapped, maybeUnwrapped) = swUnwrapped.getValue(); if (wasWrapped) { // Check if legacyCommand has an invalid $maxTimeMS option. // TODO: Move this check elsewhere when we handle upconverting/downconverting maxTimeMS. if (legacyCommand.hasField("$maxTimeMS")) { return Status(ErrorCodes::InvalidOptions, "cannot use $maxTimeMS query option with " "commands; use maxTimeMS command option " "instead"); } // If the command was wrapped, we can write out the upconverted command now, as there // is nothing else we need to remove from it. commandBob->appendElements(maybeUnwrapped); auto status = extractWrappedReadPreference(legacyCommand, &ssmBob); if (!status.isOK()) { return status; } } else { // If the command was not wrapped, we need to check for a readPreference sent by mongos // on the $queryOptions field of the command. If it is set, we remove it from the // upconverted command, so we need to pass the command builder along. auto status = extractUnwrappedReadPreference(maybeUnwrapped, commandBob, &ssmBob); if (!status.isOK()) { return status; } } auto ssm = ssmBob.done(); if (!ssm.isEmpty()) { metadataBob->append(fieldName(), ssm); } return Status::OK(); }
telldata::tell_var* telldata::user_struct::field_var(char*& fname) { std::string fieldName(fname); fieldName.erase(0,1); for(recfieldsNAME::const_iterator CI = _fieldList.begin(); CI != _fieldList.end(); CI++) { if (fieldName == CI->first) return CI->second; } return NULL; }
TITANIUM_FUNCTION(ResultSet, fieldName) { ENSURE_UINT_AT_INDEX(index, 0); const std::string result = fieldName(index); if (result.empty()) { return get_context().CreateNull(); } return get_context().CreateString(result); }
Field *Node::getField(const char *fieldString) { String fieldName(fieldString); int nField = getNFields(); for (int n=0; n<nField; n++) { Field *field = getField(n); if (fieldName.compareTo(field->getName()) == 0) return field; } return NULL; }
Status ServerSelectionMetadata::downconvert(const BSONObj& command, const BSONObj& metadata, BSONObjBuilder* legacyCommand, int* legacyQueryFlags) { auto ssmElem = metadata.getField(fieldName()); if (ssmElem.eoo()) { // slaveOk is false by default. *legacyQueryFlags &= ~mongo::QueryOption_SlaveOk; legacyCommand->appendElements(command); return Status::OK(); } else if (ssmElem.type() != mongo::Object) { return { ErrorCodes::TypeMismatch, str::stream() << "ServerSelectionMetadata metadata element must be an object, but got " << typeName(ssmElem.type())}; } auto ssmObj = ssmElem.Obj(); BSONElement secondaryOkElem; BSONElement readPreferenceElem; for (auto&& el : ssmObj) { auto fname = el.fieldNameStringData(); if (fname == kSecondaryOkFieldName) { secondaryOkElem = std::move(el); } else if (fname == kReadPreferenceFieldName) { readPreferenceElem = std::move(el); } } if (!secondaryOkElem.eoo() && secondaryOkElem.trueValue()) { *legacyQueryFlags |= mongo::QueryOption_SlaveOk; } else { *legacyQueryFlags &= ~mongo::QueryOption_SlaveOk; } if (!readPreferenceElem.eoo()) { // Use 'query' to wrap query, then append read preference. // NOTE(amidvidy): Oddly, the _isSecondaryQuery implementation in dbclient_rs does // not unwrap the query properly - it only checks for 'query', and not // '$query'. We should probably standardize on one - drivers use '$query', // and the shell uses 'query'. See SERVER-18705 for details. // TODO: this may need to use the $queryOptions hack on mongos. legacyCommand->append(kQueryWrapper, command); legacyCommand->append(readPreferenceElem); } else { legacyCommand->appendElements(command); } return Status::OK(); }
/** * Suppress the "err" and "code" field if they are coming from a previous write error and * are not related to write concern. Also removes any write stats information (e.g. "n") * * Also, In some cases, 2.4 GLE w/ wOpTime can give us duplicate "err" and "code" fields b/c of * reporting a previous error. The later field is what we want - dedup and use later field. * * Returns the stripped GLE response. */ BSONObj BatchSafeWriter::stripNonWCInfo( const BSONObj& gleResponse ) { BSONObjIterator it( gleResponse ); BSONObjBuilder builder; BSONElement codeField; // eoo BSONElement errField; // eoo while ( it.more() ) { BSONElement el = it.next(); StringData fieldName( el.fieldName() ); if ( fieldName.compare( "err" ) == 0 ) { errField = el; } else if ( fieldName.compare( "code" ) == 0 ) { codeField = el; } else if ( fieldName.compare( "n" ) == 0 || fieldName.compare( "nModified" ) == 0 || fieldName.compare( "upserted" ) == 0 || fieldName.compare( "updatedExisting" ) == 0 ) { // Suppress field } else { builder.append( el ); } } if ( !codeField.eoo() ) { if ( !gleResponse["ok"].trueValue() ) { // The last code will be from the write concern builder.append( codeField ); } else { // The code is from a non-wc error on this connection - suppress it } } if ( !errField.eoo() ) { string err = errField.str(); if ( err == "norepl" || err == "noreplset" || err == "timeout" ) { // Append err if it's from a write concern issue builder.append( errField ); } else { // Suppress non-write concern err as null, but we need to report null err if ok if ( gleResponse["ok"].trueValue() ) builder.appendNull( errField.fieldName() ); } } return builder.obj(); }
/** * A doc is empty if it only contains the fields id and text */ static bool docEmpty( lucene::document::Document* doc ) { int cnt = 0; lucene::document::DocumentFieldEnumeration* it = doc->fields(); while ( it->hasMoreElements() ) { lucene::document::Field* field = it->nextElement(); TString fieldName( field->name(), true ); if ( fieldName != Index::idFieldName() && fieldName != Index::textFieldName() ) ++cnt; } delete it; return cnt == 0; }
PTPFollowupCorruptionComponent::PTPFollowupCorruptionComponent(ValueTree corruptionTree_, int64 adapterGuid_) : PTPCorruptionComponent(corruptionTree_, adapterGuid_) { titleLabel.setText("Follow_Up field corruption", dontSendNotification); for (int fieldIndex = 0; fieldIndex < PacketFollowUp::NUM_FIELDS; ++fieldIndex) { String fieldName(PacketFollowUp::getFieldName(fieldIndex)); PacketPTP::Field field; field.index = fieldIndex; PacketFollowUp::getField(field, adapterGuid_); addFieldComponent(fieldName, field); } }
int BSONElement::getGtLtOp( int def ) const { const char *fn = fieldName(); if ( fn[0] == '$' && fn[1] ) { if ( fn[2] == 't' ) { if ( fn[1] == 'g' ) { if ( fn[3] == 0 ) return BSONObj::GT; else if ( fn[3] == 'e' && fn[4] == 0 ) return BSONObj::GTE; } else if ( fn[1] == 'l' ) { if ( fn[3] == 0 ) return BSONObj::LT; else if ( fn[3] == 'e' && fn[4] == 0 ) return BSONObj::LTE; } } else if ( fn[1] == 'n' && fn[2] == 'e' ){ if ( fn[3] == 0 ) return BSONObj::NE; if ( fn[3] == 'a' && fn[4] == 'r' && fn[5] == 0 ) return BSONObj::opNEAR; } else if ( fn[1] == 'm' ){ if ( fn[2] == 'o' && fn[3] == 'd' && fn[4] == 0 ) return BSONObj::opMOD; if ( fn[2] == 'a' && fn[3] == 'x' && fn[4] == 'D' && fn[5] == 'i' && fn[6] == 's' && fn[7] == 't' && fn[8] == 'a' && fn[9] == 'n' && fn[10] == 'c' && fn[11] == 'e' && fn[12] == 0 ) return BSONObj::opMAX_DISTANCE; } else if ( fn[1] == 't' && fn[2] == 'y' && fn[3] == 'p' && fn[4] == 'e' && fn[5] == 0 ) return BSONObj::opTYPE; else if ( fn[1] == 'i' && fn[2] == 'n' && fn[3] == 0 ) return BSONObj::opIN; else if ( fn[1] == 'n' && fn[2] == 'i' && fn[3] == 'n' && fn[4] == 0 ) return BSONObj::NIN; else if ( fn[1] == 'a' && fn[2] == 'l' && fn[3] == 'l' && fn[4] == 0 ) return BSONObj::opALL; else if ( fn[1] == 's' && fn[2] == 'i' && fn[3] == 'z' && fn[4] == 'e' && fn[5] == 0 ) return BSONObj::opSIZE; else if ( fn[1] == 'e' ){ if ( fn[2] == 'x' && fn[3] == 'i' && fn[4] == 's' && fn[5] == 't' && fn[6] == 's' && fn[7] == 0 ) return BSONObj::opEXISTS; if ( fn[2] == 'l' && fn[3] == 'e' && fn[4] == 'm' && fn[5] == 'M' && fn[6] == 'a' && fn[7] == 't' && fn[8] == 'c' && fn[9] == 'h' && fn[10] == 0 ) return BSONObj::opELEM_MATCH; } else if ( fn[1] == 'r' && fn[2] == 'e' && fn[3] == 'g' && fn[4] == 'e' && fn[5] == 'x' && fn[6] == 0 ) return BSONObj::opREGEX; else if ( fn[1] == 'o' && fn[2] == 'p' && fn[3] == 't' && fn[4] == 'i' && fn[5] == 'o' && fn[6] == 'n' && fn[7] == 's' && fn[8] == 0 ) return BSONObj::opOPTIONS; else if ( fn[1] == 'w' && fn[2] == 'i' && fn[3] == 't' && fn[4] == 'h' && fn[5] == 'i' && fn[6] == 'n' && fn[7] == 0 ) return BSONObj::opWITHIN; } return def; }
void LogicalTimeMetadata::writeToMetadata(BSONObjBuilder* metadataBuilder) const { BSONObjBuilder subObjBuilder(metadataBuilder->subobjStart(fieldName())); _clusterTime.getTime().asTimestamp().append(subObjBuilder.bb(), kClusterTimeFieldName); BSONObjBuilder signatureObjBuilder(subObjBuilder.subobjStart(kSignatureFieldName)); // Logical time metadata is only written when the LogicalTimeValidator is set, which // means the cluster time should always have a proof. invariant(_clusterTime.getProof()); _clusterTime.getProof()->appendAsBinData(signatureObjBuilder, kSignatureHashFieldName); signatureObjBuilder.append(kSignatureKeyIdFieldName, _clusterTime.getKeyId()); signatureObjBuilder.doneFast(); subObjBuilder.doneFast(); }
Document::Document(BSONObj *pBsonObj): vFieldName(), vpValue() { BSONObjIterator bsonIterator(pBsonObj->begin()); while(bsonIterator.more()) { BSONElement bsonElement(bsonIterator.next()); string fieldName(bsonElement.fieldName()); intrusive_ptr<const Value> pValue( Value::createFromBsonElement(&bsonElement)); vFieldName.push_back(fieldName); vpValue.push_back(pValue); } }