org.apache.kylin.common.util.Dictionary.nullId()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.kylin.common.util.Dictionary.nullId()方法的一些代码示例,展示了Dictionary.nullId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dictionary.nullId()方法的具体详情如下:
包路径:org.apache.kylin.common.util.Dictionary
类名称:Dictionary
方法名:nullId

Dictionary.nullId介绍

暂无

代码示例

代码示例来源:origin: apache/kylin

/**
 * Returns the ID integer of given value. In case of not found
 * <p>
 * - if roundingFlag=0, throw IllegalArgumentException; <br>
 * - if roundingFlag<0, the closest smaller ID integer if exist; <br>
 * - if roundingFlag>0, the closest bigger ID integer if exist. <br>
 * <p>
 * The implementation often has cache, thus faster than the byte[] version getIdFromValueBytes()
 * 
 * @throws IllegalArgumentException
 *             if value is not found in dictionary and rounding is off;
 *             or if rounding cannot find a smaller or bigger ID
 */
final public int getIdFromValue(T value, int roundingFlag) throws IllegalArgumentException {
  if (isNullObjectForm(value))
    return nullId();
  int id = getIdFromValueImpl(value, roundingFlag);
  if (id == -1) {
    throw new IllegalArgumentException("Value : " + value + " not exists");
  }
  return id;
}

代码示例来源:origin: apache/kylin

@Override
  public List<ByteArray> reEncodeDictionary(List<ByteArray> value, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> oldDicts, Map<TblColRef, Dictionary<String>> newDicts) {
    TblColRef colRef = getRawColumn(measureDesc.getFunction());
    Dictionary<String> sourceDict = oldDicts.get(colRef);
    Dictionary<String> mergedDict = newDicts.get(colRef);
    int valueSize = value.size();
    byte[] newIdBuf = new byte[valueSize * mergedDict.getSizeOfId()];
    int bufOffset = 0;
    for (ByteArray c : value) {
      int oldId = BytesUtil.readUnsigned(c.array(), c.offset(), c.length());
      int newId;
      String v = sourceDict.getValueFromId(oldId);
      if (v == null) {
        newId = mergedDict.nullId();
      } else {
        newId = mergedDict.getIdFromValue(v);
      }
      BytesUtil.writeUnsigned(newId, newIdBuf, bufOffset, mergedDict.getSizeOfId());
      c.reset(newIdBuf, bufOffset, mergedDict.getSizeOfId());
      bufOffset += mergedDict.getSizeOfId();
    }
    return value;
  }
};

代码示例来源:origin: apache/kylin

