Changeset 19155 for trunk


Ignore:
Timestamp:
08/12/18 15:48:05 (6 years ago)
Author:
tbretz
Message:
Added the --index option.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fits2sql.cc

    r19154 r19155  
    6868        ("conditional",    po_switch(),               "Conditional insert. Only insert if no entry exists yet with the constants defined by --const")
    6969        ("delete",         po_switch(),               "Delete all entries first which fit all constant columns defined by --const")
     70        ("index",          po_switch(),               "If a table is created, all const columns are used as a single index")
    7071        ;
    7172
     
    197198        "If any row with the given constant values are found, the execution is stopped "
    198199        "(note that this happend after the table drop/create but before the delete/insert.\n"
     200        "\n"
     201        "To ensure efficient access for a conditonal execution, it makes sense to have "
     202        "an index created for those columns. This can be done during table creation "
     203        "with the --index option.\n"
    199204        "\n"
    200205        "If a query failed, the query is printed to stderr together with the error message. "
     
    324329    const bool conditional       = conf.Get<bool>("conditional");
    325330    const bool run_delete        = conf.Get<bool>("delete");
     331    const bool index             = conf.Get<bool>("index");
    326332
    327333    const string engine          = conf.Get<string>("engine");
     
    412418
    413419    string where;
     420    vector<string> vindex;
    414421    for (auto it=fixed.cbegin(); it!=fixed.cend(); it++)
    415422    {
     
    450457        vec.emplace_back(name, val);
    451458        where += " AND `"+name+"`="+val;
     459        vindex.emplace_back(name);
    452460    }
    453461
     
    581589        query += ",\n   PRIMARY KEY USING BTREE (`"+boost::algorithm::join(primary, "`, `")+"`)";
    582590
     591    if (!vindex.empty() && index)
     592        query += ",\n   INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
     593
    583594    query +=
    584595        "\n)\n"
  • trunk/FACT++/src/root2sql.cc

    r19154 r19155  
    7171        ("conditional",    po_switch(),               "Conditional insert. Only insert if no entry exists yet with the constants defined by --const")
    7272        ("delete",         po_switch(),               "Delete all entries first which fit all constant columns defined by --const")
     73        ("index",          po_switch(),               "If a table is created, all const columns are used as a single index")
    7374        ;
    7475
     
    205206        "(note that this happend after the table drop/create but before the delete/insert.\n"
    206207        "\n"
     208        "To ensure efficient access for a conditonal execution, it makes sense to have "
     209        "an index created for those columns. This can be done during table creation "
     210        "with the --index option.\n"
     211        "\n"
    207212        "If a query failed, the query is printed to stderr together with the error message. "
    208213        "For the main INSERT query, this is only true if the verbosity level is at least 2 "
     
    319324    if (string(msg).substr(0,24)=="no dictionary for class ")
    320325        return;
     326    if (string(msg).substr(0, 5)=="unknown branch ")
     327        return;
    321328
    322329    DefaultErrorHandler(level, abort, location, msg);
     
    353360    const bool conditional       = conf.Get<bool>("conditional");
    354361    const bool run_delete        = conf.Get<bool>("delete");
     362    const bool index             = conf.Get<bool>("index");
    355363
    356364    const string engine          = conf.Get<string>("engine");
     
    435443
    436444    string where;
     445    vector<string> vindex;
    437446    for (auto it=fixed.cbegin(); it!=fixed.cend(); it++)
    438447    {
     
    473482        vec.emplace_back(name, val);
    474483        where += " AND `"+name+"`="+val;
     484        vindex.emplace_back(name);
    475485    }
    476486
     
    615625    if (!primary.empty())
    616626        query += ",\n   PRIMARY KEY USING BTREE (`"+boost::algorithm::join(primary, "`, `")+"`)";
     627
     628    if (!vindex.empty() && index)
     629        query += ",\n   INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
    617630
    618631    query +=
Note: See TracChangeset for help on using the changeset viewer.