Package com.taobao.tddl.common.sequence.Config

Examples of com.taobao.tddl.common.sequence.Config.Route


 
  @SuppressWarnings("unchecked")
  public DetachID<Long, Integer, Integer> parse(Long id) {
    DetachID<Long, Integer, Integer> detachID = new DetachID<Long, Integer, Integer>();

    Route dbRoute = config.getDatabaseRoute();
    Route tableRoute = config.getTableRoute();
    int size = config.getTotalSize();
    long routeBits;
    if(config.isPositionRight()) {
      detachID.setId(id / pow10[size]);
      routeBits = id % pow10[size];
    } else {
      detachID.setId(id % pow10[19 - size]);
      routeBits =  id / pow10[19 - size];
    }
   
    routeBits += Year2000Time;
    Date date = new Date(routeBits);
   
    if(dbRoute == null) {
      detachID.setDatabaseArg(null);
    } else {
      detachID.setDatabaseArg(((Route.AbstractExpression<Date>)dbRoute.getExpression()).execute(date));
    }
   
    if(tableRoute == null) {
      detachID.setTableArg(null);
    } else {
      detachID.setTableArg(((Route.AbstractExpression<Date>)tableRoute.getExpression()).execute(date));
    }
   
    return detachID;

  }
View Full Code Here


   * @return ��ɢ��ɢ����Ϣ��ԭʼid�������������ɵ�id������һ��bean
   */
  public DetachID<Long, Integer, Integer> parse(Long id) {
    DetachID<Long, Integer, Integer> detachID = new DetachID<Long, Integer, Integer>();
   
    Route dbRoute = config.getDatabaseRoute();
    Route tableRoute = config.getTableRoute();
    int size = (dbRoute == null ? 0 : dbRoute.getSize()) +
          (tableRoute == null ? 0 : tableRoute.getSize());
    int routeBits;
    if(config.isPositionRight()) {
      detachID.setId(id / pow10[size]);
      //routeBits���ܳ���8λ��ʮ����λ��
      routeBits = (int) (id % pow10[size]);
    } else {
      detachID.setId(size == 0 ? id : id % pow10[19 - size]);
      routeBits = (int) (size == 0 ? 0 : id / pow10[19 - size]);
    }
    if(dbRoute == null) {
      detachID.setDatabaseArg(null);
    } else {
      detachID.setDatabaseArg((int) (tableRoute == null ? routeBits : routeBits / pow10[tableRoute.getSize()]));
    }
    if(tableRoute == null) {
      detachID.setTableArg(null);
    } else {
      detachID.setTableArg((int) (routeBits % pow10[tableRoute.getSize()]));
    }
    return detachID;
  }
View Full Code Here

TOP

Related Classes of com.taobao.tddl.common.sequence.Config.Route

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.