LsnType MRecords::writeRemoveLog(Session *session, LogType logType, TrxId txnId, LsnType preLsn, RowId rid, RowId rollBackId, u8 tableIndex) { LsnType lsn = 0; MemoryContext *ctx = session->getMemoryContext(); McSavepoint msp(ctx); size_t size = sizeof(txnId) + sizeof(preLsn) + sizeof(rid) + sizeof(rollBackId) + sizeof(tableIndex); byte *buf = (byte *)ctx->alloc(size); Stream s(buf, size); s.write(txnId); s.write(preLsn); s.writeRid(rid); s.writeRid(rollBackId); s.write(tableIndex); lsn = session->getTrans()->writeTNTLog(logType, (*m_tableDef)->m_id, buf, s.getSize()); return lsn; }
TEST(Varint, Interface) { // Make sure decodeVarint() accepts all of StringPiece, MutableStringPiece, // ByteRange, and MutableByteRange. char c = 0; StringPiece sp(&c, 1); EXPECT_EQ(decodeVarint(sp), 0); MutableStringPiece msp(&c, 1); EXPECT_EQ(decodeVarint(msp), 0); ByteRange br(reinterpret_cast<unsigned char*>(&c), 1); EXPECT_EQ(decodeVarint(br), 0); MutableByteRange mbr(reinterpret_cast<unsigned char*>(&c), 1); EXPECT_EQ(decodeVarint(mbr), 0); }
LsnType MRecords::writeUpdateLog(Session *session, LogType logType, TrxId txnId, LsnType preLsn, RowId rid, RowId rollBackId, u8 tableIndex, SubRecord *update) { LsnType lsn = 0; MemoryContext *ctx = session->getMemoryContext(); McSavepoint msp(ctx); size_t size = sizeof(txnId) + sizeof(preLsn) + sizeof(rid) + sizeof(rollBackId) + sizeof(tableIndex); size += RecordOper::getSubRecordSerializeSize(*m_tableDef, update, false); byte *buf = (byte *)ctx->alloc(size); Stream s(buf, size); s.write(txnId); s.write(preLsn); s.writeRid(rid); s.writeRid(rollBackId); s.write(tableIndex); RecordOper::serializeSubRecordMNR(&s, *m_tableDef, update, false); lsn = session->getTrans()->writeTNTLog(logType, (*m_tableDef)->m_id, buf, s.getSize()); return lsn; }
bool GISServer::LoadMapSet(QString mapSetFile) { qDebug() << "*** Loading Mapset *** " + mapSetFile; int j, k, p; QFile xml(mapSetFile); GIS::MapSetParser msp(&xml); GIS::MapsetData d = msp.GetData(); this->maxX = d.mapSize.maxX; this->minX = d.mapSize.minX; this->maxY = d.mapSize.maxY; this->minY = d.mapSize.minY; // check that if the mapset already loaded QString schemaName = this->tempSchemaName; bool exists = false; if(db->CheckExistenceOfSchema(schemaName)) { exists = true; qDebug() << schemaName << ' ' << "exists in database"; // delete schema or ... } else { db->CreateSchemas(schemaName, db->userName); } //create shapefile tables for(j = 0; j < (int)d.shapefiles.size(); j++) { ShapefileData *s = &d.shapefiles[j]; db->MakeShapeFileTable(s->address, schemaName, s->type, "Geom", exists); for(k = 0; k < (int)s->columns.size(); k++) { ColumnData *c = &s->columns[k]; if(c->source != c->target && !db->MDL_RenameColumn(schemaName, s->type, c->source, c->target)) qDebug() << "Error in renaming column " + c->source; for(p = 0; p < (int)c->mappings.size(); p++) { MappingData *mapping = &c->mappings[p]; if(!db->Update(schemaName, s->type, QStringList() << c->target <<"\'" + mapping->to + "\'", "gType = \'" + mapping->from + "\'" )) qDebug() << "Error in Updating column " + c->source; } } QString queryStr = "insert into \"" + this->mapsetSchemaName + "\".\"" + s->type + "\"(id, gtype, geom) select id, gtype, geom from \"" + this->tempSchemaName + "\".\"" + s->type + "\";"; bool res; db->QQuery(queryStr, &res); if(!res) qDebug() << "Error in importing shapefile"; } for(j = 0; j < (int)d.rasterfiels.size(); j++) { RasterfileData *r = &d.rasterfiels[j]; QString idStr; QTextStream ts(&idStr); ts << r->id; db->Insert(this->mapsetSchemaName, "raster", QStringList() << "id" << idStr << "rasterfile" << "\'"+r->address+"\'"); } qDebug() << "Mapset List Loading complete"; return true; }