主頁 >  其他 > 從Mybatis原始碼角度,分析一些常見技術點

從Mybatis原始碼角度,分析一些常見技術點

2020-11-05 07:59:08 其他

文章目錄

  • 懶加載
    • 簡介
    • 實作原理
  • 快取
    • 簡介
    • 快取具體實作
    • 二級快取
      • 配置二級快取
      • 二級快取實作
  • 插件
    • 簡介
    • 實作原理
      • 初始化
      • 加載
      • 呼叫
  • 流式讀取
    • 簡介
    • 實作原理
  • 標簽的id可以重復嗎
  • 總結


懶加載

簡介

Mybatis在進行關聯查詢時,可以開啟懶加載的功能,懶加載避免了一開始就去加載關聯屬性,而是在需要時再通過關聯表來查詢關聯屬性,
開啟懶加載的配置

<settings> 
   <!--開啟懶加載-->
   <setting name="lazyLoadingEnabled" value="true"/> 
   <setting name="aggressiveLazyLoading" value="false"/> 
</settings>

在resultMap標簽配置映射規則時,關聯查詢的子標簽中可以指定select和column屬性,select屬性代表延遲加載需要執行的statement的id,如果不在當前mapper檔案中,需要加上namespace,column屬性代表同select查詢關聯的欄位,

<!-- 配置延遲加載 -->
<association property="position" fetchType="lazy"  column="position_id" select="com.stu.mapper.PositionMapper.selectByPrimaryKey" />

實作原理

Mybatis對查詢的結果集進行映射處理程序中,會讀取ResultSet中的每一行記錄然后呼叫getRowValue方法進行映射

 private Object getRowValue(ResultSetWrapper rsw, ResultMap resultMap) throws SQLException {
    final ResultLoaderMap lazyLoader = new ResultLoaderMap();
    //根據resultMap的type屬性,實體化目標物件(并確認關聯屬性是否開啟懶加載,開啟則為當前物件創建代理物件)
    Object rowValue = createResultObject(rsw, resultMap, lazyLoader, null);
    if (rowValue != null && !hasTypeHandlerForResultObject(rsw, resultMap.getType())) {
      //對目標物件進行封裝得到metaObjcect,為后續的賦值操作做好準備
      final MetaObject metaObject = configuration.newMetaObject(rowValue);
      boolean foundValues = this.useConstructorMappings;//取得是否使用建構式初始化屬性值
      if (shouldApplyAutomaticMappings(resultMap, false)) {//是否使用自動映射
    	 //一般情況下 autoMappingBehavior默認值為PARTIAL,對未明確指定映射規則的欄位進行自動映射
        foundValues = applyAutomaticMappings(rsw, resultMap, metaObject, null) || foundValues;
      }
       //映射resultMap中明確指定需要映射的列
      foundValues = applyPropertyMappings(rsw, resultMap, metaObject, lazyLoader, null) || foundValues;
      ....
    }
    return rowValue;
  }

映射程序中會先呼叫createResultObject方法根據ResultMap標簽中配置的type屬性指定的目標物件的類名,然后先通過反射實體化目標物件,接下來,會遍歷ResultMap物件中的所有ResultMapping(ResultMap標簽中的每一個子標簽,都會封裝成ResultMapping)物件,判斷關聯查詢的子標簽是否開啟了懶加載

  private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
    ...
    //回傳實際的結果集物件(通過反射創建Type指定型別的物件)
    Object resultObject = createResultObject(rsw, resultMap, constructorArgTypes, constructorArgs, columnPrefix);
    if (resultObject != null && !hasTypeHandlerForResultObject(rsw, resultMap.getType())) {
      //獲得所有的ResultMapping
      final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
      for (ResultMapping propertyMapping : propertyMappings) {
    	//這里是判斷association、collection子標簽是否開啟了懶加載
        // issue gcode #109 && issue #149
    	//嵌套查詢id存在,并且開始懶加載
        if (propertyMapping.getNestedQueryId() != null && propertyMapping.isLazy()) {
          //這里創建了延遲加載的代理物件
          resultObject = configuration.getProxyFactory().createProxy(resultObject, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
          break;
        }
      }
    }
    this.useConstructorMappings = resultObject != null && !constructorArgTypes.isEmpty(); // set current mapping result
    return resultObject;
  }

