/// Reassign the integer values to the strings. Upon successful completion /// of this function, the integer values assigned to the strings will be in /// ascending order. In other word, string values that are lexigraphically /// smaller will have smaller integer representations. /// /// The argument to this function carrys the permutation information needed /// to turn the previous integer assignments into the new ones. If the /// previous assignment was k, the new assignement will be o2n[k]. Note /// that the name o2n is shorthand for old-to-new. void ibis::dictionary::sort(ibis::array_t<uint32_t> &o2n) { const size_t nelm = raw_.size(); ibis::array_t<uint32_t> n2o(nelm); for (size_t j = 0; j < nelm; ++ j) n2o[j] = j; #if DEBUG+0 > 2 || _DEBUG+0 > 2 { ibis::util::logger lg; lg() << "DEBUG -- dictionary::sort starts with\n\t"; for (MYMAP::const_iterator it = key_.begin(); it != key_.end(); ++ it) lg() << '"' << it->first << '"' << "(" << it->second << ") "; } #endif ibis::util::sortStrings(raw_, n2o); o2n.resize(nelm); for (size_t j = 0; j < nelm; ++ j) o2n[n2o[j]] = j; for (MYMAP::iterator it = key_.begin(); it != key_.end(); ++ it) it->second = o2n[it->second]; #if DEBUG+0 > 2 || _DEBUG+0 > 2 { ibis::util::logger lg; lg() << "DEBUG -- dictionary::sort ends with"; for (MYMAP::const_iterator it = key_.begin(); it != key_.end(); ++ it) lg() << "\n\t\"" << it->first << '"' << "(" << it->second << ": " << raw_[it->second] << ") "; lg() << "\n\to2n(" << o2n.size() << "):"; for (size_t j = 1; j < nelm; ++ j) lg() << "\n\to2n[" << j << "] = " << o2n[j] << ": " << raw_[o2n[j]]; } #endif } // ibis::dictionary::sort
int FQ_Variable::getPointValues(ibis::array_t<E>& arr, const std::vector<uint64_t>& coords) const { if (! isValid("FQ_Variable::getPointValues")) return 0; std::string evt = "FQ_Variable::getPointValues"; if (ibis::gVerbose > 1) { std::ostringstream oss; oss << '(' << (thePart->name() ? thePart->name() : "?") << '.' << name() << ", " << ibis::TYPESTRING[(int)m_type] << ", coords[" << coords.size() << "])"; evt += oss.str(); } arr.resize(coords.size() / varInfo.getNDims()); LOGGER(ibis::gVerbose > 0) << "FQ_Variable::getPointValues the arr size is " << arr.size() ; bool ret; if (useAll) { ret = dataFile.getPointData(varInfo.getPath(), coords, static_cast<void*>(arr.begin())); } else { // convert to absolute coords based on space info. std::vector<uint64_t> absCoords; absCoords.resize(coords.size()); std::vector<uint64_t> offsets = varSpace.getOffsets(); std::vector<uint64_t> counts = varSpace.getCounts(); std::vector<uint64_t> strides = varSpace.getStrides(); unsigned int idx = 0; for (unsigned int i=0; i<arr.size(); i++) { for (unsigned int j=0; j<varInfo.getNDims(); j++) { absCoords[idx] = coords[idx]* strides[j] + offsets[j]; idx++; } } ret = dataFile.getPointData(varInfo.getPath(), absCoords, static_cast<void*>(arr.begin())); } if (ret) return arr.size(); else return -1; } // FQ_Variable::getPointValues