void CaretReplyConverter::onTypedMessage(
    TypedThriftReply<cpp2::McDeleteReply>&& tres, McReply& reply) {
  if (tres->get_value()) {
    reply.setValue(std::move(tres->value));
  }
  fillResult(tres, reply);
}
void CaretReplyConverter::onTypedMessage(
    TypedThriftReply<cpp2::McMetagetReply>&& tres, McReply& reply) {

  if (!fillResult(tres, reply)) {
    return;
  }

  if (tres->__isset.age) {
    reply.setNumber(tres->age);
  }
  if (tres->__isset.exptime) {
    reply.setExptime(tres->exptime);
  }
  struct in6_addr addr;

  if (tres->__isset.ipAddress) {
    if (!tres->__isset.ipv) {
      reply.setResult(mc_res_bad_value);
      return;
    }
    int af = (tres->ipv == 6) ? AF_INET6 : AF_INET;
    auto ret = inet_pton(
        af, reinterpret_cast<const char*>(tres->ipAddress.data()), &addr);
    if (ret == 1) {
      reply.setIpAddress(addr, tres->ipv);
    }
  }
}
TypedThriftMessage<cpp2::McMetagetReply> convertToTyped(
    McReply&& reply, McOperation<mc_op_metaget>) {
  TypedThriftMessage<cpp2::McMetagetReply> tres;
  if (!fillResult(reply, tres)) {
    return tres;
  }
  tres->__isset.age = true;
  tres->age = reply.number();
  tres->__isset.exptime = true;
  tres->exptime = reply.exptime();
  tres->__isset.isTransient = true;
  if (reply.flags() == 1) {
    tres->isTransient = true;
  } else {
    tres->isTransient = false;
  }
  char ipStr[INET6_ADDRSTRLEN];

  if (reply.ipv() != 0) {
    int af = (reply.ipv() == 6) ? AF_INET6 : AF_INET;
    auto ret = inet_ntop(af,
                         reinterpret_cast<const void*>(&reply.ipAddress()),
                         ipStr,
                         INET6_ADDRSTRLEN);
    if (ret != nullptr) {
      tres->__isset.ipAddress = true;
      tres->ipAddress = ipStr;
      tres->__isset.ipv = true;
      tres->ipv = reply.ipv();
    }
  }
  return tres;
}
void QueryEvaluator::fillResultList(TNode * result_node, ResultTable * table, vector<string> * results) {
	for (int i=0; i<table->getSize(); i++) {
		vector<int> row = table->getValRow(i);
		string result = fillResult(result_node, row, table);
		results->push_back(result);
	}
}
void CaretReplyConverter::onTypedMessage(
    TypedThriftReply<cpp2::McVersionReply>&& tres, McReply& reply) {
  if (!fillResult(tres, reply)) {
    return;
  }
  if (tres->__isset.value != true) {
    reply.setResult(mc_res_bad_value);
    return;
  }
  reply.setValue(std::move(tres->value));
}
string QueryEvaluator::fillResult(TNode * result_node, vector<int> values, ResultTable * table) {
	string result = "";
	int size = result_node->getNumChildren();
	for (size_t i=0; i<size; i++) {
		TNode * node = result_node->getChildAtIndex(i);
		int value_index = table->getSymbolIndex(node->getValue());
		string str = fillResult(node, values[value_index]);
		if (i<size-1) {
			result += str + " "; 
		} else {
			result += str;
		}
	}
	return result;
}
Exemple #7
0
void
dodso(int pdu)
{
    int			sts = 0;		/* initialize to pander to gcc */
    int			length;
    pmDesc		desc;
    pmDesc		*desc_list = NULL;
    pmResult		*result;
    __pmInResult	*inresult;
    int			i;
    int			j;
    char		*buffer;
    struct timeval	start;
    struct timeval	end;
    char		name[32];
    char		**namelist;
    int			*statuslist;
    pmID		pmid;

    if (timer != 0)
        __pmtimevalNow(&start);

    switch (pdu) {

    case PDU_DESC_REQ:
        printf("PMID: %s\n", pmIDStr(param.pmid));
        if ((sts = dodso_desc(param.pmid, &desc)) >= 0)
            __pmPrintDesc(stdout, &desc);
        else
            printf("Error: DSO desc() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_FETCH:
        printf("PMID(s):");
        for (i = 0; i < param.numpmid; i++)
            printf(" %s", pmIDStr(param.pmidlist[i]));
        putchar('\n');

        if (get_desc) {
            desc_list = (pmDesc *)malloc(param.numpmid * sizeof(pmDesc));
            if (desc_list == NULL) {
                printf("Error: DSO fetch() failed: %s\n", pmErrStr(ENOMEM));
                return;
            }
            for (i = 0; i < param.numpmid; i++) {
                if ((sts = dodso_desc(param.pmidlist[i], &desc_list[i])) < 0) {
                    printf("Error: DSO desc() failed: %s\n", pmErrStr(sts));
                    free(desc_list);
                    return;
                }
            }
        }
        sts = 0;
        if (profile_changed) {
#ifdef PCP_DEBUG
            if (pmDebug & DBG_TRACE_PDU)
                fprintf(stderr, "DSO profile()\n");
#endif
            sts = dispatch.version.any.profile(profile, dispatch.version.any.ext);
            if (sts < 0)
                printf("Error: DSO profile() failed: %s\n", pmErrStr(sts));
            else
                profile_changed = 0;
        }
        if (sts >= 0) {
#ifdef PCP_DEBUG
            if (pmDebug & DBG_TRACE_PDU)
                fprintf(stderr, "DSO fetch()\n");
#endif
            sts = dispatch.version.any.fetch(param.numpmid, param.pmidlist,
                                             &result, dispatch.version.any.ext);
            if (sts >= 0) {
                if (desc_list)
                    _dbDumpResult(stdout, result, desc_list);
                else
                    __pmDumpResult(stdout, result);
                /*
                 * DSO PMDA will manage the pmResult skelton, but
                 * we need to free the pmValueSets and values here
                 */
                __pmFreeResultValues(result);
            }
            else {
                printf("Error: DSO fetch() failed: %s\n", pmErrStr(sts));
            }
        }
        if (desc_list)
            free(desc_list);
        break;

    case PDU_INSTANCE_REQ:
        printf("pmInDom: %s\n", pmInDomStr(param.indom));
#ifdef PCP_DEBUG
        if (pmDebug & DBG_TRACE_PDU)
            fprintf(stderr, "DSO instance()\n");
#endif

        sts = dispatch.version.any.instance(param.indom, param.number,
                                            param.name, &inresult,
                                            dispatch.version.any.ext);
        if (sts >= 0)
            printindom(stdout, inresult);
        else
            printf("Error: DSO instance() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_RESULT:

        printf("PMID: %s\n", pmIDStr(param.pmid));
        printf("Getting description...\n");
        desc_list = &desc;
        if ((sts = dodso_desc(param.pmid, desc_list)) < 0) {
            printf("Error: DSO desc() failed: %s\n", pmErrStr(sts));
            return;
        }

        if (profile_changed) {
            printf("Sending Profile...\n");
            sts = dispatch.version.any.profile(profile, dispatch.version.any.ext);
            if (sts < 0) {
                printf("Error: DSO profile() failed: %s\n", pmErrStr(sts));
                return;
            }
            else
                profile_changed = 0;
        }

        printf("Getting Result Structure...\n");
        sts = dispatch.version.any.fetch(1, &(desc.pmid), &result,
                                         dispatch.version.any.ext);
        if (sts < 0) {
            printf("Error: DSO fetch() failed: %s\n", pmErrStr(sts));
            return;
        }

#ifdef PCP_DEBUG
        else if (pmDebug & DBG_TRACE_FETCH)
            _dbDumpResult(stdout, result, desc_list);
#endif

        sts = fillResult(result, desc.type);
        if (sts < 0) {
            pmFreeResult(result);
            return;
        }

        sts = dispatch.version.any.store(result, dispatch.version.any.ext);
        if (sts < 0)
            printf("Error: DSO store() failed: %s\n", pmErrStr(sts));

        break;

    case PDU_TEXT_REQ:
        if (param.number == PM_TEXT_PMID) {
            printf("PMID: %s\n", pmIDStr(param.pmid));
            i = param.pmid;
        }
        else {
            printf("pmInDom: %s\n", pmInDomStr(param.indom));
            i = param.indom;
        }

        for (j = 0; j < 2; j++) {

            if (j == 0)
                param.number |= PM_TEXT_ONELINE;
            else {
                param.number &= ~PM_TEXT_ONELINE;
                param.number |= PM_TEXT_HELP;
            }

            sts = dispatch.version.any.text(i, param.number, &buffer, dispatch.version.any.ext);
            if (sts >= 0) {
                if (j == 0) {
                    if (*buffer != '\0')
                        printf("[%s]\n", buffer);
                    else
                        printf("[<no one line help text specified>]\n");
                }
                else if (*buffer != '\0')
                    printf("%s\n", buffer);
                else
                    printf("<no help text specified>\n");
            }
            else
                printf("Error: DSO text() failed: %s\n", pmErrStr(sts));
        }
        break;

    case PDU_PMNS_IDS:
        if (dispatch.comm.pmda_interface < PMDA_INTERFACE_4) {
            printf("Error: PMDA Interface %d does not support dynamic metric names\n", dispatch.comm.pmda_interface);
            break;
        }
        printf("PMID: %s\n", pmIDStr(param.pmid));
        sts = dispatch.version.four.name(param.pmid, &namelist, dispatch.version.four.ext);
        if (sts > 0) {
            for (i = 0; i < sts; i++) {
                printf("   %s\n", namelist[i]);
            }
            free(namelist);
        }
        else if (sts == 0)
            printf("Warning: DSO name() returns 0\n");
        else
            printf("Error: DSO name() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_PMNS_NAMES:
        if (dispatch.comm.pmda_interface < PMDA_INTERFACE_4) {
            printf("Error: PMDA Interface %d does not support dynamic metric names\n", dispatch.comm.pmda_interface);
            break;
        }
        printf("Metric: %s\n", param.name);
        sts = dispatch.version.four.pmid(param.name, &pmid, dispatch.version.four.ext);
        if (sts >= 0)
            printf("   %s\n", pmIDStr(pmid));
        else
            printf("Error: DSO pmid() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_PMNS_CHILD:
        if (dispatch.comm.pmda_interface < PMDA_INTERFACE_4) {
            printf("Error: PMDA Interface %d does not support dynamic metric names\n", dispatch.comm.pmda_interface);
            break;
        }
        printf("Metric: %s\n", param.name);
        sts = dispatch.version.four.children(param.name, 0, &namelist, &statuslist, dispatch.version.four.ext);
        if (sts > 0) {
            for (i = 0; i < sts; i++) {
                printf("   %8.8s %s\n", statuslist[i] == 1 ? "non-leaf" : "leaf", namelist[i]);
            }
            free(namelist);
            free(statuslist);
        }
        else if (sts == 0)
            printf("Warning: DSO children() returns 0\n");
        else
            printf("Error: DSO children() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_PMNS_TRAVERSE:
        if (dispatch.comm.pmda_interface < PMDA_INTERFACE_4) {
            printf("Error: PMDA Interface %d does not support dynamic metric names\n", dispatch.comm.pmda_interface);
            break;
        }
        printf("Metric: %s\n", param.name);
        sts = dispatch.version.four.children(param.name, 1, &namelist, &statuslist, dispatch.version.four.ext);
        if (sts > 0) {
            for (i = 0; i < sts; i++) {
                printf("   %8.8s %s\n", statuslist[i] == 1 ? "non-leaf" : "leaf", namelist[i]);
            }
            free(namelist);
            free(statuslist);
        }
        else if (sts == 0)
            printf("Warning: DSO children() returns 0\n");
        else
            printf("Error: DSO children() failed: %s\n", pmErrStr(sts));
        break;

    case PDU_AUTH:
        if (dispatch.comm.pmda_interface < PMDA_INTERFACE_6) {
            printf("Error: PMDA Interface %d does not support authentication\n", dispatch.comm.pmda_interface);
            break;
        }
        j = param.number;			/* attribute key */
        buffer = param.name;		/* attribute value */
        if (buffer)
            length = strlen(buffer) + 1;	/* length of value */
        else
            length = 0;
        i = 0;				/* client ID */

        __pmAttrKeyStr_r(j, name, sizeof(name)-1);
        name[sizeof(name)-1] = '\0';

        printf("Attribute: %s=%s\n", name, buffer ? buffer : "''");
        sts = dispatch.version.six.attribute(i, j, buffer, length, dispatch.version.six.ext);
        if (sts >= 0)
            printf("Success\n");
        else
            printf("Error: DSO attribute() failed: %s\n", pmErrStr(sts));
        break;

    default:
        printf("Error: DSO PDU (%s) botch!\n", __pmPDUTypeStr(pdu));
        break;
    }

    if (sts >= 0 && timer != 0) {
        __pmtimevalNow(&end);
        printf("Timer: %f seconds\n", __pmtimevalSub(&end, &start));
    }
}
void CaretReplyConverter::onTypedMessage(
    TypedThriftReply<cpp2::McTouchReply>&& tres, McReply& reply) {
  fillResult(tres, reply);
}
Exemple #9
0
ibis::table*
ibis::jRange::select(const ibis::table::stringArray& colnames) const {
    ibis::table *res = 0;
    if (nrows < 0) {
        int64_t ierr = count();
        if (ierr < 0) {
            LOGGER(ibis::gVerbose > 0)
                << "Warning -- jRange::count failed with error code"
                << ierr;
            return res;
        }
    }
    if (valr_ == 0 || orderr_ == 0 || vals_ == 0 || orders_ == 0 ||
        orderr_->size() != maskr_.cnt() || orders_->size() != masks_.cnt()) {
        LOGGER(ibis::gVerbose > 0)
            << "Warning -- jRange::select failed to evaluate the join";
        return res;
    }
    if (colnames.empty() || nrows == 0) {
        std::string nm = ibis::util::shortName(desc_);
        res = new ibis::tabula(nm.c_str(), desc_.c_str(), nrows);
        return res;
    }

    const uint32_t ncols = colnames.size();
    std::string evt;
    evt = "select ";
    evt += colnames[0];
    for (uint32_t j = 1; j < ncols; ++ j) {
        evt += ", ";
        evt += colnames[j];
    }
    if ((desc_[0] != 'F' && desc_[0] != 'f') ||
        (desc_[1] != 'R' && desc_[1] != 'r') ||
        (desc_[2] != 'O' && desc_[2] != 'o') ||
        (desc_[3] != 'M' && desc_[3] != 'm'))
        evt += " for ";
    else
        evt += ' ';
    evt += desc_;
    ibis::util::timer mytimer(evt.c_str());
    std::map<const char*, uint32_t, ibis::lessi> namesToPos;
    std::vector<uint32_t> ipToPos(colnames.size());
    std::vector<const ibis::column*> ircol, iscol;
    std::vector<const ibis::dictionary*> cats(colnames.size(), 0);
    // identify the names from the two data partitions
    for (uint32_t j = 0; j < ncols; ++ j) {
        ipToPos[j] = ncols+1;
        const char* cn = colnames[j];
        std::string tname;
        while (*cn != 0 && *cn != '.') {
            tname += *cn;
            ++ cn;
        }
        if (*cn == '.') {
            ++ cn;
        }
        else { // did not find '.'
            tname.erase();
            cn = colnames[j];
        }
        int match = -1; // 0 ==> partr_, 1 ==> parts_
        if (! tname.empty()) {
            match = frm_->position(tname.c_str());
            if (match >= static_cast<long>(frm_->size())) {
                if (stricmp(tname.c_str(), partr_.name()) == 0) {
                    match = 0;
                }
                else if (stricmp(tname.c_str(), parts_.name()) == 0) {
                    match = 1;
                }
            }
        }

        if (match == 0) {
            const ibis::column *col = partr_.getColumn(cn);
            if (col != 0) {
                namesToPos[colnames[j]] = j;
                ipToPos[j] = ircol.size();
                ircol.push_back(col);
                if (col->type() == ibis::CATEGORY) {
                    const ibis::category *cat =
                        static_cast<const ibis::category*>(col);
                    cats[j] = cat->getDictionary();
                }
                else if (col->type() == ibis::UINT) {
                    const ibis::bord::column *bc =
                        dynamic_cast<const ibis::bord::column*>(col);
                    if (bc != 0) {
                        cats[j] = bc->getDictionary();
                    }
                }
            }
            else {
                LOGGER(ibis::gVerbose > 0)
                    << "Warning -- " << evt << " can not find column named \""
                    << colnames[j] << "\" in data partition \"" << partr_.name()
                    << "\"";
                return res;
            }
        }
        else if (match == 1) {
            const ibis::column *col = parts_.getColumn(cn);
            if (col != 0) {
                namesToPos[colnames[j]] = j;
                ipToPos[j] = ncols - iscol.size();
                iscol.push_back(col);
                if (col->type() == ibis::CATEGORY) {
                    const ibis::category *cat =
                        static_cast<const ibis::category*>(col);
                    cats[j] = cat->getDictionary();
                }
                else if (col->type() == ibis::UINT) {
                    const ibis::bord::column *bc =
                        dynamic_cast<const ibis::bord::column*>(col);
                    if (bc != 0) {
                        cats[j] = bc->getDictionary();
                    }
                }
            }
            else {
                LOGGER(ibis::gVerbose > 0)
                    << "Warning -- " << evt << " can not find column named \""
                    << colnames[j] << "\" in data partition \""
                    << parts_.name() << "\"";
                return res;
            }
        }
        else { // not prefixed with a data partition name
            cn = colnames[j];
            const ibis::column* col = partr_.getColumn(cn);
            if (col != 0) {
                ipToPos[j] = ircol.size();
                ircol.push_back(col);
                if (col->type() == ibis::CATEGORY) {
                    const ibis::category *cat =
                        static_cast<const ibis::category*>(col);
                    cats[j] = cat->getDictionary();
                }
                else if (col->type() == ibis::UINT) {
                    const ibis::bord::column *bc =
                        dynamic_cast<const ibis::bord::column*>(col);
                    if (bc != 0) {
                        cats[j] = bc->getDictionary();
                    }
                }
                LOGGER(ibis::gVerbose > 3)
                    << evt << " encountered a column name ("
                    << colnames[j] << ") that does not start with a data "
                    "partition name, assume it is for \"" << partr_.name()
                    << "\"";
            }
            else {
                col = parts_.getColumn(cn);
                if (col != 0) {
                    ipToPos[j] = ncols - iscol.size();
                    iscol.push_back(col);
                    if (col->type() == ibis::CATEGORY) {
                        const ibis::category *cat =
                            static_cast<const ibis::category*>(col);
                        cats[j] = cat->getDictionary();
                    }
                    else if (col->type() == ibis::UINT) {
                        const ibis::bord::column *bc =
                            dynamic_cast<const ibis::bord::column*>(col);
                        if (bc != 0) {
                            cats[j] = bc->getDictionary();
                        }
                    }
                    LOGGER(ibis::gVerbose > 1)
                        << evt << " encountered a column name (" << colnames[j]
                        << ") that does not start with a data partition name, "
                        "assume it is for \"" << parts_.name() << "\"";
                }
                else {
                    LOGGER(ibis::gVerbose > 0)
                        << "Warning -- " << evt << " encountered a name ("
                        << colnames[j] << ") that does not start with a data "
                        "partition name";
                    return res;
                }
            }
        }
    } // for (uint32_t j = 0; j < ncols;

    LOGGER(ibis::gVerbose > 3)
        << evt << " -- found " << ircol.size()
        << " column" << (ircol.size() > 1 ? "s" : "") << " from "
        << partr_.name() << " and " << iscol.size() << " column"
        << (iscol.size() > 1 ? "s" : "") << " from " << parts_.name();

    // change Pos values for columns in S to have offset ircol.size()
    for (uint32_t j = 0; j < ncols; ++j) {
        if (ipToPos[j] <= ncols && ipToPos[j] >= ircol.size())
            ipToPos[j] = (ncols - ipToPos[j]) + ircol.size();
    }
    ibis::table::typeArray   rtypes(ircol.size(), ibis::UNKNOWN_TYPE);
    ibis::table::bufferArray rbuff(ircol.size(), 0);
    IBIS_BLOCK_GUARD(ibis::table::freeBuffers, ibis::util::ref(rbuff),
                     ibis::util::ref(rtypes));
    ibis::table::typeArray   stypes(iscol.size(), ibis::UNKNOWN_TYPE);
    ibis::table::bufferArray sbuff(iscol.size(), 0);
    IBIS_BLOCK_GUARD(ibis::table::freeBuffers, ibis::util::ref(sbuff),
                     ibis::util::ref(stypes));
    bool sane = true;

    // retrieve values from r_
    for (uint32_t j = 0; sane && j < ircol.size(); ++ j) {
        rtypes[j] = ircol[j]->type();
        switch (ircol[j]->type()) {
        case ibis::BYTE:
            rbuff[j] = ircol[j]->selectBytes(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<signed char>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::UBYTE:
            rbuff[j] = ircol[j]->selectUBytes(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<unsigned char>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::SHORT:
            rbuff[j] = ircol[j]->selectShorts(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int16_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::USHORT:
            rbuff[j] = ircol[j]->selectUShorts(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint16_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::INT:
            rbuff[j] = ircol[j]->selectInts(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int32_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::UINT:
            rbuff[j] = ircol[j]->selectUInts(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint32_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::LONG:
            rbuff[j] = ircol[j]->selectLongs(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int64_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::ULONG:
            rbuff[j] = ircol[j]->selectULongs(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint64_t>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::FLOAT:
            rbuff[j] = ircol[j]->selectFloats(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<float>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::DOUBLE:
            rbuff[j] = ircol[j]->selectDoubles(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<double>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        case ibis::TEXT:
        case ibis::CATEGORY:
            rbuff[j] = ircol[j]->selectStrings(maskr_);
            if (rbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<std::vector<std::string>*>(rbuff[j]),
                     *orderr_);
            else
                sane = false;
            break;
        default:
            sane = false;
            rbuff[j] = 0;
            LOGGER(ibis::gVerbose > 1)
                << "Warning -- jRange::select does not support column "
                "type " << ibis::TYPESTRING[(int)ircol[j]->type()]
                << " (name = " << partr_.name() << "." << ircol[j]->name()
                << ")";
            break;
        }
    }
    if (! sane) {
        return res;
    }

    // retrieve values from parts_
    for (uint32_t j = 0; sane && j < iscol.size(); ++ j) {
        stypes[j] = iscol[j]->type();
        switch (iscol[j]->type()) {
        case ibis::BYTE:
            sbuff[j] = iscol[j]->selectBytes(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<signed char>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::UBYTE:
            sbuff[j] = iscol[j]->selectUBytes(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<unsigned char>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::SHORT:
            sbuff[j] = iscol[j]->selectShorts(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int16_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::USHORT:
            sbuff[j] = iscol[j]->selectUShorts(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint16_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::INT:
            sbuff[j] = iscol[j]->selectInts(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int32_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::UINT:
            sbuff[j] = iscol[j]->selectUInts(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint32_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::LONG:
            sbuff[j] = iscol[j]->selectLongs(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<int64_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::ULONG:
            sbuff[j] = iscol[j]->selectULongs(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<uint64_t>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::FLOAT:
            sbuff[j] = iscol[j]->selectFloats(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<float>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::DOUBLE:
            sbuff[j] = iscol[j]->selectDoubles(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<array_t<double>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        case ibis::TEXT:
        case ibis::CATEGORY:
            sbuff[j] = iscol[j]->selectStrings(masks_);
            if (sbuff[j] != 0)
                ibis::util::reorder
                    (*static_cast<std::vector<std::string>*>(sbuff[j]),
                     *orders_);
            else
                sane = false;
            break;
        default:
            sane = false;
            sbuff[j] = 0;
            LOGGER(ibis::gVerbose > 1)
                << "Warning -- jRange::select does not support column "
                "type " << ibis::TYPESTRING[(int)iscol[j]->type()]
                << " (name = " << parts_.name() << "." << iscol[j]->name()
                << ")";
            break;
        }
    }
    if (! sane) {
        return res;
    }

    /// fill the in-memory buffer
    switch (colr_.type()) {
    case ibis::BYTE:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<signed char>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<signed char>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::UBYTE:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<unsigned char>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<unsigned char>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::SHORT:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<int16_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<int16_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::USHORT:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<uint16_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<uint16_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::INT:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<int32_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<int32_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::UINT:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<uint32_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<uint32_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::LONG:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<int64_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<int64_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::ULONG:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<uint64_t>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<uint64_t>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::FLOAT:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<float>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<float>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    case ibis::DOUBLE:
        res = fillResult
            (nrows, delta1_, delta2_, evt,
             *static_cast<array_t<double>*>(valr_), rtypes, rbuff,
             *static_cast<array_t<double>*>(vals_), stypes, sbuff,
             colnames, ipToPos);
        break;
    default:
        LOGGER(ibis::gVerbose > 0)
            << "Warning -- " << evt << " can not handle join column of type "
            << ibis::TYPESTRING[(int)colr_.type()];
    }

    for (unsigned j = 0; j < cats.size(); ++ j) {
        if (cats[j] != 0) {
            ibis::bord::column *bc = dynamic_cast<ibis::bord::column*>
                (static_cast<ibis::bord*>(res)->getColumn(j));
            if (bc != 0)
                bc->setDictionary(cats[j]);
        }
    }
    return res;
} // ibis::jRange::select
TypedThriftMessage<cpp2::McTouchReply> convertToTyped(
    McReply&& reply, McOperation<mc_op_touch>) {
  TypedThriftMessage<cpp2::McTouchReply> tres;
  fillResult(reply, tres);
  return tres;
}