如果開啟了懶加載就會通過Javassist或者Cglib為目標物件創建一個代理物件,并指定代理類的處理類EnhancedResultObjectProxyImpl,

static Object crateProxy(Class<?> type, MethodHandler callback, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
    ProxyFactory enhancer = new ProxyFactory();
    //要生成代理物件的原生類
    enhancer.setSuperclass(type);
    ...
    try {
       //創建帶引數的代理物件
      enhanced = enhancer.create(typesArray, valuesArray);
    } catch (Exception e) {
      throw new ExecutorException("Error creating lazy proxy.  Cause: " + e, e);
    }
    ((Proxy) enhanced).setHandler(callback);//指定代理類的處理類
    return enhanced;
  }

當呼叫目標物件的指定方法時,就會被代理物件攔截,然后執行到EnhancedResultObjectProxyImpl該處理類invoke方法,其中PropertyNamer. isProperty(methodName)這段代碼,它會判斷呼叫的方法是不是get,is型別的方法或者lazyLoadTriggerMethods集合中指定的方法,如果是的話,就會觸發懶加載,

private static class EnhancedResultObjectProxyImpl implements MethodHandler {
   ....
   @Override
    public Object invoke(Object enhanced, Method method, Method methodProxy, Object[] args) throws Throwable {
      final String methodName = method.getName();
      try {
        synchronized (lazyLoader) {
          if (WRITE_REPLACE_METHOD.equals(methodName)) {
            .....
          } else {
            if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
              if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            	//全部加載
                lazyLoader.loadAll();
              //判斷是否為set方法,set方法不需要延遲加載
              } else if (PropertyNamer.isSetter(methodName)) { 
                final String property = PropertyNamer.methodToProperty(methodName);
                lazyLoader.remove(property);
              } else if (PropertyNamer.isGetter(methodName)) {
                final String property = PropertyNamer.methodToProperty(methodName);
                if (lazyLoader.hasLoader(property)) {
                  //延遲加載單個屬性
                  lazyLoader.load(property);
                }
              }
            }
          }
        }
        return methodProxy.invoke(enhanced, args);
      } catch (Throwable t) {
        throw ExceptionUtil.unwrapThrowable(t);
      }
    }
}

懶加載程序會根據resultLoader記錄的嵌套查詢的資訊,呼叫具體的方法查詢,最后將查詢結果反射set到目標物件中,完成懶加載程序,

public void load(final Object userObject) throws SQLException {
      .....
      //關鍵點就在這,查詢出關聯物件,然后通過metaObject給目標物件的關聯屬性賦值
      this.metaResultObject.setValue(property, this.resultLoader.loadResult());
    }
public Object loadResult() throws SQLException {
	//這里就會查詢出關聯物件
    List<Object> list = selectList();
    resultObject = resultExtractor.extractObjectFromList(list, targetType);
    return resultObject;
}

其中ResultLoader的生成是在進行嵌套查詢映射時生成的,

private Object getNestedQueryMappingValue(ResultSet rs, MetaObject metaResultObject, ResultMapping propertyMapping, ResultLoaderMap lazyLoader, String columnPrefix)
      throws SQLException {
    final String nestedQueryId = propertyMapping.getNestedQueryId();
    final String property = propertyMapping.getProperty();
    final MappedStatement nestedQuery = configuration.getMappedStatement(nestedQueryId);
    final Class<?> nestedQueryParameterType = nestedQuery.getParameterMap().getType();
    final Object nestedQueryParameterObject = prepareParameterForNestedQuery(rs, propertyMapping, nestedQueryParameterType, columnPrefix);
    Object value = null;
    if (nestedQueryParameterObject != null) {
      .....
      if (executor.isCached(nestedQuery, key)) {
        executor.deferLoad(nestedQuery, metaResultObject, property, key, targetType);
        value = DEFERED;
      } else {
    	//重點,ResultLoader 就在這里構造,記錄嵌套查詢的資訊
        final ResultLoader resultLoader = new ResultLoader(configuration, executor, nestedQuery, nestedQueryParameterObject, targetType, key, nestedBoundSql);
        //懶加載的處理
        if (propertyMapping.isLazy()) {
          //property:嵌套查詢配置的type物件  metaResultObject:目標代理物件   resultLoader: 嵌套查詢資訊
          lazyLoader.addLoader(property, metaResultObject, resultLoader);
          value = DEFERED; //標識為懶加載
        } else {
          value = resultLoader.loadResult();
        }
      }
    }
    return value;
  }

