Beispiel #1
0
file::generate_result file::generate()
{
    ////////////////////////////////////////////////////////////////
    // buffer
    int track_byte_count = libtraits::packer_size(*this);
    std::shared_ptr<char> midi_output = std::shared_ptr<char>(new char[track_byte_count], std::default_delete<char[]>());
    
    ////////////////////////////////////////////////////////////////
    // fill
    char* ptr = midi_output.get();
    typedef __gnu_cxx::__normal_iterator<char*, C> iterator_type;
    iterator_type it(ptr);

    libtraits::traits::generator<file>::generate(it, *this);

    return generate_result(midi_output, track_byte_count);
}
static int is_columnstore_files_fill(THD* thd, TABLE_LIST* tables, COND* cond)
{
    BRM::DBRM* emp = new BRM::DBRM();
    BRM::OID_t cond_oid = 0;
    TABLE* table = tables->table;

    if (!emp || !emp->isDBRMReady())
    {
        return 1;
    }

    if (cond && cond->type() == Item::FUNC_ITEM)
    {
        Item_func* fitem = (Item_func*) cond;

        if ((fitem->functype() == Item_func::EQ_FUNC) && (fitem->argument_count() == 2))
        {
            if (fitem->arguments()[0]->real_item()->type() == Item::FIELD_ITEM &&
                    fitem->arguments()[1]->const_item())
            {
                // WHERE object_id = value
                Item_field* item_field = (Item_field*) fitem->arguments()[0]->real_item();

                if (strcasecmp(item_field->field_name.str, "object_id") == 0)
                {
                    cond_oid = fitem->arguments()[1]->val_int();
                    return generate_result(cond_oid, emp, table, thd);
                }
            }
            else if (fitem->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
                     fitem->arguments()[0]->const_item())
            {
                // WHERE value = object_id
                Item_field* item_field = (Item_field*) fitem->arguments()[1]->real_item();

                if (strcasecmp(item_field->field_name.str, "object_id") == 0)
                {
                    cond_oid = fitem->arguments()[0]->val_int();
                    return generate_result(cond_oid, emp, table, thd);
                }
            }
        }
        else if (fitem->functype() == Item_func::IN_FUNC)
        {
            // WHERE object_id in (value1, value2)
            Item_field* item_field = (Item_field*) fitem->arguments()[0]->real_item();

            if (strcasecmp(item_field->field_name.str, "object_id") == 0)
            {
                for (unsigned int i = 1; i < fitem->argument_count(); i++)
                {
                    cond_oid = fitem->arguments()[i]->val_int();
                    int result = generate_result(cond_oid, emp, table, thd);

                    if (result)
                        return 1;
                }
            }
        }
        else if (fitem->functype() == Item_func::UNKNOWN_FUNC &&
                 strcasecmp(fitem->func_name(), "find_in_set") == 0)
        {
            // WHERE FIND_IN_SET(object_id, values)
            String* tmp_var = fitem->arguments()[1]->val_str();
            std::stringstream ss(tmp_var->ptr());

            while (ss >> cond_oid)
            {
                int ret = generate_result(cond_oid, emp, table, thd);

                if (ret)
                    return 1;

                if (ss.peek() == ',')
                    ss.ignore();
            }
        }