/*@brief search index catalog object from all cached database objects * @param index_name * @return index catalog object; if not found return null */ std::shared_ptr<IndexCatalogObject> DatabaseCatalogObject::GetCachedIndexObject( const std::string &index_name, const std::string &schema_name) { for (auto it = table_objects_cache.begin(); it != table_objects_cache.end(); ++it) { auto table_object = it->second; if (table_object != nullptr && table_object->GetSchemaName() == schema_name) { auto index_object = table_object->GetIndexObject(index_name, true); if (index_object) return index_object; } } return nullptr; }
/* @brief evict table catalog object from cache * @param table_oid * @return true if table_oid is found and evicted; false if not found */ bool DatabaseCatalogObject::EvictTableObject(oid_t table_oid) { // find table name from table name cache auto it = table_objects_cache.find(table_oid); if (it == table_objects_cache.end()) { return false; // table oid not found in cache } auto table_object = it->second; PELOTON_ASSERT(table_object); table_objects_cache.erase(it); // erase from table name cache std::string key = table_object->GetSchemaName() + "." + table_object->GetTableName(); table_name_cache.erase(key); return true; }
///////////////////////////////////////////////////////////////// // HRESULT CSession::GetSchemaRowset // ///////////////////////////////////////////////////////////////// HRESULT CSession::GetSchemaRowset(CAggregate* pCAggregate, REFGUID guidSchema, ULONG cRestrictions, VARIANT* rgRestrictions, REFIID riid, ULONG cPropSets, DBPROPSET* rgPropSets, IUnknown** ppIUnknown) { HRESULT hr = S_OK; if(!m_pIDBSchemaRowset) return E_FAIL; //Schema Rowset WCHAR wszBuffer[MAX_NAME_LEN+1]; WCHAR* pwszSchemaName = GetSchemaName(guidSchema); //Try to find the String Resprentation of the guidSchema if(pwszSchemaName == NULL) { StringFromGUID2(guidSchema, wszBuffer, MAX_NAME_LEN); pwszSchemaName = wszBuffer; } //GetSchema Rowset XTEST_(hr = m_pIDBSchemaRowset->GetRowset( pCAggregate, // punkOuter guidSchema, // schema IID cRestrictions, // # of restrictions rgRestrictions, // array of restrictions riid, // rowset interface cPropSets, // # of properties rgPropSets, // properties ppIUnknown),S_OK); // rowset pointer TRACE_METHOD(hr, L"IDBSchemaRowset::GetRowset(0x%p, %s, %d, 0x%p, %s, %d, 0x%p, &0x%p)", pCAggregate, pwszSchemaName, cRestrictions, rgRestrictions, GetInterfaceName(riid), cPropSets, rgPropSets, ppIUnknown ? *ppIUnknown : NULL); //Display Errors (if occurred) TESTC(hr = DisplayPropErrors(hr, cPropSets, rgPropSets)); //Handle Aggregation if(pCAggregate) TESTC(hr = pCAggregate->HandleAggregation(riid, ppIUnknown)); CLEANUP: return hr; }
void FdoXmlElementMapping::_writeXml( FdoXmlWriter* xmlWriter, const FdoXmlFlags* flags ) { xmlWriter->WriteStartElement( L"element" ); FdoPhysicalElementMapping::_writeXml( xmlWriter, flags ); // Encode names to handle characters not allowed in XML names. FdoStringP classSchema = flags->GetNameAdjust() ? ((FdoString*) xmlWriter->EncodeName(GetSchemaName())) : GetSchemaName(); xmlWriter->WriteAttribute( L"classSchema", classSchema ); // Encode names to handle characters not allowed in XML names. FdoStringP className = flags->GetNameAdjust() ? ((FdoString*) xmlWriter->EncodeName(GetClassName())) : GetClassName(); // TODO: centralize // Complex Type name is class name with "Type" suffix appended. if ( className.GetLength() > 0 ) { className += "Type"; } xmlWriter->WriteAttribute( L"className", className ); if ( mGmlUri != L"" ) { xmlWriter->WriteAttribute( L"gmlUri", mGmlUri ); } if ( mGmlLocalName != L"" ) { xmlWriter->WriteAttribute( L"gmlLocalName", mGmlLocalName ); } xmlWriter->WriteEndElement(); }