快取

簡介

Mybatis的快取分為一級快取和二級快取,一級快取存在于SqlSession的生命周期中,默認會啟用,二級快取也叫應用快取,存在于SqlSessionFactory的生命周期中,可以理解為跨SqlSession的,快取是以 namespace為單位的,默認未啟用,
對一級快取來說同一個SqlSession在查詢時, Mybatis會把執行的方法和引數等資訊通過演算法生成快取的鍵值,將鍵值和查詢結果存入一個 Map 物件中,大多數情況下同一個SqlSession中執行的方法和引數完全一致,那么通過演算法會生成相同的鍵值,當Map快取物件中己經存在該鍵值時,則查詢時會回傳快取中的物件,任何的 INSERT 、UPDATE 、DELETE 操作都會清空一級快取;

快取具體實作

Mybatis快取的底層是基于一個HashMap進行存盤的,具體的實作為:

//快取的具體實作類
public class PerpetualCache implements Cache {

  private final String id; //Mapper中namespace的值

  //這個的key: cachekey value : sql陳述句處理程序
  //cachekey: sql陳述句、入參、分頁資訊、MappedStatement的id
  private Map<Object, Object> cache = new HashMap<>();
  ...
}

而Mybatis中快取的key生成是非常嚴謹的,在查詢時會呼叫一個createCacheKey方法創建一個CacheKey物件,CacheKey的生成主要由四大約束條件:
1、MappedStatement的id
2、Mybatis內置分頁物件的引數資訊
3、sql陳述句
4、sql陳述句對應的實際引數值

//創建CacheKey物件,做為快取Map中訪問的key
  @Override
  public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
    if (closed) {
      throw new ExecutorException("Executor was closed.");
    }
    CacheKey cacheKey = new CacheKey();
    cacheKey.update(ms.getId()); //MappedStatement的id加入計算
    cacheKey.update(rowBounds.getOffset());  //分頁資訊
    cacheKey.update(rowBounds.getLimit());   //分頁資訊
    cacheKey.update(boundSql.getSql()); // 將sql陳述句加入計算
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); //sql陳述句的引數映射集
    TypeHandlerRegistry typeHandlerRegistry = ms.getConfiguration().getTypeHandlerRegistry(); 
    // mimic DefaultParameterHandler logic
    for (ParameterMapping parameterMapping : parameterMappings) {
      if (parameterMapping.getMode() != ParameterMode.OUT) {
        Object value;
        String propertyName = parameterMapping.getProperty(); // 獲取引數的屬性
        // 以下獲取引數的值
        if (boundSql.hasAdditionalParameter(propertyName)) {
          value = boundSql.getAdditionalParameter(propertyName);
        } else if (parameterObject == null) {
          value = null;
        } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
          value = parameterObject;
        } else {
          MetaObject metaObject = configuration.newMetaObject(parameterObject);
          value = metaObject.getValue(propertyName);
        }
        cacheKey.update(value); // 將引數值加入計算
      }
    }
    if (configuration.getEnvironment() != null) {
      // issue #176
      cacheKey.update(configuration.getEnvironment().getId()); // 存在Environment,則將Environment的id也加入計算
    }
    return cacheKey;
  }

二級快取

配置二級快取

在 Mybatis 的核心組態檔中cacheEnabled引數是二級快取的全域開關,默認值是 true,如果把這個引數設定為false,即使有后面的二級快取配置,也不會生效,
要開啟二級快取,只需要在某一個Mapper檔案中添加配置,如下:

<cache eviction=LRU" flushInterval="60000" size="512" readOnly="true"/>

注意: 二級快取是以namespace為單位的,屬于SqlSession共享的,容易出現臟讀現象,應該避免去使用二級快取,

二級快取實作