BytesUtil.writeUnsigned(mergedDict.nullId(), newKeyBodyBuf, bufOffset, mergedDict.getSizeOfId());
  bufOffset += mergedDict.getSizeOfId();
  continue;
  idInMergedDict = mergedDict.nullId();
} else {
  idInMergedDict = mergedDict.getIdFromValue(v);

代码示例来源:origin: apache/kylin

@Ignore
@SuppressWarnings("unchecked")
@Test
public void testEmptyInput() throws IOException {
  String[] ints = new String[] { "", "0", "5", "100", "13" };
  // check "" is treated as NULL, not a code of dictionary
  Dictionary<?> dict = DictionaryGenerator.buildDictionary(DataType.getType("integer"),
      new IterableDictionaryValueEnumerator(ints));
  assertEquals(4, dict.getSize());
  final int id = ((NumberDictionary<String>) dict).getIdFromValue("");
  assertEquals(id, dict.nullId());
}

代码示例来源:origin: org.apache.kylin/kylin-core-common

/**
 * Returns the ID integer of given value. In case of not found
 * <p>
 * - if roundingFlag=0, throw IllegalArgumentException; <br>
 * - if roundingFlag<0, the closest smaller ID integer if exist; <br>
 * - if roundingFlag>0, the closest bigger ID integer if exist. <br>
 * <p>
 * The implementation often has cache, thus faster than the byte[] version getIdFromValueBytes()
 * 
 * @throws IllegalArgumentException
 *             if value is not found in dictionary and rounding is off;
 *             or if rounding cannot find a smaller or bigger ID
 */
final public int getIdFromValue(T value, int roundingFlag) throws IllegalArgumentException {
  if (isNullObjectForm(value))
    return nullId();
  int id = getIdFromValueImpl(value, roundingFlag);
  if (id == -1) {
    throw new IllegalArgumentException("Value : " + value + " not exists");
  }
  return id;
}

代码示例来源:origin: org.apache.kylin/kylin-common

/**
 * A lower level API, return ID integer from raw value bytes. In case of not found
 * <p>
 * - if roundingFlag=0, throw IllegalArgumentException; <br>
 * - if roundingFlag<0, the closest smaller ID integer if exist; <br> 
 * - if roundingFlag>0, the closest bigger ID integer if exist. <br>
 * <p>
 * Bypassing the cache layer, this could be significantly slower than getIdFromValue(T value).
 * 
 * @throws IllegalArgumentException
 *             if value is not found in dictionary and rounding is off or failed
 */
final public int getIdFromValueBytes(byte[] value, int offset, int len, int roundingFlag) {
  if (isNullByteForm(value, offset, len))
    return nullId();
  else
    return getIdFromValueBytesImpl(value, offset, len, roundingFlag);
}

代码示例来源:origin: org.apache.kylin/kylin-common

/**
 * Returns the ID integer of given value. In case of not found
 * <p>
 * - if roundingFlag=0, throw IllegalArgumentException; <br>
 * - if roundingFlag<0, the closest smaller ID integer if exist; <br>
 * - if roundingFlag>0, the closest bigger ID integer if exist. <br>
 * <p>
 * The implementation often has cache, thus faster than the byte[] version getIdFromValueBytes()
 * 
 * @throws IllegalArgumentException
 *             if value is not found in dictionary and rounding is off or
 *             failed
 */
final public int getIdFromValue(T value, int roundingFlag) throws IllegalArgumentException {
  if (isNullObjectForm(value))
    return nullId();
  else
    return getIdFromValueImpl(value, roundingFlag);
}

代码示例来源:origin: org.apache.kylin/kylin-job

idInMergedDict = mergedDict.nullId();
} else {
  idInMergedDict = mergedDict.getIdFromValueBytes(newKeyBuf, bufOffset, size);

代码示例来源:origin: org.apache.kylin/kylin-core-metadata

@Override
  public List<ByteArray> reEncodeDictionary(List<ByteArray> value, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> oldDicts, Map<TblColRef, Dictionary<String>> newDicts) {
    TblColRef colRef = getRawColumn(measureDesc.getFunction());
    Dictionary<String> sourceDict = oldDicts.get(colRef);
    Dictionary<String> mergedDict = newDicts.get(colRef);
    int valueSize = value.size();
    byte[] newIdBuf = new byte[valueSize * mergedDict.getSizeOfId()];
    int bufOffset = 0;
    for (ByteArray c : value) {
      int oldId = BytesUtil.readUnsigned(c.array(), c.offset(), c.length());
      int newId;
      String v = sourceDict.getValueFromId(oldId);
      if (v == null) {
        newId = mergedDict.nullId();
      } else {
        newId = mergedDict.getIdFromValue(v);
      }
      BytesUtil.writeUnsigned(newId, newIdBuf, bufOffset, mergedDict.getSizeOfId());
      c.reset(newIdBuf, bufOffset, mergedDict.getSizeOfId());
      bufOffset += mergedDict.getSizeOfId();
    }
    return value;
  }
};

代码示例来源:origin: org.apache.kylin/kylin-engine-mr

BytesUtil.writeUnsigned(mergedDict.nullId(), newKeyBodyBuf, bufOffset, mergedDict.getSizeOfId());
  bufOffset += mergedDict.getSizeOfId();
  continue;
  idInMergedDict = mergedDict.nullId();
} else {
  idInMergedDict = mergedDict.getIdFromValue(v);

相关文章