FieldSet TableInfo::genFieldSet(UINT index, const FieldSet &fields) const {
  const IndexDefinition &indexDef = m_indexArray[index];
  FieldSet keyFieldSet;
  for(size_t i = 0; i < fields.size(); i++) {
    int j = indexDef.getFieldIndex(fields[i]);
    if(j < 0) {
      throwSqlError(SQL_FATAL_ERROR,_T("Column %d is not member of index %s in table %s\n")
                                   ,fields[i],indexDef.m_indexName.cstr(),m_fileName.cstr());
    }
    keyFieldSet.add(j);
  }
  return keyFieldSet;
}
Exemplo n.º 2
0
// static
void ProjectionStage::transformSimpleInclusion(const BSONObj& in,
                                               const FieldSet& includedFields,
                                               BSONObjBuilder& bob) {
    // Look at every field in the source document and see if we're including it.
    BSONObjIterator inputIt(in);
    while (inputIt.more()) {
        BSONElement elt = inputIt.next();
        auto fieldIt = includedFields.find(elt.fieldNameStringData());
        if (includedFields.end() != fieldIt) {
            // If so, add it to the builder.
            bob.append(elt);
        }
    }
}
Exemplo n.º 3
0
bool DBOperation::verify_fields(const dclass::Class *dclass, const FieldSet& fields)
{
    bool valid = true;
    for(auto it = fields.begin(); it != fields.end(); ++it) {
        const dclass::Field *field = *it;
        if(!dclass->get_field_by_id(field->get_id())) {
            m_dbserver->m_log->warning() << "Field " << field->get_name()
                                         << " does not belong to object " << m_doid
                                         << "(" << dclass->get_name() << ")\n";
            valid = false;
        }
    }
    return valid;
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{
  if (argc != 2)
    return -1;

  int n = std::atoi(argv[1]);

  std::cout << n << " queens" << std::endl;
  Field field(n);
  FieldSet result;
  depth_first(field, result);

  std::cout << "found " << result.size() << " solutions." << std::endl;

  return 0;
}
Exemplo n.º 5
0
void depth_first(const Field & field, FieldSet & result)
{
  //std::cout << "descending: " << field.queens.size() << "/" << field.n << std::endl;
  if (field.queens.size() == field.n)
    result.insert(field);

  for (int x = 0; x < field.n; ++x)
  {
    if (field.x[x])
      continue;
    for (int y = 0; y < field.n; ++y)
    {
      if (field.is_free(x, y))
      {
        Field variation = field.with_queen_at(x, y);
        depth_first(variation, result);
      }
    }
  }
}