本文整理汇总了C++中Table类的典型用法代码示例。如果您正苦于以下问题:C++ Table类的具体用法?C++ Table怎么用?C++ Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: readXML
bool readXML(map<string, Table>& tables) {
TiXmlDocument *myDoc = new TiXmlDocument("information.xml");
if (!myDoc->LoadFile()) {
cout << myDoc->ErrorDesc() << endl;
return false;
} else
myDoc->LoadFile();
TiXmlElement* root = myDoc->RootElement();
//the first layer loop
for (TiXmlNode* firstNode = root->FirstChild(); firstNode;
firstNode = firstNode->NextSibling()) {
Table tmpTable;
if (strcmp(firstNode->Value(), "class") == 0) {
//the second layer loop
for (TiXmlNode *secondNode = firstNode->FirstChild();
secondNode; secondNode = secondNode->NextSibling()) {
if (strcmp(secondNode->Value(), "class_name") == 0) {
tmpTable.setTableName(secondNode->FirstChild()->Value());
} else if (strcmp(secondNode->Value(), "attribute") == 0) {
Attribute tmpAttribute;
for (TiXmlNode *thirdNode = secondNode->FirstChild();
thirdNode; thirdNode = thirdNode->NextSibling()) {
if (strcmp(thirdNode->Value(), "attribute_name") == 0) {
if (thirdNode->FirstChild() != 0)
tmpAttribute.name = thirdNode->FirstChild()->Value();
string name = tmpTable.getTableName();
string newName = name.substr(0,2) + '_';
newName += tmpAttribute.name;
tmpAttribute.name = newName;
} else if (strcmp(thirdNode->Value(), "identifier") == 0) {
if (thirdNode->FirstChild() != 0) {
tmpAttribute.id = thirdNode->FirstChild()->Value();
}
} else if (strcmp(thirdNode->Value(), "multiplicity") == 0) {
if (thirdNode->FirstChild() != 0)
tmpAttribute.multiplicity = thirdNode->FirstChild()->Value();
}
}
tmpTable.setAttribute(tmpAttribute);
}
}
tables.insert(make_pair(tmpTable.getTableName(), tmpTable));
} else if (strcmp(firstNode->Value(), "association") == 0) {
Association tmpAssociation;
for (TiXmlNode *secondNode = firstNode->FirstChild();
secondNode; secondNode = secondNode->NextSibling()) {
if (strcmp(secondNode->Value(), "nameOfAssociation") == 0) {
if (secondNode->FirstChild() != 0)
tmpAssociation.nameOfAssociation = secondNode->FirstChild()->Value();
} else if (strcmp(secondNode->Value(), "class") == 0) {
Association_class tableValue;
for (TiXmlNode *thirdNode = secondNode->FirstChild();
thirdNode; thirdNode = thirdNode->NextSibling()) {
if (strcmp(thirdNode->Value(), "class_name") == 0) {
if (thirdNode->FirstChild() != 0)
tableValue.name = thirdNode->FirstChild()->Value();
} else if (strcmp(thirdNode->Value(), "multiplicity") == 0) {
if (thirdNode->FirstChild() != 0)
tableValue.multiplicity = thirdNode->FirstChild()->Value();
} else if (strcmp(thirdNode->Value(), "role") == 0) {
if (thirdNode->FirstChild() != 0)
tableValue.role = thirdNode->FirstChild()->Value();
} else {
if (thirdNode->FirstChild() != 0)
tableValue.qualification.push_back(thirdNode->
FirstChild()->Value());
}
}
tmpAssociation.startTable = tableValue;
} else if (strcmp(secondNode->Value(), "other_class") == 0) {
Association_class tableValue;
for (TiXmlNode *thirdNode = secondNode->FirstChild();
thirdNode; thirdNode = thirdNode->NextSibling()) {
if (strcmp(thirdNode->Value(), "class_name") == 0) {
tableValue.name = thirdNode->FirstChild()->Value();
} else if (strcmp(thirdNode->Value(), "multiplicity") == 0) {
if (thirdNode->FirstChild() != 0)
tableValue.multiplicity = thirdNode->FirstChild()->Value();
} else if (strcmp(thirdNode->Value(), "role") == 0) {
if (thirdNode->FirstChild() != 0)
tableValue.role = thirdNode->FirstChild()->Value();
} else {
if (thirdNode->FirstChild() != 0)
tableValue.qualification.push_back(thirdNode->
FirstChild()->Value());
}
}
tmpAssociation.anotherTable = tableValue;
} else if (strcmp(secondNode->Value(), "Link") == 0) {
Linker tmpLink;
TiXmlNode* thirdNode = secondNode->FirstChild();
for (; thirdNode; thirdNode = thirdNode->NextSibling()) {
if (strcmp(thirdNode->Value(), "link_attribute") == 0
&& thirdNode->FirstChild() != 0) {
TiXmlNode* forthNode = thirdNode->FirstChild();
//.........这里部分代码省略.........
开发者ID:vitawebsitedesign,项目名称:321,代码行数:101,代码来源:main.cpp
示例2: translate
void translate(Table& envT, Table& userT)
{
enum QueueType { UNKNOWN = -1, SLURM = 1, SGE, SLURM_TACC, PBS, LSF };
QueueType queueType = UNKNOWN;
// Pick type of queuing system.
if (envT.count("SGE_ACCOUNT"))
queueType = SGE;
else if (envT.count("SLURM_TACC_ACCOUNT") || envT.count("SLURM_TACC_JOBNAME"))
queueType = SLURM_TACC;
else if (envT.count("SBATCH_ACCOUNT"))
queueType = SLURM;
else if (envT.count("PBS_JOBID"))
queueType = PBS;
else if (envT.count("LSF_VERSION"))
queueType = LSF;
// Now fill in num_cores, num_nodes, account, job_id, queue, submit_host in userT from the environment
if (queueType == SGE)
{
userT["num_cores"] = safe_get(userT, "num_tasks", "1");
userT["num_nodes"] = safe_get(envT, "NHOSTS", "1");
userT["account"] = safe_get(envT, "SGE_ACCOUNT", "unknown");
userT["job_id"] = safe_get(envT, "JOB_ID", "unknown");
userT["queue"] = safe_get(envT, "QUEUE", "unknown");
userT["submit_host"] = "unknown";
}
else if (queueType == SLURM_TACC || queueType == SLURM )
{
userT["num_cores"] = safe_get(userT, "num_tasks", "1");
userT["num_nodes"] = safe_get(envT, "SLURM_NNODES", "1");
userT["job_id"] = safe_get(envT, "SLURM_JOB_ID", "unknown");
userT["queue"] = safe_get(envT, "SLURM_QUEUE", "unknown");
userT["submit_host"] = safe_get(envT, "SLURM_SUBMIT_HOST", "unknown");
if (queueType == SLURM_TACC)
userT["account"] = safe_get(envT, "SLURM_TACC_ACCOUNT", "unknown");
}
else if (queueType == PBS)
{
userT["num_cores"] = safe_get(userT, "num_tasks", "1");
userT["num_nodes"] = safe_get(envT, "PBS_NUM_NODES", "1");
userT["job_id"] = safe_get(envT, "PBS_JOBID", "unknown");
userT["queue"] = safe_get(envT, "PBS_QUEUE", "unknown");
userT["submit_host"] = safe_get(envT, "PBS_O_HOST", "unknown");
userT["account"] = safe_get(envT, "PBS_ACCOUNT", "unknown");
}
else if (queueType == LSF)
{
// We must count the number of "words" in mcpuA.
// We find the number of words by counting space blocks and add 1;
// then divide by 2. then convert to a string.
std::string mcpuA = safe_get(envT, "LSB_MCPU_HOSTS", "a 1");
std::string::size_type idx;
int count = 1;
idx = 0;
while (1)
{
idx = mcpuA.find(" ",idx);
if (idx == std::string::npos)
break;
count++;
idx = mcpuA.find_first_not_of(" ",idx+1);
}
count /= 2;
std::ostringstream sstream;
sstream << count;
userT["num_cores"] = safe_get(userT, "num_tasks", "1");
userT["num_nodes"] = sstream.str();
userT["job_id"] = safe_get(envT, "LSB_JOBID", "unknown");
userT["queue"] = safe_get(envT, "LSB_QUEUE", "unknown");
userT["submit_host"] = safe_get(envT, "LSB_EXEC_CLUSTER", "unknown");
userT["account"] = "unknown";
}
else
{
userT["num_cores"] = "1";
userT["num_nodes"] = "1";
userT["job_id"] = "unknown";
userT["queue"] = "unknown";
userT["submit_host"] = "unknown";
userT["account"] = "unknown";
}
}
开发者ID:treydock,项目名称:xalt,代码行数:87,代码来源:translate.C
示例3: print_system_meminfo
void print_system_meminfo()
{
// We can't use sysinfo() here because iit doesn't tell us how much cached
// memory we're using. (On B2G, this is often upwards of 30mb.)
//
// Instead, we have to parse /proc/meminfo.
FILE* meminfo = fopen("/proc/meminfo", "r");
if (!meminfo) {
perror("Couldn't open /proc/meminfo");
return;
}
// These are all in kb.
int total = -1;
int free = -1;
int buffers = -1;
int cached = -1;
int swap_total = -1;
int swap_free = -1;
int swap_cached = -1;
char line[256];
while(fgets(line, sizeof(line), meminfo)) {
int val;
if (sscanf(line, "MemTotal: %d kB", &val) == 1) {
total = val;
} else if (sscanf(line, "MemFree: %d kB", &val) == 1) {
free = val;
} else if (sscanf(line, "Buffers: %d kB", &val) == 1) {
buffers = val;
} else if (sscanf(line, "Cached: %d kB", &val) == 1) {
cached = val;
} else if (sscanf(line, "SwapTotal: %d kB", &val) == 1) {
swap_total = val;
} else if (sscanf(line, "SwapFree: %d kB", &val) == 1) {
swap_free = val;
} else if (sscanf(line, "SwapCached: %d kB", &val) == 1) {
swap_cached = val;
}
}
fclose(meminfo);
if (total == -1 || free == -1 || buffers == -1 || cached == -1 ||
swap_total == -1 || swap_free == -1 || swap_cached == -1) {
fprintf(stderr, "Unable to parse /proc/meminfo.\n");
return;
}
int actually_used = total - free - buffers - cached - swap_cached;
puts("System memory info:\n");
Table t;
t.start_row();
t.add("Total");
t.add_fmt("%0.1f MB", kb_to_mb(total));
t.start_row();
t.add("SwapTotal");
t.add_fmt("%0.1f MB", kb_to_mb(swap_total));
t.start_row();
t.add("Used - cache");
t.add_fmt("%0.1f MB", kb_to_mb(total - free - buffers - cached - swap_cached));
t.start_row();
t.add("B2G procs (PSS)");
int b2g_mem_kb = 0;
for (vector<Process*>::const_iterator it = ProcessList::singleton().b2g_processes().begin();
it != ProcessList::singleton().b2g_processes().end(); ++it) {
b2g_mem_kb += (*it)->pss_kb();
}
t.add_fmt("%0.1f MB", b2g_mem_kb / 1024.0);
t.start_row();
t.add("Non-B2G procs");
t.add_fmt("%0.1f MB", kb_to_mb(total - free - buffers - cached - b2g_mem_kb - swap_cached));
t.start_row();
t.add("Free + cache");
t.add_fmt("%0.1f MB", kb_to_mb(free + buffers + cached + swap_cached));
t.start_row();
t.add("Free");
t.add_fmt("%0.1f MB", kb_to_mb(free));
t.start_row();
t.add("Cache");
t.add_fmt("%0.1f MB", kb_to_mb(buffers + cached + swap_cached));
t.start_row();
t.add("SwapFree");
t.add_fmt("%0.1f MB", kb_to_mb(swap_free));
t.print_with_indent(2);
}
开发者ID:EricRahm,项目名称:gonk-misc,代码行数:100,代码来源:b2g-info.cpp
示例4: iMin
void MeshAlg::weldBoundaryEdges(
Array<Face>& faceArray,
Array<Edge>& edgeArray,
Array<Vertex>& vertexArray) {
// Copy over the original edge array
Array<Edge> oldEdgeArray = edgeArray;
// newEdgeIndex[e] is the new index of the old edge with index e
// Note that newEdgeIndex[e] might be negative, indicating that
// the edge switched direction between the arrays.
Array<int> newEdgeIndex;
newEdgeIndex.resize(edgeArray.size());
edgeArray.resize(0);
// boundaryEdgeIndices[v_low] is an array of the indices of
// all boundary edges whose lower vertex is v_low.
Table<int, Array<int> > boundaryEdgeIndices;
// Copy over non-boundary edges to the new array
for (int e = 0; e < oldEdgeArray.size(); ++e) {
if (oldEdgeArray[e].boundary()) {
// Add to the boundary table
const int v_low = iMin(oldEdgeArray[e].vertexIndex[0], oldEdgeArray[e].vertexIndex[1]);
if (! boundaryEdgeIndices.containsKey(v_low)) {
boundaryEdgeIndices.set(v_low, Array<int>());
}
boundaryEdgeIndices[v_low].append(e);
// We'll fill out newEdgeIndex[e] later, when we find pairs
} else {
// Copy the edge to the new array
newEdgeIndex[e] = edgeArray.size();
edgeArray.append(oldEdgeArray[e]);
}
}
// Remove all edges from the table that have pairs.
Table<int, Array<int> >::Iterator cur = boundaryEdgeIndices.begin();
Table<int, Array<int> >::Iterator end = boundaryEdgeIndices.end();
while (cur != end) {
Array<int>& boundaryEdge = cur->value;
for (int i = 0; i < boundaryEdge.size(); ++i) {
int ei = boundaryEdge[i];
const Edge& edgei = oldEdgeArray[ei];
for (int j = i + 1; j < boundaryEdge.size(); ++j) {
int ej = boundaryEdge[j];
const Edge& edgej = oldEdgeArray[ej];
// See if edge ei is the reverse (match) of edge ej.
// True if the edges match
bool match = false;
// True if edgej's vertex indices are reversed from
// edgei's (usually true).
bool reversej = false;
int u = edgei.vertexIndex[0];
int v = edgei.vertexIndex[1];
if (edgei.faceIndex[0] != Face::NONE) {
// verts|faces
// edgei = [u v A /]
if (edgej.faceIndex[0] != Face::NONE) {
if ((edgej.vertexIndex[0] == v) && (edgej.vertexIndex[1] == u)) {
// This is the most common of the four cases
// edgej = [v u B /]
match = true;
reversej = true;
}
} else {
if ((edgej.vertexIndex[0] == u) && (edgej.vertexIndex[1] == v)) {
// edgej = [u v / B]
match = true;
}
}
} else {
// edgei = [u v / A]
if (edgej.faceIndex[0] != Face::NONE) {
if ((edgej.vertexIndex[0] == u) && (edgej.vertexIndex[1] == v)) {
// edgej = [u v B /]
match = true;
}
} else {
if ((edgej.vertexIndex[0] == v) && (edgej.vertexIndex[1] == u)) {
// edgej = [v u / B]
match = true;
reversej = true;
}
}
//.........这里部分代码省略.........
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:101,代码来源:MeshAlgAdjacency.cpp
示例5: Table
Table( const Table& t){ //Copy constructor
for(int i=0; i< t.size(); i++){
Data.push_back(t.getRow(i));
}
recalc();
}
开发者ID:adunofaiur,项目名称:sportsdatabase,代码行数:6,代码来源:Table.cpp
示例6: deserialize
void MaskSprite::deserialize(const Table& table)
{
Sprite::deserialize(table);
setAlphaMask( table.getFloat("alphaMask", getAlphaMask()) );
}
开发者ID:Gabriele91,项目名称:Easy2D,代码行数:5,代码来源:Mask.cpp
示例7: hero
void TestTable::parseSQL()
{
QString sSQL = "create TABLE hero (\n"
"\tid integer PRIMARY KEY AUTOINCREMENT,\n"
"\tname text NOT NULL DEFAULT 'xxxx',\n"
"\tinfo VARCHAR(255) CHECK (info == 'x')\n"
");";
Table tab = Table::parseSQL(sSQL).first;
QVERIFY(tab.name() == "hero");
QVERIFY(tab.rowidColumn() == "_rowid_");
QVERIFY(tab.fields().at(0)->name() == "id");
QVERIFY(tab.fields().at(1)->name() == "name");
QVERIFY(tab.fields().at(2)->name() == "info");
QVERIFY(tab.fields().at(0)->type() == "integer");
QVERIFY(tab.fields().at(1)->type() == "text");
QCOMPARE(tab.fields().at(2)->type(), QString("VARCHAR ( 255 )"));
FieldVector pk = tab.primaryKey();
QVERIFY(tab.fields().at(0)->autoIncrement());
QVERIFY(pk.size() == 1 && pk.at(0) == tab.fields().at(0));
QVERIFY(tab.fields().at(1)->notnull());
QCOMPARE(tab.fields().at(1)->defaultValue(), QString("'xxxx'"));
QCOMPARE(tab.fields().at(1)->check(), QString(""));
QCOMPARE(tab.fields().at(2)->check(), QString("info == 'x'"));
}
开发者ID:AndrewADev,项目名称:sqlitebrowser,代码行数:28,代码来源:testsqlobjects.cpp
示例8: chtest
void TestTable::parseSQLdefaultexpr()
{
QString sSQL = "CREATE TABLE chtest(\n"
"id integer primary key,\n"
"dumpytext text default('axa') CHECK(dumpytext == \"aa\"),\n"
"date datetime default CURRENT_TIMESTAMP,"
"zoi integer)";
Table tab = Table::parseSQL(sSQL).first;
QCOMPARE(tab.name(), QString("chtest"));
QCOMPARE(tab.fields().at(0)->name(), QString("id"));
QCOMPARE(tab.fields().at(1)->name(), QString("dumpytext"));
QCOMPARE(tab.fields().at(2)->name(), QString("date"));
QCOMPARE(tab.fields().at(3)->name(), QString("zoi"));
QCOMPARE(tab.fields().at(0)->type(), QString("integer"));
QCOMPARE(tab.fields().at(1)->type(), QString("text"));
QCOMPARE(tab.fields().at(2)->type(), QString("datetime"));
QCOMPARE(tab.fields().at(3)->type(), QString("integer"));
QCOMPARE(tab.fields().at(1)->defaultValue(), QString("('axa')"));
QCOMPARE(tab.fields().at(1)->check(), QString("dumpytext == \"aa\""));
QCOMPARE(tab.fields().at(2)->defaultValue(), QString("CURRENT_TIMESTAMP"));
QCOMPARE(tab.fields().at(2)->check(), QString(""));
QCOMPARE(tab.fields().at(3)->defaultValue(), QString(""));
QCOMPARE(tab.fields().at(3)->check(), QString(""));
sqlb::FieldVector pk = tab.primaryKey();
QVERIFY(pk.size() == 1 && pk.at(0) == tab.fields().at(0));
}
开发者ID:AndrewADev,项目名称:sqlitebrowser,代码行数:31,代码来源:testsqlobjects.cpp
示例9: Exception
void Table::addObject(BaseObject *obj, int obj_idx)
{
ObjectType obj_type;
if(!obj)
throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);
else
{
int idx;
obj_type=obj->getObjectType();
#ifdef DEMO_VERSION
#warning "DEMO VERSION: table children objects creation limit."
vector<TableObject *> *obj_list=(obj_type!=OBJ_TABLE ? getObjectList(obj_type) : nullptr);
if((obj_list && obj_list->size() >= GlobalAttributes::MAX_OBJECT_COUNT) ||
(obj_type==OBJ_TABLE && ancestor_tables.size() >= GlobalAttributes::MAX_OBJECT_COUNT))
throw Exception(trUtf8("In demonstration version tables can have only `%1' instances of each child object type or ancestor tables! You've reach this limit for the type: `%2'")
.arg(GlobalAttributes::MAX_OBJECT_COUNT)
.arg(BaseObject::getTypeName(obj_type)),
ERR_CUSTOM,__PRETTY_FUNCTION__,__FILE__,__LINE__);
#endif
try
{
//Raises an error if already exists a object with the same name and type
if(getObject(obj->getName(),obj_type,idx))
{
throw Exception(QString(Exception::getErrorMessage(ERR_ASG_DUPLIC_OBJECT))
.arg(obj->getName(true))
.arg(obj->getTypeName())
.arg(this->getName(true))
.arg(this->getTypeName()),
ERR_ASG_DUPLIC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);
}
//Raises an error if the user try to set the table as ancestor/copy of itself
else if((obj_type==OBJ_TABLE || obj_type==BASE_TABLE) && obj==this)
throw Exception(ERR_INV_INH_COPY_RELATIONSHIP,__PRETTY_FUNCTION__,__FILE__,__LINE__);
switch(obj_type)
{
case OBJ_COLUMN:
case OBJ_CONSTRAINT:
case OBJ_TRIGGER:
case OBJ_INDEX:
case OBJ_RULE:
TableObject *tab_obj;
vector<TableObject *> *obj_list;
Column *col;
tab_obj=dynamic_cast<TableObject *>(obj);
col=dynamic_cast<Column *>(tab_obj);
//Sets the object parent table if there isn't one
if(!tab_obj->getParentTable())
tab_obj->setParentTable(this);
//Raises an error if the parent table of the table object is different from table 'this'
else if(tab_obj->getParentTable()!=this)
throw Exception(ERR_ASG_OBJ_BELONGS_OTHER_TABLE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
//Validates the object SQL code befor insert on table
obj->getCodeDefinition(SchemaParser::SQL_DEFINITION);
if(col && col->getType()==this)
{
throw Exception(Exception::getErrorMessage(ERR_INV_COLUMN_TABLE_TYPE)
.arg(col->getName())
.arg(this->getName()),
ERR_INV_COLUMN_TABLE_TYPE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
}
else if(obj_type==OBJ_CONSTRAINT)
{
//Raises a error if the user try to add a second primary key on the table
if(dynamic_cast<Constraint *>(tab_obj)->getConstraintType()==ConstraintType::primary_key &&
this->getPrimaryKey())
throw Exception(ERR_ASG_EXISTING_PK_TABLE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
}
else if(obj_type==OBJ_TRIGGER)
dynamic_cast<Trigger *>(tab_obj)->validateTrigger();
obj_list=getObjectList(obj_type);
//Adds the object to the table
if(obj_idx < 0 || obj_idx >= static_cast<int>(obj_list->size()))
obj_list->push_back(tab_obj);
else
{
//If there is a object index specified inserts the object at the position
if(obj_list->size() > 0)
obj_list->insert((obj_list->begin() + obj_idx), tab_obj);
else
obj_list->push_back(tab_obj);
}
if(obj_type==OBJ_COLUMN || obj_type==OBJ_CONSTRAINT)
{
updateAlterCmdsStatus();
//.........这里部分代码省略.........
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:101,代码来源:table.cpp
示例10: bucket_count
typename Table::size_type bucket_count () const {return table.size();}
开发者ID:alekseyd,项目名称:task2,代码行数:1,代码来源:jethro_cache.hpp
示例11: VOLT_TRACE
bool InsertExecutor::p_init(AbstractPlanNode* abstractNode,
const ExecutorVector& executorVector)
{
VOLT_TRACE("init Insert Executor");
m_node = dynamic_cast<InsertPlanNode*>(abstractNode);
assert(m_node);
assert(m_node->getTargetTable());
assert(m_node->getInputTableCount() == (m_node->isInline() ? 0 : 1));
Table* targetTable = m_node->getTargetTable();
m_isUpsert = m_node->isUpsert();
//
// The insert node's input schema is fixed. But
// if this is an inline node we don't set it here.
// We let the parent node set it in p_execute_init.
//
// Also, we don't want to set the input table for inline
// insert nodes.
//
if ( ! m_node->isInline()) {
setDMLCountOutputTable(executorVector.limits());
m_inputTable = dynamic_cast<AbstractTempTable*>(m_node->getInputTable()); //input table should be temptable
assert(m_inputTable);
} else {
m_inputTable = NULL;
}
// Target table can be StreamedTable or PersistentTable and must not be NULL
PersistentTable *persistentTarget = dynamic_cast<PersistentTable*>(targetTable);
m_partitionColumn = -1;
StreamedTable *streamTarget = dynamic_cast<StreamedTable*>(targetTable);
m_hasStreamView = false;
if (streamTarget != NULL) {
m_isStreamed = true;
//See if we have any views.
m_hasStreamView = streamTarget->hasViews();
m_partitionColumn = streamTarget->partitionColumn();
}
if (m_isUpsert) {
VOLT_TRACE("init Upsert Executor actually");
assert( ! m_node->isInline() );
if (m_isStreamed) {
VOLT_ERROR("UPSERT is not supported for Stream table %s", targetTable->name().c_str());
}
// look up the tuple whether it exists already
if (persistentTarget->primaryKeyIndex() == NULL) {
VOLT_ERROR("No primary keys were found in our target table '%s'",
targetTable->name().c_str());
}
}
if (persistentTarget) {
m_partitionColumn = persistentTarget->partitionColumn();
}
m_multiPartition = m_node->isMultiPartition();
m_sourceIsPartitioned = m_node->sourceIsPartitioned();
// allocate memory for template tuple, set defaults for all columns
m_templateTupleStorage.init(targetTable->schema());
TableTuple tuple = m_templateTupleStorage.tuple();
std::set<int> fieldsExplicitlySet(m_node->getFieldMap().begin(), m_node->getFieldMap().end());
// These default values are used for an INSERT including the INSERT sub-case of an UPSERT.
// The defaults are purposely ignored in favor of existing column values
// for the UPDATE subcase of an UPSERT.
m_node->initTupleWithDefaultValues(m_engine,
&m_memoryPool,
fieldsExplicitlySet,
tuple,
m_nowFields);
m_hasPurgeFragment = persistentTarget ? persistentTarget->hasPurgeFragment() : false;
return true;
}
开发者ID:akhanzode,项目名称:voltdb,代码行数:80,代码来源:insertexecutor.cpp
示例12: initialAppDataDir
std::string System::findDataFile
(const std::string& full,
bool errorIfNotFound) {
// Places where specific files were most recently found. This is
// used to cache seeking of common files.
static Table<std::string, std::string> lastFound;
// First check if the file exists as requested. This will go
// through the FileSystemCache, so most calls do not touch disk.
if (fileExists(full)) {
return full;
}
// Now check where we previously found this file.
std::string* last = lastFound.getPointer(full);
if (last != NULL) {
if (fileExists(*last)) {
// Even if cwd has changed the file is still present.
// We won't notice if it has been deleted, however.
return *last;
} else {
// Remove this from the cache it is invalid
lastFound.remove(full);
}
}
// Places to look
static Array<std::string> directoryArray;
if (directoryArray.size() == 0) {
// Initialize the directory array
RealTime t0 = System::time();
Array<std::string> baseDirArray;
std::string initialAppDataDir(instance().m_appDataDir);
baseDirArray.append("");
if (! initialAppDataDir.empty()) {
baseDirArray.append(initialAppDataDir);
}
const char* g3dPath = getenv("G3DDATA");
if (g3dPath && (initialAppDataDir != g3dPath)) {
baseDirArray.append(g3dPath);
}
static const std::string subdirs[] =
{"font", "gui", "SuperShader", "cubemap", "icon", "material", "image", "md2", "md3", "ifs", "3ds", "sky", ""};
for (int j = 0; j < baseDirArray.size(); ++j) {
std::string d = baseDirArray[j];
if (fileExists(d)) {
directoryArray.append(d);
for (int i = 0; ! subdirs[i].empty(); ++i) {
const std::string& p = pathConcat(d, subdirs[i]);
if (fileExists(p)) {
directoryArray.append(p);
}
}
}
}
logLazyPrintf("Initializing System::findDataFile took %fs\n", System::time() - t0);
}
for (int i = 0; i < directoryArray.size(); ++i) {
const std::string& p = pathConcat(directoryArray[i], full);
if (fileExists(p)) {
lastFound.set(full, p);
return p;
}
}
if (errorIfNotFound) {
// Generate an error message
std::string locations;
for (int i = 0; i < directoryArray.size(); ++i) {
locations += pathConcat(directoryArray[i], full) + "\n";
}
alwaysAssertM(false, "Could not find '" + full + "' in:\n" + locations);
}
// Not found
return "";
}
开发者ID:AtVirus,项目名称:Descent-core,代码行数:87,代码来源:System.cpp
示例13: main
int main()
{
Connection conn;
DbRetVal rv = conn.open("root", "manager");
if (rv != OK)
{
printf("Error during connection %d\n", rv);
return 1;
}
DatabaseManager *dbMgr = conn.getDatabaseManager();
if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}
TableDef tabDef;
tabDef.addField("f1", typeInt, 0, NULL, true);
tabDef.addField("f2", typeString, 196);
rv = dbMgr->createTable("t1", tabDef);
if (rv != OK) { printf("Table creation failed\n"); return 3; }
printf("Table created\n");
#ifdef WITHINDEX
HashIndexInitInfo *idxInfo = new HashIndexInitInfo();
strcpy(idxInfo->tableName, "t1");
idxInfo->list.append("f1");
idxInfo->indType = hashIndex;
idxInfo->isUnique = true;
idxInfo->isPrimary = true;
rv = dbMgr->createIndex("indx1", idxInfo);
if (rv != OK) { printf("Index creation failed\n"); return -1; }
printf("Index created\n");
delete idxInfo;
#endif
#ifdef WITHTREEINDEX
HashIndexInitInfo *idxInfo = new HashIndexInitInfo();
strcpy(idxInfo->tableName, "t1");
idxInfo->list.append("f1");
idxInfo->indType = treeIndex;
rv = dbMgr->createIndex("indx1", idxInfo);
if (rv != OK) { printf("Index creation failed\n"); return -1; }
printf("Index created\n");
delete idxInfo;
#endif
#ifdef WITHTRIEINDEX
HashIndexInitInfo *idxInfo = new HashIndexInitInfo();
strcpy(idxInfo->tableName, "t1");
idxInfo->list.append("f1");
idxInfo->indType = trieIndex;
rv = dbMgr->createIndex("indx1", idxInfo);
if (rv != OK) { printf("Index creation failed\n"); return -1; }
printf("Index created\n");
delete idxInfo;
#endif
Table *table = dbMgr->openTable("t1");
if (table == NULL) { printf("Unable to open table\n"); return 4; }
table->bindFld("f1", &id);
table->bindFld("f2", name);
char *tuple;
int ret;
int i;
rv =conn.startTransaction();
for(i = 0; i< 5; i++)
{
if (rv != OK) exit(5);
id= i;
strcpy(name, "PRABAKARAN0123456750590");
ret = table->insertTuple();
if (ret != 0) break;
}
conn.commit();
conn.startTransaction();
select(table, OpEquals);
conn.commit();
conn.startTransaction();
select(table, OpNotEquals);
conn.commit();
conn.startTransaction();
select(table, OpLessThan);
conn.commit();
conn.startTransaction();
select( table, OpLessThanEquals);
conn.commit();
conn.startTransaction();
select( table, OpGreaterThan);
conn.commit();
conn.startTransaction();
select( table, OpGreaterThanEquals);
conn.commit();
dbMgr->closeTable(table);
dbMgr->dropTable("t1");
conn.close();
return 0;
}
开发者ID:mattibickel,项目名称:csql,代码行数:99,代码来源:inttest.c
示例14: assert_field_type
void assert_field_type(Table &td, int field_index,
ActiveRecord::Type::Type type) {
ASSERT_EQ(type, td.fields()[field_index].type());
}
开发者ID:wqx081,项目名称:cpp-active-record,代码行数:4,代码来源:test_helper.cpp
示例15: tr
void LineProfileTool::calculateLineProfile(const QPoint& start, const QPoint& end)
{
QRect rect = d_target->rect();
if (!rect.contains(start) || !rect.contains(end)){
QMessageBox::warning(d_graph, tr("MantidPlot - Pixel selection warning"),
tr("Please select the end line point inside the image rectangle!"));
return;
}
QPoint o = d_target->origin();
QPixmap pic = d_target->pixmap();
QImage image = pic.convertToImage();
int x1 = start.x()-o.x();
int x2 = end.x()-o.x();
int y1 = start.y()-o.y();
int y2 = end.y()-o.y();
QSize realSize = pic.size();
QSize actualSize = d_target->size();
if (realSize != actualSize){
double ratioX = (double)realSize.width()/(double)actualSize.width();
double ratioY = (double)realSize.height()/(double)actualSize.height();
x1 = static_cast<int>(x1*ratioX);
x2 = static_cast<int>(x2*ratioX);
y1 = static_cast<int>(y1*ratioY);
y2 = static_cast<int>(y2*ratioY);
}
QString text = tr("pixel") + "\tx\ty\t" + tr("intensity") + "\n";
//uses the fast Bresenham's line-drawing algorithm
#define sgn(x) ((x<0)?-1:((x>0)?1:0))
int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py,n = 0;
dx=x2-x1; //the horizontal distance of the line
dy=y2-y1; //the vertical distance of the line
dxabs=abs(dx);
dyabs=abs(dy);
sdx=sgn(dx);
sdy=sgn(dy);
x=dyabs>>1;
y=dxabs>>1;
px=x1;
py=y1;
if (dxabs>=dyabs){ //the line is more horizontal than vertical
for(i=0;i<dxabs;i++){
y+=dyabs;
if (y>=dxabs){
y-=dxabs;
py+=sdy;
}
px+=sdx;
n=dxabs;
text+=QString::number(i)+"\t";
text+=QString::number(px)+"\t";
text+=QString::number(py)+"\t";
text+=QString::number(averageImagePixel(image, px, py, true))+"\n";
}
} else {// the line is more vertical than horizontal
for(i=0;i<dyabs;i++){
x+=dxabs;
if (x>=dyabs){
x-=dyabs;
px+=sdx;
}
py+=sdy;
n=dyabs;
text+=QString::number(i)+"\t";
text+=QString::number(px)+"\t";
text+=QString::number(py)+"\t";
text+=QString::number(averageImagePixel(image, px, py, false))+"\n";
}
}
Table *t = d_app->newTable(tr("Table") + "1", n, 4, text);
MultiLayer* plot = d_app->multilayerPlot(t, QStringList(QString(t->objectName())+"_intensity"), 0);
Graph *g = dynamic_cast<Graph*>(plot->activeGraph());
if (g){
g->setTitle("");
g->setXAxisTitle(tr("pixels"));
g->setYAxisTitle(tr("pixel intensity (a.u.)"));
}
}
开发者ID:trnielsen,项目名称:mantid,代码行数:89,代码来源:LineProfileTool.cpp
示例16: serialize
void MaskSprite::serialize(Table& table)
{
Sprite::serialize(table);
table.set("alphaMask", getAlphaMask());
}
开发者ID:Gabriele91,项目名称:Easy2D,代码行数:5,代码来源:Mask.cpp
示例17: Table
/*****************************************************
**
** HoraExpert --- write
**
******************************************************/
void HoraExpert::write( Sheet *sheet, const bool isLocaltime )
{
TzUtil tzu;
wxString s;
TzFormattedDate fd;
Lang lang;
SheetFormatter fmt;
double corr = ( location->getTimeZone() + location->getDST()) / 24;
Table *table = new Table( 7, 13 );
if ( config->view->showTextViewHeaders ) table->setHeader( _( "Hora" ));
table->setHeader( 0, _( "Begin" ));
table->setHeader( 1, _( "Lord" ));
table->setHeader( 2, _( "End" ));
//table->setHeader( 3, wxEmptyString );
table->setHeader( 4, _( "Begin" ));
table->setHeader( 5, _( "Lord" ));
table->setHeader( 6, _( "End" ));
int line = 1;
int colskip = 0;
for ( int i = 0; i < 24; i++ )
{
if ( i == 12 )
{
colskip = 4;
line = 1;
}
table->setEntry( 3, line, wxEmptyString );
fd = tzu.getDateFormatted( horaStart[i] + corr, isLocaltime );
table->setEntry( colskip, line, fd.timeFormatted );
table->setEntry( 1+colskip, line, fmt.getObjectName( horaLord[i], TF_LONG ));
fd = tzu.getDateFormatted( horaStart[i+1] + corr, isLocaltime );
table->setEntry( 2+colskip, line, fd.timeFormatted );
line++;
}
sheet->addItem( table );
sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the day" ),
lang.getObjectName( getDinaLord(), TF_LONG ).c_str()));
sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the month" ),
lang.getObjectName( getMasaLord(), TF_LONG ).c_str()));
sheet->addLine( wxString::Format( wxT( "%s: %s" ), _( "Lord of the year" ),
lang.getObjectName( getVarshaLord(), TF_LONG ).c_str() ));
}
开发者ID:martin-pe,项目名称:maitreya8,代码行数:54,代码来源:Hora.cpp
示例18: assert
bool InsertExecutor::p_execute(const NValueArray ¶ms) {
assert(m_node == dynamic_cast<InsertPlanNode*>(m_abstractNode));
assert(m_node);
assert(m_inputTable == dynamic_cast<TempTable*>(m_node->getInputTable()));
assert(m_inputTable);
// Target table can be StreamedTable or PersistentTable and must not be NULL
// Update target table reference from table delegate
Table* targetTable = m_node->getTargetTable();
assert(targetTable);
assert((targetTable == dynamic_cast<PersistentTable*>(
|
请发表评论