在Mapper檔案中開啟二級快取時,是可以動態的配置一些屬性,比如:淘汰策略、定時重繪、同步、日志、序列化功能等能力,Mybatis針對這種場景使用了裝飾器模式進行了二級快取功能的動態增強,二級快取實作類圖如下:
在這里插入圖片描述
底層在初始化二級快取時,是通過XMLMapperBuilder在決議每一個mapper檔案時,會決議每一個cache標簽,然后為當前mapper檔案生成一個PerpetualCache快取具體實作類,之后會根據cache標簽的配置的屬性以及一些默認的屬性,創建對應的快取裝飾器物件(比如SynchronizedCache裝飾器物件,默認為二級快取添加同步功能),對PerpetualCache進行具體的裝飾,

public Cache build() {
	  //設定快取的主實作類為PerpetualCache
    setDefaultImplementations();
    //通過反射實體化PerpetualCache物件
    Cache cache = newBaseCacheInstance(implementation, id);
    setCacheProperties(cache);//根據cache節點下的<property>資訊,初始化cache
    // issue #352, do not apply decorators to custom caches
    
    if (PerpetualCache.class.equals(cache.getClass())) {//如果cache是PerpetualCache的實作,則為其添加標準的裝飾器
      for (Class<? extends Cache> decorator : decorators) {//為cache物件添加裝飾器,這里主要處理快取清空策略的裝飾器
        cache = newCacheDecoratorInstance(decorator, cache);
        setCacheProperties(cache);
      }
      //通過一些屬性為cache物件添加裝飾器
      cache = setStandardDecorators(cache);
    } else if (!LoggingCache.class.isAssignableFrom(cache.getClass())) {
      //如果cache不是PerpetualCache的實作,則為其添加日志的能力
      cache = new LoggingCache(cache);
    }
    return cache;
  }

插件

簡介

插件是用來改變或者擴展Mybatis的原有的功能,Mybatis的插件就是通過繼承Interceptor攔截器來實作的,在沒有完全理解插件之前禁止使用插件對Mybatis進行擴展,有可能會導致嚴重的問題;
Mybatis中能使用插件進行攔截的介面和方法如下:

  1. Executor(update、query 、 flushStatment 、 commit 、 rollback 、 getTransaction 、 close 、 isClose)
  2. StatementHandler(prepare 、 paramterize 、 batch 、 update 、 query)
  3. ParameterHandler( getParameterObject 、 setParameters )
  4. ResultSetHandler( handleResultSets 、 handleCursorResultSets 、 handleOutputParameters )

實作原理

初始化

在Mybatis的組態檔中引入一個插件

<plugins>
  	 <plugin interceptor="com.github.pagehelper.PageInterceptor">
		<property name="pageSizeZero" value="true" />
     </plugin>
</plugins>

之后,組態檔在決議時會通過XMLConfigBuilder這個類,決議所有的plugin標簽,然后根據指定的插件類名,將對應的插件進行反射實體化,最后添加到Configuration配置類中的InterceptorChain物件中,其內部通過list記錄所有的插件,

private void pluginElement(XNode parent) throws Exception {
    if (parent != null) {
      //遍歷所有的插件配置
      for (XNode child : parent.getChildren()) {
    	//獲取插件的類名
        String interceptor = child.getStringAttribute("interceptor");
        //獲取插件的配置
        Properties properties = child.getChildrenAsProperties();
        //實體化插件物件
        Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
        //設定插件屬性
        interceptorInstance.setProperties(properties);
        //將插件添加到configuration物件,底層使用list保存所有的插件并記錄順序
        configuration.addInterceptor(interceptorInstance);
      }
    }
  }

加載

當創建Executor、StatementHandler、ParameterHandler、ResultSetHandler這些介面實作類時,就會嘗試添加插件功能,在Mybatis的Configuration配置類中提供了new這些物件的方法,其中創建Executor實作如下:

public Executor newExecutor(Transaction transaction, ExecutorType executorType) {
    ....
    //通過interceptorChain遍歷所有的插件為executor增強,添加插件的功能
    executor = (Executor) interceptorChain.pluginAll(executor);
    return executor;
  }

遍歷初始化時收集的所有插件,為目標物件添加插件功能

public class InterceptorChain {

