zoukankan      html  css  js  c++  java
  • Hbase put写入源码分析

    今天有空闲时间看一下HBASE的写入代码

    MutiAction类,是一个action的container,包括get . put. delete。并且是根据region name分组的。其中核心的就是add方法,根据传进来的region name将action分组

    public final class MultiAction<R> {
      // TODO: This class should not be visible outside of the client package.
    
      // map of regions to lists of puts/gets/deletes for that region.
      public Map<byte[], List<Action<R>>> actions =
        new TreeMap<byte[], List<Action<R>>>(Bytes.BYTES_COMPARATOR);
    
      private long nonceGroup = HConstants.NO_NONCE;
    
      public MultiAction() {
        super();
      }
    
      /**
       * Get the total number of Actions
       *
       * @return total number of Actions for all groups in this container.
       */
      public int size() {
        int size = 0;
        for (List<?> l : actions.values()) {
          size += l.size();
        }
        return size;
      }
    
      /**
       * Add an Action to this container based on it's regionName. If the regionName
       * is wrong, the initial execution will fail, but will be automatically
       * retried after looking up the correct region.
       *
       * @param regionName
       * @param a
       */
      public void add(byte[] regionName, Action<R> a) {
        add(regionName, Arrays.asList(a));
      }
    
      /**
       * Add an Action to this container based on it's regionName. If the regionName
       * is wrong, the initial execution will fail, but will be automatically
       * retried after looking up the correct region.
       *
       * @param regionName
       * @param actionList list of actions to add for the region
       */
      public void add(byte[] regionName, List<Action<R>> actionList){
        List<Action<R>> rsActions = actions.get(regionName);
        if (rsActions == null) {
          rsActions = new ArrayList<Action<R>>(actionList.size());
          actions.put(regionName, rsActions);
        }
        rsActions.addAll(actionList);
      }
    
      public void setNonceGroup(long nonceGroup) {
        this.nonceGroup = nonceGroup;
      }
    
      public Set<byte[]> getRegions() {
        return actions.keySet();
      }
    
      public boolean hasNonceGroup() {
        return nonceGroup != HConstants.NO_NONCE;
      }
    
      public long getNonceGroup() {
        return this.nonceGroup;
      }
    }  

    接下来介绍AyncProcess类,该类

    待续

  • 相关阅读:
    UML/ROSE学习笔记系列二:UML的概念模型
    UML/ROSE学习笔记系列五:用况对过程的描述
    UML/ROSE学习笔记系列四:图
    SQLSERVER2005 的作业调度(非原创)
    ORACLE 和SQLSERVER 两表之间批量更新数据对比
    彻底领悟javascript中的exec与match方法(非原创)
    对象,对象集合的简单Xml序列化与反序列化(非原创)
    JIT是库存管理的发展趋势
    UML/ROSE学习笔记系列一:建模原理、概念
    C# 多线程与异步操作实现的探讨(非原创)
  • 原文地址:https://www.cnblogs.com/Evil-Rebe/p/11684045.html
Copyright © 2011-2022 走看看