Package com.dianping.cat.config

Examples of com.dianping.cat.config.TrieTreeNode$TrieTreeKey


      tree.addFormat("", format);
      return;
    }
    boolean isPrefix = true;
    int sIndex = 0, eIndex = 0;
    TrieTreeNode sCurrent = tree, eCurrent = tree;
    if (prefix.length != 0) {
      for (int i = 0; i < prefix.length; i++) {
        TrieTreeNode node = sCurrent.getChildNode(prefix[i], true);
        if (node == null) {
          node = new TrieTreeNode();
          sCurrent.addTreeNode(prefix[i], true, node);
          sIndex++;
        }
        sCurrent = node;
      }
    }
    if (suffix.length != 0) {
      for (int i = suffix.length - 1; i >= 0; i--) {
        TrieTreeNode node = eCurrent.getChildNode(suffix[i], false);
        if (node == null) {
          node = new TrieTreeNode();
          eCurrent.addTreeNode(suffix[i], false, node);
          eIndex++;
        }
        eCurrent = node;
      }
View Full Code Here


   */
  private String parse(TrieTreeNode formatTree, String input) {
    char[] cs = input.toCharArray();
    List<Map<String, AggregationMessageFormat>> sformatSet = new ArrayList<Map<String, AggregationMessageFormat>>();
    List<Map<String, AggregationMessageFormat>> eformatSet = new ArrayList<Map<String, AggregationMessageFormat>>();
    TrieTreeNode current = formatTree;
    int i = 0;

    for (; i < cs.length; i++) {
      sformatSet.add(current.getFormatMap());
      TrieTreeNode node = current.getChildNode(cs[i], true);
      if (node == null) {
        i--;
        break;
      }
      current = node;
    }

    current = formatTree;
    int j = cs.length - 1;
    for (; j > 0; j--) {
      eformatSet.add(current.getFormatMap());
      TrieTreeNode node = current.getChildNode(cs[j], false);
      if (node == null) {
        j++;
        break;
      }
      current = node;
View Full Code Here

  @Override
  public void register(Collection<PatternItem> rules) {
    m_logger.info("register url pattern start");

    TrieTreeNode formats = new TrieTreeNode();
    Set<String> orignals = new HashSet<String>();
    Map<String, String> urlToId = new HashMap<String, String>();

    for (PatternItem item : rules) {
      String format = item.getPattern();
View Full Code Here

      tree.addFormat("", format);
      return;
    }
    boolean isPrefix = true;
    int sIndex = 0, eIndex = 0;
    TrieTreeNode sCurrent = tree, eCurrent = tree;
    if (prefix.length != 0) {
      for (int i = 0; i < prefix.length; i++) {
        TrieTreeNode node = sCurrent.getChildNode(prefix[i], true);
        if (node == null) {
          node = new TrieTreeNode();
          sCurrent.addTreeNode(prefix[i], true, node);
          sIndex++;
        }
        sCurrent = node;
      }
    }
    if (suffix.length != 0) {
      for (int i = suffix.length - 1; i >= 0; i--) {
        TrieTreeNode node = eCurrent.getChildNode(suffix[i], false);
        if (node == null) {
          node = new TrieTreeNode();
          eCurrent.addTreeNode(suffix[i], false, node);
          eIndex++;
        }
        eCurrent = node;
      }
View Full Code Here

    m_logger = logger;
  }

  private TrieTreeNode findOrCreateTrieTreeNode(int type, String domain) {
    Map<String, TrieTreeNode> nodes = findOrCreateTrieTreeNodes(type);
    TrieTreeNode node = nodes.get(domain);

    if (node == null) {
      node = new TrieTreeNode();
      nodes.put(domain, node);
    }
    return node;
  }
View Full Code Here

    return domainToFormatMap.get(domain);
  }

  @Override
  public String handle(int type, String domain, String input) {
    TrieTreeNode formatTree = getFormatTree(type, domain);

    if (formatTree == null) {
      return input;
    }
    return parse(formatTree, input);
View Full Code Here

   */
  private String parse(TrieTreeNode formatTree, String input) {
    char[] cs = input.toCharArray();
    List<Map<String, AggregationMessageFormat>> sformatSet = new ArrayList<Map<String, AggregationMessageFormat>>();
    List<Map<String, AggregationMessageFormat>> eformatSet = new ArrayList<Map<String, AggregationMessageFormat>>();
    TrieTreeNode current = formatTree;
    int i = 0;

    for (; i < cs.length; i++) {
      sformatSet.add(current.getFormatMap());
      TrieTreeNode node = current.getChildNode(cs[i], true);
      if (node == null) {
        i--;
        break;
      }
      current = node;
    }

    current = formatTree;
    int j = cs.length - 1;
    for (; j > 0; j--) {
      eformatSet.add(current.getFormatMap());
      TrieTreeNode node = current.getChildNode(cs[j], false);
      if (node == null) {
        j++;
        break;
      }
      current = node;
View Full Code Here

      String key1 = format.substring(0, index1);
      String key2 = format.substring(index2 + 1);
      AggregationMessageFormat value = new AggregationMessageFormat(format);

      if (rule.getDomain() != null) {
        TrieTreeNode node = findOrCreateTrieTreeNode(rule.getType(), rule.getDomain());

        buildFormatTree(node, key1.toCharArray(), key2.toCharArray(), value);
      }
    }
View Full Code Here

TOP

Related Classes of com.dianping.cat.config.TrieTreeNode$TrieTreeKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.