  private final List<Interceptor> interceptors = new ArrayList<>();

  public Object pluginAll(Object target) {
    for (Interceptor interceptor : interceptors) {
      //為目標物件添加插件功能
      target = interceptor.plugin(target);
    }
    return target;
  }
  ...
}

通常情況下插件的plugin方法都會執行到Plugin這個代理處理類的wrap方法,通過這個wrap方法會決議當前插件上的@Intercepts注解內部的@Signature注解資訊,然后根據每個Signature攔截的型別來確認是否能夠攔截到當前目標物件,如果能就會基于JDK動態代理為當前目標物件創建一個代理物件,

//靜態方法,用于幫助Interceptor生成動態代理
  public static Object wrap(Object target, Interceptor interceptor) {
	//決議Interceptor上@Intercepts注解得到的signature資訊
    Map<Class<?>, Set<Method>> signatureMap = getSignatureMap(interceptor);
    Class<?> type = target.getClass();//獲取目標物件的型別
    Class<?>[] interfaces = getAllInterfaces(type, signatureMap);//獲取目標物件實作的介面(攔截器可以攔截4大物件實作的介面)
    if (interfaces.length > 0) {
      //使用jdk的方式創建動態代理
      return Proxy.newProxyInstance(
          type.getClassLoader(),
          interfaces,
          new Plugin(target, interceptor, signatureMap));
    }
    return target;
  }

呼叫

加載程序我們知道如果目標物件能夠被任意一個插件攔截就會為其生成一個代理物件,之后當目標物件執行相應方法時,就會被代理物件攔截,然后執行到Plugin這個類的invoke方法,invoke執行程序中會先判斷當前呼叫的方法是否被攔截,如果被攔截就會執行插件的intercept方法,呼叫具體插件邏輯,

public class Plugin implements InvocationHandler {
  //封裝的真正提供服務的物件
  private final Object target;
  //插件攔截器
  private final Interceptor interceptor;
  //決議@Intercepts注解得到的signature資訊
  private final Map<Class<?>, Set<Method>> signatureMap;
  ....
  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    try {
      //獲取當前介面可以被攔截的方法
      Set<Method> methods = signatureMap.get(method.getDeclaringClass());
      if (methods != null && methods.contains(method)) {//如果當前方法需要被攔截,則呼叫interceptor.intercept方法進行攔截處理
        return interceptor.intercept(new Invocation(target, method, args));
      }
      //如果當前方法不需要被攔截,則呼叫物件自身的方法
      return method.invoke(target, args);
    } catch (Exception e) {
      throw ExceptionUtil.unwrapThrowable(e);
    }
  }
}

流式讀取

簡介

Mybatis針對大數量讀取提供了一種流式讀取的方式,避免查詢資料過多,導致OOM,具體實作:
首先,自定義ResultHandler實作類來處理結果集

public class MyResultHandler<T> implements ResultHandler<T>{

	//如果需要批量處理,可以定義一個容器進行保存每條資料
	//當超過BATCH_SIZE再對容器中資料進行處理
	private final int BATCH_SIZE= 100;
	private List<T> list=new ArrayList<T>(); 
	
	@Override
	public void handleResult(ResultContext resultContext) {
		// TODO 流式讀取,每次只回傳單條結果
		Object result=resultContext.getResultObject();
		// TODO 對獲取到的結果資料進行相應的業務處理
	}

}

其次,在指定mapper介面中定義一個以ResultHandler作為入參的查詢方法,并且查詢方法不接識訓傳值

/**
 * 流式讀取資料
 * @param handler  回呼處理
 */
void seachUserDataList(ResultHandler handler);

最后,在呼叫seachUserDataList()查詢方法時,會將查詢到的每一條記錄都呼叫一次MyResultHandler的handleResult()方法,這就是流式讀取的效果,避免一次性在記憶體中加載過大的物件,

實作原理

DefaultResultSetHandler在進行查詢的結果集處理時,會判斷當前查詢方法是否有指定ResultHandler做為入參,如果有,就會使用指定的resultHandler進行后續處理,處理程序中會通過handleRowValuesForSimpleResultMap()對查詢的結果集的每條資料進行處理,將ResultSet結果集的每一行資料映射成目標物件,再呼叫storeObject方法保存映射目標物件,之后就會執行callResultHandler()方法,將目標物件添加到resultContext中,最后根據指定的resultHandler呼叫它的handleResult()方法,達到流式讀取的效果,

