コード例 #1
0
 /**
  * 函数名:getFieldsIndexAllValues 功能描述:在当前指针的位置,获取fields字段下visitType类型的所有版本值.
  *
  * @param result
  * @param fields
  * @param visitorType
  * @return
  */
 private static List<String> getFieldsIndexAllValues(
     HbaseResult result, INDEX_FIELDS fields, Integer visitorType) {
   if (result == null || result.size() == 0) return null;
   List<String> retVal = new ArrayList<String>();
   retVal.addAll(
       result.getAllData(
           result.getCurPos(),
           UserVisitLogFields.Index_Family,
           fields.toString() + "_" + visitorType));
   return retVal;
 }
コード例 #2
0
 /**
  * 函数名:getFieldsIndexValue 功能描述:在当前指针位置,获取fields字段的最近值,当不指定visitType时且fields=keyList时,那么
  * visitType将是最近一次访问类型.
  *
  * @param result
  * @param family
  * @param fields
  * @param visitType
  * @return
  */
 private static Object getFieldsIndexValue(
     HbaseResult result, String family, INDEX_FIELDS fields, Integer visitType) {
   if (result == null || result.size() == 0) return null;
   String retVal = null;
   byte[] tmp = null;
   String quality = fields.toString();
   switch (fields) {
       // add get visitTime operation
     case visitTime:
       tmp = result.getRawValue(result.getCurPos(), family, quality);
       if (tmp == null) return null;
       return Bytes.toLong(tmp);
     case count:
       if (visitType != null && visitType > 0) quality = fields + "_" + visitType;
       tmp = result.getRawValue(result.getCurPos(), family, quality);
       if (tmp == null) return null;
       return Bytes.toLong(tmp);
     case keyList:
       Integer type = null;
       if (visitType == null || visitType == 0) {
         byte tmpArray[] =
             result.getRawValue(
                 result.getCurPos(),
                 UserVisitLogFields.Index_InfoFam,
                 INDEX_FIELDS.visitType.toString());
         if (tmpArray != null) {
           type = Integer.parseInt(Bytes.toString(tmpArray));
         }
       } else {
         type = visitType;
       }
       if (type == null) return null;
       tmp = result.getRawValue(result.getCurPos(), family, fields.toString() + "_" + type);
       if (tmp == null) return null;
       retVal = Bytes.toString(tmp);
       break;
     default:
       return null;
   }
   return retVal;
 }