ChunkVersion forceShardFilteringMetadataRefresh(OperationContext* opCtx, const NamespaceString& nss, bool forceRefreshFromThisThread) { invariant(!opCtx->lockState()->isLocked()); invariant(!opCtx->getClient()->isInDirectClient()); auto const shardingState = ShardingState::get(opCtx); invariant(shardingState->canAcceptShardedCommands()); const auto routingInfo = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfoWithRefresh( opCtx, nss, forceRefreshFromThisThread)); const auto cm = routingInfo.cm(); if (!cm) { // No chunk manager, so unsharded. // Exclusive collection lock needed since we're now changing the metadata AutoGetCollection autoColl(opCtx, nss, MODE_IX, MODE_X); auto css = CollectionShardingState::get(opCtx, nss); css->refreshMetadata(opCtx, nullptr); return ChunkVersion::UNSHARDED(); } { AutoGetCollection autoColl(opCtx, nss, MODE_IS); auto metadata = CollectionShardingState::get(opCtx, nss)->getMetadata(opCtx); // We already have newer version if (metadata && metadata->getCollVersion().epoch() == cm->getVersion().epoch() && metadata->getCollVersion() >= cm->getVersion()) { LOG(1) << "Skipping refresh of metadata for " << nss << " " << metadata->getCollVersion() << " with an older " << cm->getVersion(); return metadata->getShardVersion(); } } // Exclusive collection lock needed since we're now changing the metadata AutoGetCollection autoColl(opCtx, nss, MODE_IX, MODE_X); auto css = CollectionShardingState::get(opCtx, nss); auto metadata = css->getMetadata(opCtx); // We already have newer version if (metadata && metadata->getCollVersion().epoch() == cm->getVersion().epoch() && metadata->getCollVersion() >= cm->getVersion()) { LOG(1) << "Skipping refresh of metadata for " << nss << " " << metadata->getCollVersion() << " with an older " << cm->getVersion(); return metadata->getShardVersion(); } std::unique_ptr<CollectionMetadata> newCollectionMetadata = stdx::make_unique<CollectionMetadata>(cm, shardingState->getShardName()); css->refreshMetadata(opCtx, std::move(newCollectionMetadata)); return css->getMetadata(opCtx)->getShardVersion(); }
/** * @brief BTRecordFile::insertRecord * @param pListPtr * @return newRecord, nuevo registro insertado * Función para insertar registros en la RAM */ BTRecord *BTRecordFile::insertRecord(DLL<IRecordDataType *> *pListPtr) { std::cout << "------------------------------------------------------------" "\nMetadatos inicio: \n"; getMetadata()->printMetadata(); std::cout << "------------------------------------------------------------\n\n"; unsigned short cantRegistros = this->_metadataPtr->getNumberOfRecords(); unsigned short tamanoRegistro = this->_metadataPtr->getRecordSize(); unsigned short posicionPrimerRegistro = this->_metadataPtr->getFirstRecordPos(); std::string dataBinaryRecord; // concatenacion del registro a binario cout << "cantRegistros: " << cantRegistros << endl; cout << "tamanoRegistro: " << tamanoRegistro << endl; cout << "BOF: " << posicionPrimerRegistro << endl; cout << "EOF: " << _metadataPtr->getEOF() << endl; if (this->_metadataPtr->getFreeBlockList() == 0) { if (cantRegistros == 1) { dataBinaryRecord = "000000000000000000000000"; // No tiene ni padre ni hijos } else { // se insertan otros registros después de haber uno cout << "CANTIDAD DE REGISTROS--> " << cantRegistros << endl; unsigned short fatherPosition = posicionPrimerRegistro + ((tamanoRegistro) * ((cantRegistros / 2) - 1)); std::string leftChild = "00000000"; // obtiene el hijo izq std::string rightChild = "00000000"; // obtiene el hijo der modifyLastTreeRegistry(cantRegistros, fatherPosition); // cambia datos del registro padre unsigned short padre = (cantRegistros / 2); std::string parent = _conversion->decimalToBinary(std::to_string(padre)); dataBinaryRecord = (parent + leftChild + rightChild); } dataBinaryRecord += getUserRecordData(pListPtr); cout << "El BINARIO es-->: " << dataBinaryRecord << endl; // cout << "El tamano BINARIO es-->: " << dataBinaryRecord.length() << endl; // cout << "tamanoRegistro " << _metadataPtr->getRecordSize() << endl; std::cout << "???????????????????????????????????????????????\n"; std::cout << "Dirección de inserción: \n"; std::cout << "eof: " << _metadataPtr->getEOF(); this->_disk->write(this->_metadataPtr->getEOF() , _conversion->fromStringToConstChar(dataBinaryRecord)); // en vez de cero sería en EOF std::cout << "\n???????????????????????????????????????????????\n"; // Actualiza el tamaño de EOF y la cantidad de registros insertados this->_metadataPtr->setEOF(this->_metadataPtr->getEOF() + tamanoRegistro); //cout << "EOF " << this->_metadataPtr->getEOF() << endl; // cout << "BOF " << this->_metadataPtr->getFirstRecordPos() << endl; this->_metadataPtr->setNumberOfRecords(++cantRegistros); } else { cout << "$$$$$$$$$$ Insertando en espacio... $$$$$$$$$$" << endl; aux_InsertRecord2Disk(pListPtr); } cout << "-----------------------------------------------------------------" << endl; cout << "$$$$$$$$$$ Escritura a disco finalizada $$$$$$$$$$" << endl; cout << "-----------------------------------------------------------------" << endl; std::cout << "\n\n------------------------------------------------------------" "\nMetadatos final: \n"; getMetadata()->printMetadata(); std::cout << "------------------------------------------------------------\n\n"; }
QString FormatContext::title() const { if (isStreamed) { const QByteArray icyName = getTag(formatCtx->metadata, "icy-name", false); if (!icyName.isEmpty()) return icyName; } if (lengthToPlay > 0.0) return QString(); if (AVDictionary *dict = getMetadata()) { const QString title = getTag(dict, "title"); const QString artist = artistWithTitle ? getTag(dict, "artist") : QString(); if (!title.isEmpty() && !artist.isEmpty()) return artist + " - " + title; else if (title.isEmpty() && !artist.isEmpty()) return artist; else if (!title.isEmpty() && artist.isEmpty()) return title; } if (oggHelper) return tr("Track") + " " + QString::number(oggHelper->track); return QString(); }
// Deferring write until this time allows both points and faces from multiple // point views to be written. void PlyWriter::done(PointTableRef table) { for (auto& v : m_views) { PointRef point(*v, 0); for (PointId idx = 0; idx < v->size(); ++idx) { point.setPointId(idx); writePoint(point, table.layout()); } } if (m_faces) { PointId offset = 0; for (auto& v : m_views) { TriangularMesh *mesh = v->mesh(); if (mesh) { for (size_t id = 0; id < mesh->size(); ++id) { const Triangle& t = (*mesh)[id]; writeTriangle(t, offset); } } offset += v->size(); } } Utils::closeFile(m_stream); m_stream = nullptr; getMetadata().addList("filename", m_filename); }
void DecoderIOFactoryFile::start(void) { QString sourcename = getMetadata().Filename(); VERBOSE(VB_PLAYBACK, QString("DecoderIOFactory: Opening Local File %1").arg(sourcename)); m_input = new QFile(sourcename); doConnectDecoder(getUrl().toLocalFile()); }
void NetworkInterfaceASIO::_completedWriteCallback(AsyncOp* op) { // If we were told to send an empty message, toRecv will be empty here. // TODO: handle metadata readers const auto elapsed = [this, op]() { return now() - op->start(); }; if (op->toRecv()->empty()) { LOG(3) << "received an empty message"; return _completeOperation(op, RemoteCommandResponse(BSONObj(), BSONObj(), elapsed())); } try { auto reply = rpc::makeReply(op->toRecv()); if (reply->getProtocol() != op->operationProtocol()) { return _completeOperation(op, Status(ErrorCodes::RPCProtocolNegotiationFailed, str::stream() << "Mismatched RPC protocols - request was '" << opToString(op->toSend()->operation()) << "' '" << " but reply was '" << opToString(op->toRecv()->operation()) << "'")); } _completeOperation(op, // unavoidable copy RemoteCommandResponse(reply->getCommandReply().getOwned(), reply->getMetadata().getOwned(), elapsed())); } catch (...) { // makeReply can throw if the reply was invalid. _completeOperation(op, exceptionToStatus()); } }
void MakerNoteWidget::slotSaveMetadataToFile() { QUrl url = saveMetadataToFile(i18n("EXIF File to Save"), QString(QLatin1String("*.exif|") + i18n("EXIF binary Files (*.exif)"))); storeMetadataToFile(url, getMetadata().getExifEncoded()); }
PointViewPtr IcpFilter::icp(PointViewPtr fixed, PointViewPtr moving) const { typedef pcl::PointXYZ Point; typedef pcl::PointCloud<Point> Cloud; Cloud::Ptr fixedCloud(new Cloud()); pclsupport::PDALtoPCD(fixed, *fixedCloud); Cloud::Ptr movingCloud(new Cloud()); pclsupport::PDALtoPCD(moving, *movingCloud); pcl::IterativeClosestPoint<Point, Point> icp; icp.setInputSource(movingCloud); icp.setInputTarget(fixedCloud); Cloud result; icp.align(result); MetadataNode root = getMetadata(); // I couldn't figure out the template-fu to get // `MetadataNodeImpl::setValue` to work for all Eigen matrices with one // function, so I'm just brute-forcing the cast for now. root.add("transform", Eigen::MatrixXd(icp.getFinalTransformation().cast<double>())); root.add("converged", icp.hasConverged()); root.add("fitness", icp.getFitnessScore()); assert(moving->size() == result.points.size()); for (PointId i = 0; i < moving->size(); ++i) { moving->setField(Dimension::Id::X, i, result.points[i].x); moving->setField(Dimension::Id::Y, i, result.points[i].y); moving->setField(Dimension::Id::Z, i, result.points[i].z); } return moving; }
bool NameSpace::MetadataTrieTree::Node::insert(Metadata* metadata, int offset) { assert(0 == ((size_t)metadata & 1)); if(isNull()) { setMetadata(metadata); return true; } else if(isMetadata()) { Metadata* currentMetadata = getMetadata(); Node* children = paf_new Node[num_metadata_name_char]; assert(0 == ((size_t)children & 1)); setChildren(children); size_t currentIndex = GetIndex(currentMetadata->m_name[offset]); children[currentIndex].setMetadata(currentMetadata); size_t index = GetIndex(metadata->m_name[offset]); if(0 == currentIndex && 0 == index) { return false; } else { return children[index].insert(metadata, offset + 1); } } else { Node* children = getChildren(); size_t index = GetIndex(metadata->m_name[offset]); return children[index].insert(metadata, offset + 1); } }
ResponseStatus NetworkInterfaceASIO::_responseFromMessage(const Message& received, rpc::Protocol protocol) { try { // TODO: elapsed isn't going to be correct here, SERVER-19697 auto start = now(); auto reply = rpc::makeReply(&received); if (reply->getProtocol() != protocol) { auto requestProtocol = rpc::toString(static_cast<rpc::ProtocolSet>(protocol)); if (!requestProtocol.isOK()) return requestProtocol.getStatus(); return Status(ErrorCodes::RPCProtocolNegotiationFailed, str::stream() << "Mismatched RPC protocols - request was '" << requestProtocol.getValue().toString() << "' '" << " but reply was '" << opToString(received.operation()) << "'"); } // unavoidable copy auto ownedCommandReply = reply->getCommandReply().getOwned(); auto ownedReplyMetadata = reply->getMetadata().getOwned(); return ResponseStatus( RemoteCommandResponse(ownedCommandReply, ownedReplyMetadata, now() - start)); } catch (...) { // makeReply can throw if the reply was invalid. return exceptionToStatus(); } }
void DBClientCursor::commandDataReceived() { int op = batch.m.operation(); invariant(op == opReply || op == dbCommandReply); batch.nReturned = 1; batch.pos = 0; auto commandReply = rpc::makeReply(&batch.m); auto commandStatus = getStatusFromCommandResult(commandReply->getCommandReply()); if (ErrorCodes::SendStaleConfig == commandStatus) { throw RecvStaleConfigException("stale config in DBClientCursor::dataReceived()", commandReply->getCommandReply()); } else if (!commandStatus.isOK()) { wasError = true; } if (_client->getReplyMetadataReader()) { uassertStatusOK(_client->getReplyMetadataReader()(commandReply->getMetadata(), _client->getServerAddress())); } // HACK: If we got an OP_COMMANDREPLY, take the reply object // and shove it in to an OP_REPLY message. if (op == dbCommandReply) { // Need to take ownership here as we destroy the underlying message. BSONObj reply = commandReply->getCommandReply().getOwned(); batch.m.reset(); replyToQuery(0, batch.m, reply); } QueryResult::View qr = batch.m.singleData().view2ptr(); batch.data = qr.data(); }
void P2gWriter::done(PointTableRef table) { double adfGeoTransform[6]; adfGeoTransform[0] = m_bounds.minx - 0.5*m_GRID_DIST_X; adfGeoTransform[1] = m_GRID_DIST_X; adfGeoTransform[2] = 0.0; adfGeoTransform[3] = m_bounds.maxy + 0.5*m_GRID_DIST_Y; adfGeoTransform[4] = 0.0; adfGeoTransform[5] = -1 * m_GRID_DIST_Y; SpatialReference const& srs = table.spatialReference(); log()->get(LogLevel::Debug) << "Output SRS :'" << srs.getWKT() << "'" << std::endl; // Strip off the extension if it was provided so that we don't get // file.asc.type.asc or file.asc.asc, as point2grid appends a file // extension. std::string extension = FileUtils::extension(m_filename); if (extension == ".asc" || extension == ".grid" || extension == ".tif") m_filename = m_filename.substr(0, m_filename.find_last_of(".")); if (m_interpolator->finish(m_filename.c_str(), m_outputFormat, m_outputTypes, adfGeoTransform, srs.getWKT().c_str()) < 0) { ostringstream oss; oss << getName() << ": interp->finish() error"; throw pdal_error(oss.str()); } getMetadata().addList("filename", m_filename); }
UpdateSystemThread::~UpdateSystemThread() { BlockMetadata* m = getMetadata(); if (m != NULL) { impl->idToObject.remove(&m->identifier); FD_DELETE(BlockMetadata, *m, impl->pooledAllocator); } }
const std::vector<FieldRef*>* UpdateLifecycleImpl::getImmutableFields() const { CollectionMetadataPtr metadata = getMetadata(_nsString); if (metadata) { const std::vector<FieldRef*>& fields = metadata->getKeyPatternFields(); // Return shard-keys as immutable for the update system. return &fields; } return NULL; }
void ProgrammableFilter::filter(PointView& view) { log()->get(LogLevel::Debug5) << "Python script " << *m_script << " processing " << view.size() << " points." << std::endl; m_pythonMethod->resetArguments(); m_pythonMethod->begin(view, m_totalMetadata); m_pythonMethod->execute(); m_pythonMethod->end(view, getMetadata()); }
void DecoderIOFactoryShoutCast::shoutcastMeta(const QString &metadata) { LOG(VB_PLAYBACK, LOG_INFO, QString("DecoderIOFactoryShoutCast: metadata changed - %1") .arg(metadata)); ShoutCastMetaParser parser; parser.setMetaFormat(getMetadata().MetadataFormat()); ShoutCastMetaMap meta_map = parser.parseMeta(metadata); MusicMetadata mdata = getMetadata(); mdata.setTitle(meta_map["title"]); mdata.setArtist(meta_map["artist"]); mdata.setAlbum(meta_map["album"]); mdata.setLength(-1); DecoderHandlerEvent ev(DecoderHandlerEvent::Meta, mdata); dispatch(ev); }
SaveMenu::SaveMenu(GameContext& gameContext, std::shared_ptr<Task> saveTask) : GameState(gameContext, GameStateType::MENU, "LoadMenu"), m_model(*this, getMetadata()), m_saveLocation(SaveLocation()), m_saveTask(saveTask), m_saveGameViewModel(m_model) { initializeMenu(); initializeConfirmDialog(true /*loadMode*/); }
//public Metadata *CdDecoder::getLastMetadata() { for(int i = getNumTracks(); i > 0; --i) { Metadata *m = getMetadata(i); if(m) return m; } return NULL; }
SaveMenu::SaveMenu(GameContext& gameContext, std::weak_ptr<PlayerData> playerData, const SaveLocation saveLocation, std::shared_ptr<Task> saveTask) : GameState(gameContext, GameStateType::MENU, "SaveMenu"), m_model(*this, getMetadata()), m_saveLocation(saveLocation), m_playerData(playerData), m_saveTask(saveTask), m_saveGameViewModel(m_model) { initializeMenu(); initializeConfirmDialog(false /*loadMode*/); }
bool CollectionShardingState::collectionIsSharded() { auto metadata = getMetadata().getMetadata(); if (metadata && (metadata->getCollVersion().isStrictlyEqualTo(ChunkVersion::UNSHARDED()))) { return false; } // If 'metadata' is null, then the shard doesn't know if this collection is sharded or not. In // this scenario we will assume this collection is sharded. We will know sharding state // definitively once SERVER-24960 has been fixed. return true; }
bool VideoSource::updateName() { bool nameChanged = false; std::string sdesName = getMetadata( VPMSession::VPMSESSION_SDES_NAME ); std::string sdesCname = getMetadata( VPMSession::VPMSESSION_SDES_CNAME ); if ( sdesName != "" && sdesName != name ) { name = sdesName; nameChanged = true; finalName = true; gravUtil::logVerbose( "VideoSource::updateName: got name: %s\n", name.c_str() ); } if ( sdesCname != "" && sdesCname != altName ) { altName = sdesCname; nameChanged = true; gravUtil::logVerbose( "VideoSource::updateName: got cname: %s\n", altName.c_str() ); } // if we don't have a proper name yet just use cname if ( name == "" && sdesCname != "" ) name = sdesCname; // also update the location info std::string loc = getMetadata( VPMSession::VPMSESSION_SDES_LOC ); size_t pos = loc.find( ',' ); if ( pos != std::string::npos ) { std::string latS = loc.substr( 0, pos ); std::string lonS = loc.substr( pos+1 ); lat = strtod( latS.c_str(), NULL ); lon = strtod( lonS.c_str(), NULL ); } if ( nameChanged ) updateTextBounds(); return nameChanged; }
vector<AbstractGui*> guiConstruct::guiBoxConstruct(char* metadata_file, string NodeValue) { vector<AbstractGui*> boxes; int index = 1; //for naming the elements ifstream metadata_stream ((char*)metadata_file, ios::in); if (metadata_stream == NULL) { return boxes; } char line[1000]; metadata_stream.getline(line, 1000); while (!metadata_stream.eof()) { string value = getNodeValue(line); if (value == NodeValue) { string str_metadata = getMetadata(line); int lb_corner_x; int lb_corner_y; int width; int height; int position1 = 0; int position2 = str_metadata.find(","); lb_corner_x = capturedData; position1 = position2 + 1; position2 = str_metadata.find(",", position1); lb_corner_y = capturedData; position1 = position2 + 1; position2 = str_metadata.find(",", position1); width = capturedData; position1 = position2 + 1; height = atoi(str_metadata.substr(position2 + 1).data()); Point* lb_corner = new Point(lb_corner_x , lb_corner_y); Box* box = new Box(*lb_corner, width, height, index++); boxes.push_back(box); } memset(line,0,1000); metadata_stream.getline(line, 1000); } metadata_stream.close(); return boxes; }
bool FormatContext::getReplayGain(bool album, float &gain_db, float &peak) const { if (AVDictionary *dict = getMetadata()) { AVDictionaryEntry *avtag; QString album_gain_db, album_peak, track_gain_db, track_peak; if ((avtag = av_dict_get(dict, "REPLAYGAIN_ALBUM_GAIN", NULL, AV_DICT_IGNORE_SUFFIX)) && avtag->value) album_gain_db = avtag->value; if ((avtag = av_dict_get(dict, "REPLAYGAIN_ALBUM_PEAK", NULL, AV_DICT_IGNORE_SUFFIX)) && avtag->value) album_peak = avtag->value; if ((avtag = av_dict_get(dict, "REPLAYGAIN_TRACK_GAIN", NULL, AV_DICT_IGNORE_SUFFIX)) && avtag->value) track_gain_db = avtag->value; if ((avtag = av_dict_get(dict, "REPLAYGAIN_TRACK_PEAK", NULL, AV_DICT_IGNORE_SUFFIX)) && avtag->value) track_peak = avtag->value; if (album_gain_db.isEmpty() && !track_gain_db.isEmpty()) album_gain_db = track_gain_db; if (!album_gain_db.isEmpty() && track_gain_db.isEmpty()) track_gain_db = album_gain_db; if (album_peak.isEmpty() && !track_peak.isEmpty()) album_peak = track_peak; if (!album_peak.isEmpty() && track_peak.isEmpty()) track_peak = album_peak; QString str_gain_db, str_peak; if (album) { str_gain_db = album_gain_db; str_peak = album_peak; } else { str_gain_db = track_gain_db; str_peak = track_peak; } int space_idx = str_gain_db.indexOf(' '); if (space_idx > -1) str_gain_db.remove(space_idx, str_gain_db.length() - space_idx); bool ok; float tmp = str_peak.toFloat(&ok); if (ok) peak = tmp; tmp = str_gain_db.toFloat(&ok); if (ok) gain_db = tmp; return ok; } return false; }
/** * Set the object data fields */ void I2CStats::setData(const DataFields& data) { QMutexLocker locker(mutex); // Get metadata Metadata mdata = getMetadata(); // Update object if the access mode permits if (UAVObject::GetGcsAccess(mdata) == ACCESS_READWRITE) { this->data = data; emit objectUpdatedAuto(this); // trigger object updated event emit objectUpdated(this); } }
void PlyWriter::done(PointTableRef table) { if (!ply_add_element(m_ply, "vertex", m_pointCollector->size())) { std::stringstream ss; ss << "Could not add vertex element"; throw pdal_error(ss.str()); } auto dimensions = table.layout()->dims(); for (auto dim : dimensions) { std::string name = Dimension::name(dim); e_ply_type plyType = getPlyType(Dimension::defaultType(dim)); if (!ply_add_scalar_property(m_ply, name.c_str(), plyType)) { std::stringstream ss; ss << "Could not add scalar property '" << name << "'"; throw pdal_error(ss.str()); } } if (!ply_add_comment(m_ply, "Generated by PDAL")) { std::stringstream ss; ss << "Could not add comment"; throw pdal_error(ss.str()); } if (!ply_write_header(m_ply)) { std::stringstream ss; ss << "Could not write ply header"; throw pdal_error(ss.str()); } for (PointId index = 0; index < m_pointCollector->size(); ++index) { for (auto dim : dimensions) { double value = m_pointCollector->getFieldAs<double>(dim, index); if (!ply_write(m_ply, value)) { std::stringstream ss; ss << "Error writing dimension '" << Dimension::name(dim) << "' of point number " << index; throw pdal_error(ss.str()); } } } if (!ply_close(m_ply)) throw pdal_error("Error closing ply file"); getMetadata().addList("filename", m_filename); }
bool MakerNoteWidget::decodeMetadata() { DMetadata data = getMetadata(); if (!data.hasExif()) { return false; } // Update all metadata contents. setMetadataMap(data.getExifTagsDataList(m_keysFilter, true)); return true; }
/** * Set the object data fields */ void MixerSettings::setData(const DataFields& data) { QMutexLocker locker(mutex); // Get metadata Metadata mdata = getMetadata(); // Update object if the access mode permits if ( mdata.gcsAccess == ACCESS_READWRITE ) { this->data = data; emit objectUpdatedAuto(this); // trigger object updated event emit objectUpdated(this); } }
bool AllMusic::updateMetadata(int an_id, Metadata *the_track) { if (an_id > 0) { Metadata *mdata = getMetadata(an_id); if (mdata) { *mdata = *the_track; return true; } } return false; }
void DecoderIOFactoryShoutCast::stop(void) { if (m_timer) m_timer->disconnect(); doOperationStop(); Metadata mdata(getMetadata()); mdata.setTitle("Stopped"); mdata.setArtist(""); mdata.setLength(-1); DecoderHandlerEvent ev(DecoderHandlerEvent::Meta, mdata); dispatch(ev); }
boost::property_tree::ptree Reader::serializePipeline() const { boost::property_tree::ptree tree; tree.add("<xmlattr>.type", getName()); PipelineWriter::write_option_ptree(tree, getOptions()); PipelineWriter::write_metadata_ptree(tree, getMetadata()); boost::property_tree::ptree root; root.add_child("Reader", tree); return root; }