//處理結果集
private void handleResultSet(ResultSetWrapper rsw, ResultMap resultMap, List<Object> multipleResults, ResultMapping parentMapping) throws SQLException {
    try {
      if (parentMapping != null) {//處理多結果集的嵌套映射
        handleRowValues(rsw, resultMap, null, RowBounds.DEFAULT, parentMapping);
      } else {
        if (resultHandler == null) {//如果resultHandler為空,實體化一個人默認的resultHandler
         ....
        } else {
          //使用指定的resultHandler進行處理
          handleRowValues(rsw, resultMap, resultHandler, rowBounds, null);
        }
      }
    } finally {
      // issue #228 (close resultsets)
      //呼叫resultset.close()關閉結果集
      closeResultSet(rsw.getResultSet());
    }
  }
//簡單映射處理
private void handleRowValuesForSimpleResultMap(ResultSetWrapper rsw, ResultMap resultMap, ResultHandler<?> resultHandler, RowBounds rowBounds, ResultMapping parentMapping)
      throws SQLException {
	//創建結果背景關系,所謂的背景關系就是專門在回圈中快取結果物件的
    DefaultResultContext<Object> resultContext = new DefaultResultContext<>();
    skipRows(rsw.getResultSet(), rowBounds);
    //shouldProcessMoreRows判斷是否需要映射后續的結果,實際還是翻頁處理,避免超過limit
    while (shouldProcessMoreRows(resultContext, rowBounds) && rsw.getResultSet().next()) {
      ResultMap discriminatedResultMap = resolveDiscriminatedResultMap(rsw.getResultSet(), resultMap, null);
      //讀取resultSet中的一行記錄并進行映射,轉化并回傳目標物件
      Object rowValue = getRowValue(rsw, discriminatedResultMap);
      //保存映射結果物件
      storeObject(resultHandler, resultContext, rowValue, parentMapping, rsw.getResultSet());
    }
}
private void storeObject(ResultHandler<?> resultHandler, DefaultResultContext<Object> resultContext, Object rowValue, ResultMapping parentMapping, ResultSet rs) throws SQLException {
    if (parentMapping != null) {
      linkToParents(rs, parentMapping, rowValue);
    } else {//普通映射則把物件保存至resultHandler和resultContext
      callResultHandler(resultHandler, resultContext, rowValue);
    }
  }
private void callResultHandler(ResultHandler<?> resultHandler, DefaultResultContext<Object> resultContext, Object rowValue) {
    resultContext.nextResultObject(rowValue);
    //流式讀取
    ((ResultHandler<Object>) resultHandler).handleResult(resultContext);
  }

標簽的id可以重復嗎

Mybatis中約束了同一種型別的標簽(ResultMap、增刪改查)不能存在相同的namespace+id,原因是Mybatis的配置類Configuration中,會通過Map去記錄每個標簽封裝的物件,其中namespace+id 是作為Map的key使用的,而Map是使用的自定義StrictMap繼承與HashMap,在進行put()插入標簽元素時,會判斷namespace+id是否重復,重復就會拋出例外,

protected static class StrictMap<V> extends HashMap<String, V> {
    ...
    public V put(String key, V value) {
      //插入之前判斷namespace+id,是否已經存在,已經存在拋出例外
      if (containsKey(key)) {
        throw new IllegalArgumentException(name + " already contains value for " + key);
      }
      ....
      return super.put(key, value);
    }
}

總結

以上介紹了一些Mybatis內部的一些技術點,也結合原始碼去簡單分析了技術點底層實作,在代碼截圖中對一些非關鍵的代碼進行了洗掉,避免關注到其它知識點,個人認為在原始碼學習的程序中,每一個點的學習,要去抓住關鍵點,去排除掉一些無用不相關的代碼,這樣整體的結構就會更清晰點,

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/203072.html

標籤:其他

上一篇:金鴿工業以太網遠程I/O資料采集模塊 (產品系列:MxxxT)

下一篇:Java實作單鏈表的簡單操作

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more