Пример #1
0
PropertyComponent *CtrlrIDManager::createComponentForProperty (const Identifier &propertyName, const ValueTree &propertyElement, CtrlrPanel *panel, StringArray *possibleChoices,  StringArray *possibleValues)
{
    ValueTree identifierDefinition = ctrlrIdTree.getChildWithProperty (Ids::name, propertyName.toString());

    StringArray choices;
    Array <var> values;

    if (possibleChoices != nullptr)
        choices = *possibleChoices;
    else
        choices = getChoicesArray(identifierDefinition);

    if (possibleValues != nullptr)
        values = toValueList(*possibleValues);
    else
        values = toValueList(getValuesArray(identifierDefinition));

    return (new CtrlrPropertyComponent (propertyName, propertyElement, identifierDefinition, panel, &choices, &values));
}
Пример #2
0
template <typename T> ibis::array_t<T>*
FQ_Variable::selectData(const ibis::bitvector& mask,
			ibis::array_t<T>* array) const {
    if (! isValid("FQ_Variable::selectData")) return 0;

    ibis::array_t<T> prop;
    uint32_t i = 0;
    uint32_t tot = mask.cnt();
    ibis::horometer timer;
    if (ibis::gVerbose > 3) {
        LOGGER(ibis::gVerbose > 4)
            << "FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
            << "." << name() << "]::selectData starting timer..";
        timer.start();
    }
#ifdef DEBUG
    LOGGER(1) << "Debug -- reading " << name() << ", mask.cnt() = " << tot
              << ", mask.size() = " << mask.size()
              << ", mask.bytes() = " << mask.bytes()
              << ", mask.size()*8/pagesize = "
              << mask.size()*8/ibis::fileManager::pageSize()
              << ", read all = "
              << (mask.bytes()/240 > mask.size()/ibis::fileManager::pageSize() ?
                  "yes" : "no");
#endif
    if (mask.size() == mask.cnt()) {
        getValuesArray(array);
        i = array->size();
        LOGGER(ibis::gVerbose > 1)
            << "FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
            << "." << name() << "]::selectData using getValuesArray to retrieve "
            << i;
    }
    else if (mask.size() < 1048576 || tot+tot > mask.size() ||
             mask.bytes()/240 > mask.size()/ibis::fileManager::pageSize()) {
        // read all values than extract the ones marked with 1 in mask
        getValuesArray(&prop); // retrieving all values of this variable
        array->resize(tot);
        if (tot > prop.size()) tot = prop.size();
        const uint32_t nprop = prop.size();
        ibis::bitvector::indexSet index = mask.firstIndexSet();
        if (nprop >= mask.size()) {
            while (index.nIndices() > 0) {
                const ibis::bitvector::word_t *idx0 = index.indices();
                if (index.isRange()) {
                    for (uint32_t j = *idx0; j<idx0[1]; ++j, ++i) {
                        (*array)[i] = (prop[j]);
                    }
                }
                else {
                    for (uint32_t j = 0; j<index.nIndices(); ++j, ++i) {
                        (*array)[i] = (prop[idx0[j]]);
                    }
                }
                ++ index;
            }
        }
        else {
            while (index.nIndices() > 0) {
                const ibis::bitvector::word_t *idx0 = index.indices();
                if (*idx0 >= nprop) break;
                if (index.isRange()) {
                    for (uint32_t j = *idx0;
                         j<(idx0[1]<=nprop ? idx0[1] : nprop);
                         ++j, ++i) {
                        (*array)[i] = (prop[j]);
                    }
                }
                else {
                    for (uint32_t j = 0; j<index.nIndices(); ++j, ++i) {
                        if (idx0[j] < nprop)
                            (*array)[i] = (prop[idx0[j]]);
                        else
                            break;
                    }
                }
                ++ index;
            }
        }
        LOGGER(ibis::gVerbose > 1)
            << "FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
            << "." << name()
            << "]::select using getValuesArray and extracted "
            << i;
    }
    else {
        // generate the coordinates and extract their values
        std::vector<uint64_t> coord;
        coord.reserve(tot);
        for (ibis::bitvector::indexSet ix = mask.firstIndexSet();
             ix.nIndices() > 0; ++ ix) {
            const ibis::bitvector::word_t *ind = ix.indices();
            if (ix.isRange()) {
                for (unsigned int j = ind[0]; j < ind[1]; ++ j)
                    coord.push_back(static_cast<int32_t>(j));
            }
            else {
                for (unsigned int j = 0; j < ix.nIndices(); ++j)
                    coord.push_back(static_cast<int32_t>(ind[j]));
            }
        }
	uint64_t nElements = coord.size()/varInfo.getNDims();
        array->resize(nElements);
        i = getPointValues(*array, coord);
        LOGGER(ibis::gVerbose > 1)
            << "FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
            << "." << name() << "]::select using getPointValues. i = "
            << i;
    }
    if (i != tot) {
        array->resize(i);
        logWarning("select", "expects to retrieve %lu elements "
                   "but only got %lu", static_cast<long unsigned>(tot),
                   static_cast<long unsigned>(i));
    }
    else if (ibis::gVerbose > 3) {
        timer.stop();
        LOGGER(ibis::gVerbose >= 0)
            << "FQ_Variable[" << (thePart->name() ? thePart->name() : "?")
            << "." << name() << "]::select extracted " << tot << " value"
            << (tot > 1 ? "s" : "") << " out of " << mask.size() << " took "
            << timer.CPUTime() << " sec (CPU) and " << timer.realTime()
            << " sec (elapsed) time";
    }
    return array;
} // FQ_Variable::selectDoubles
Пример #3
0
int FQ_Variable::searchSorted(const ibis::qDiscreteRange& rng,
			      ibis::bitvector& hits) const {
    if (! isValid("FQ_Variable::searchSorted")) return 0;

    int ierr;
    LOGGER(ibis::gVerbose >= 5)
        << "... entering FQ_Variable::searchSorted to resolve " << rng;
    switch (m_type) {
    case ibis::BYTE: {
        ibis::array_t<signed char> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
	/*
	  case ibis::UBYTE: {
	  ibis::array_t<unsigned char> vals;
	  ierr = getValuesArray(&vals);
	  if (ierr >= 0) {
	  ierr = ibis::column::searchSortedICD(vals, rng, hits);
	  }
	  break;}
	  case ibis::SHORT: {
	  ibis::array_t<int16_t> vals;
	  ierr = getValuesArray(&vals);
	  if (ierr >= 0) {
	  ierr = ibis::column::searchSortedICD(vals, rng, hits);
	  }
	  break;}
	  case ibis::USHORT: {
	  ibis::array_t<uint16_t> vals;
	  ierr = getValuesArray(&vals);
	  if (ierr >= 0) {
	  ierr = ibis::column::searchSortedICD(vals, rng, hits);
	  }
	  break;}
	*/
    case ibis::FLOAT: {
        ibis::array_t<float> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    case ibis::DOUBLE: {
        ibis::array_t<double> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    case ibis::INT: {
        ibis::array_t<int32_t> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    case ibis::UINT: {
        ibis::array_t<uint32_t> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    case ibis::LONG: {
        ibis::array_t<int64_t> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    case ibis::ULONG: {
        ibis::array_t<uint64_t> vals;
        ierr = getValuesArray(&vals);
        if (ierr >= 0) {
            ierr = ibis::column::searchSortedICD(vals, rng, hits);
        }
        break;}
    default: {
        LOGGER(ibis::gVerbose > 0)
            << "Warning -- FQ_Variable["
            << (thePart ? thePart->name() : "?") << '.'
            << m_name << "]::searchSorted(" << rng.colName() << " IN ...) "
            << "does not yet support column type "
            << ibis::TYPESTRING[(int)m_type];
        ierr = -5;
        break;}
    } // switch (m_type)
    return (ierr < 0 ? ierr : 0);
} // FQ_Variable::searchSorted