예제 #1
0
void ColumnCommandJL::reloadExtents()
{
	int err;
	BRM::DBRM dbrm;

	err = dbrm.getExtents(OID, extents);
	if (err) {
		ostringstream os;
		os << "pColStep: BRM lookup error. Could not get extents for OID " << OID;
		throw runtime_error(os.str());
	}

	sort(extents.begin(), extents.end(), BRM::ExtentSorter());
}
예제 #2
0
static int is_erydb_extents_fill(THD *thd, TABLE_LIST *tables, COND *cond)
{
    CHARSET_INFO *cs = system_charset_info;
    TABLE *table = tables->table;
    std::vector<struct BRM::EMEntry> entries;
   	std::vector<struct BRM::EMEntry>::iterator iter;
	std::vector<struct BRM::EMEntry>::iterator end;

    BRM::DBRM *emp = new BRM::DBRM();
    if (!emp || !emp->isDBRMReady())
    {
        return 1;
    }

    execplan::ObjectIDManager oidm;
    BRM::OID_t MaxOID = oidm.size();

    for(BRM::OID_t oid = 3000; oid <= MaxOID; oid++)
    {
        emp->getExtents(oid, entries, false, false, true);
        if (entries.size() == 0)
            continue;

        iter = entries.begin();
        end = entries.end();
        while (iter != end)
        {
            table->field[0]->store(oid);
            if (iter->colWid > 0)
            {
                table->field[1]->store("Column", strlen("Column"), cs);
                if (iter->partition.cprange.lo_val == std::numeric_limits<int64_t>::max() ||
        			iter->partition.cprange.lo_val <= (std::numeric_limits<int64_t>::min() + 2))
        		{
        		    table->field[4]->set_null();
        		}
        		else
        		{
        		    table->field[4]->set_notnull();
                    table->field[4]->store(iter->partition.cprange.lo_val);
                }
                if (iter->partition.cprange.hi_val == std::numeric_limits<int64_t>::max() ||
        			iter->partition.cprange.hi_val <= (std::numeric_limits<int64_t>::min() + 2))
        		{
        		    table->field[5]->set_null();
        		}
        		else
        		{
                    table->field[5]->set_notnull();
                    table->field[5]->store(iter->partition.cprange.hi_val);
                }
                table->field[6]->store(iter->colWid);

            }
            else
            {
                table->field[1]->store("Dictionary", strlen("Dictionary"), cs);
                table->field[4]->set_null();
                table->field[5]->set_null();
                table->field[6]->store(8192);
            }
            table->field[2]->store(iter->range.start);
            table->field[3]->store(iter->range.start + (iter->range.size * 1024) - 1);

            table->field[7]->store(iter->dbRoot);
            table->field[8]->store(iter->partitionNum);
            table->field[9]->store(iter->segmentNum);
            table->field[10]->store(iter->blockOffset);
            table->field[11]->store(iter->range.size * 1024);
            table->field[12]->store(iter->HWM);

            switch (iter->partition.cprange.isValid)
            {
                case 0:
                    table->field[13]->store("Invalid", strlen("Invalid"), cs);
                    break;
                case 1:
                    table->field[13]->store("Updating", strlen("Updating"), cs);
                    break;
                case 2:
                    table->field[13]->store("Valid", strlen("Valid"), cs);
                    break;
                default:
                    table->field[13]->store("Unknown", strlen("Unknown"), cs);
                    break;
            }
            switch (iter->status)
            {
                case BRM::EXTENTAVAILABLE:
                    table->field[14]->store("Available", strlen("Available"), cs);
                    break;
                case BRM::EXTENTUNAVAILABLE:
                    table->field[14]->store("Unavailable", strlen("Unavailable"), cs);
                    break;
                case BRM::EXTENTOUTOFSERVICE:
                    table->field[14]->store("Out of service", strlen("Out of service"), cs);
                    break;
                default:
                    table->field[14]->store("Unknown", strlen("Unknown"), cs);
            }
            // MCOL-454: special case, sometimes blockOffset can be > 0 and HWM can be 0
            if (iter->HWM == 0)
            {
                table->field[15]->store(8192);
            }
            else
            {
                table->field[15]->store((iter->HWM - iter->blockOffset + 1) * 8192);
            }

            if (schema_table_store_record(thd, table))
            {
                delete emp;
                return 1;
            }

            iter++;

        }
    }

    delete emp;
    return 0;
}