<commit_before>/*
 *  Copyright (c) 2017, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <vector>

#include "mcrouter/lib/config/RouteHandleBuilder.h"
#include "mcrouter/lib/routes/SelectionRoute.h"
#include "mcrouter/routes/ErrorRouteFactory.h"

namespace facebook {
namespace memcache {

/**
 * Constructs a SelectionRoute for the given "RouterInfo".
 *
 * @param children                List of children route handles.
 * @param selector                Selector responsible for choosing to which
 *                                of the children the request should be sent
 *                                to.
 * @param outOfRangeDestination   The destination to which the request will be
 *                                routed if selector.select() returns a value
 *                                that is >= than children.size().
 */
template <class RouterInfo, class Selector>
typename RouterInfo::RouteHandlePtr createSelectionRoute(
    std::vector<typename RouterInfo::RouteHandlePtr> children,
    Selector selector,
    typename RouterInfo::RouteHandlePtr outOfRangeDestination = nullptr) {
  if (!outOfRangeDestination) {
    outOfRangeDestination =
        mcrouter::createErrorRoute<RouterInfo>("Invalid destination index.");
  }
  return makeRouteHandleWithInfo<RouterInfo, SelectionRoute, Selector>(
      std::move(children),
      std::move(selector),
      std::move(outOfRangeDestination));
}

} // memcache
} // facebook<commit_msg>Use ErrorRoute when an smc tier is empty<commit_after>/*
 *  Copyright (c) 2017, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <vector>

#include "mcrouter/lib/config/RouteHandleBuilder.h"
#include "mcrouter/lib/routes/SelectionRoute.h"
#include "mcrouter/routes/ErrorRouteFactory.h"

namespace facebook {
namespace memcache {

/**
 * Constructs a SelectionRoute for the given "RouterInfo".
 *
 * @param children                List of children route handles.
 * @param selector                Selector responsible for choosing to which
 *                                of the children the request should be sent
 *                                to.
 * @param outOfRangeDestination   The destination to which the request will be
 *                                routed if selector.select() returns a value
 *                                that is >= than children.size().
 */
template <class RouterInfo, class Selector>
typename RouterInfo::RouteHandlePtr createSelectionRoute(
    std::vector<typename RouterInfo::RouteHandlePtr> children,
    Selector selector,
    typename RouterInfo::RouteHandlePtr outOfRangeDestination = nullptr) {
  if (!outOfRangeDestination) {
    outOfRangeDestination =
        mcrouter::createErrorRoute<RouterInfo>("Invalid destination index.");
  }
  if (children.empty()) {
    return std::move(outOfRangeDestination);
  }
  return makeRouteHandleWithInfo<RouterInfo, SelectionRoute, Selector>(
      std::move(children),
      std::move(selector),
      std::move(outOfRangeDestination));
}

} // memcache
} // facebook
{'fraction_non_alphanumeric': 0.0844671201814059, 'fraction_numerical': 0.0022675736961451248, 'mean_word_length': 2.9167591564927857, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6798205', 'n_tokens_mistral': 914, 'n_tokens_neox': 902, 'n_words': 300}