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

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

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

Dictionary.getIdFromValue介绍

[英]Convenient form of getIdFromValue(value, 0)
[中]getIdFromValue(value, 0)的便捷形式

代码示例

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

/**
 * Convenient form of <code>getIdFromValue(value, 0)</code>
 */
final public int getIdFromValue(T value) throws IllegalArgumentException {
  return getIdFromValue(value, 0);
}

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

public void addValue(T value) {
  int id = fullDict.getIdFromValue(value);
  valueToIdMap.put(value, id);
}

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

@Override
public void encode(String valueStr, byte[] output, int outputOffset) {
  try {
    int id = dict.getIdFromValue(valueStr, roundingFlag);
    BytesUtil.writeUnsigned(id, output, outputOffset, fixedLen);
  } catch (IllegalArgumentException ex) {
    for (int i = outputOffset; i < outputOffset + fixedLen; i++) {
      output[i] = defaultByte;
    }
    logger.error("Can't translate value " + valueStr + " to dictionary ID, roundingFlag " + roundingFlag + "."
        + " Using default value " + String.format(Locale.ROOT, "\\x%02X", defaultByte));
  }
}

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

@Override
public void serialize(Object value, ByteBuffer buf) {
  int id = dict.getIdFromValue(value == null ? null : value.toString(), roundingFlag);
  BytesUtil.writeUnsigned(id, dict.getSizeOfId(), buf);
}

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

private long runQueryIdByValueBytes(ArrayList<String> rawData, Dictionary<String> dict, int cardnality, int testTimes) {
  long startTime = System.currentTimeMillis();
  int step = 1;
  for (int i = 0; i < testTimes; i++) {
    for (int j = 0; j < cardnality; j++) {
      step |= dict.getIdFromValue(rawData.get(j));
    }
  }
  return System.currentTimeMillis() - startTime;
}

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

private long runQueryId(ArrayList<String> rawData, Dictionary<String> dict, int cardnality, int testTimes) {
  long startTime = System.currentTimeMillis();
  int step = 1;
  for (int i = 0; i < testTimes; i++) {
    for (int j = 0; j < cardnality; j++) {
      step |= dict.getIdFromValue(rawData.get(j));
    }
  }
  return System.currentTimeMillis() - startTime;
}

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

buf.append(", ");
buf.append(s.toString()).append("=>").append(dict.getIdFromValue(s));

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

@Override
public BitmapCounter valueOf(String[] values, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
  checkArgument(values.length == 1, "expect 1 value, got %s", Arrays.toString(values));
  current.clear();
  if (values[0] == null) {
    return current;
  }
  int id;
  if (needDictionaryColumn(measureDesc.getFunction())) {
    TblColRef literalCol = measureDesc.getFunction().getParameter().getColRefs().get(0);
    Dictionary<String> dictionary = dictionaryMap.get(literalCol);
    id = dictionary.getIdFromValue(values[0]);
  } else {
    id = Integer.parseInt(values[0]);
  }
  current.add(id);
  return current;
}

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

@Override
public List<ByteArray> valueOf(String[] values, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
  if (values.length != 1)
    throw new IllegalArgumentException();
  //source input column value
  String literal = values[0];
  // encode literal using dictionary
  TblColRef literalCol = getRawColumn(measureDesc.getFunction());
  Dictionary<String> dictionary = dictionaryMap.get(literalCol);
  int keyEncodedValue = dictionary.getIdFromValue(literal);
  ByteArray key = new ByteArray(dictionary.getSizeOfId());
  BytesUtil.writeUnsigned(keyEncodedValue, key.array(), key.offset(), dictionary.getSizeOfId());
  List<ByteArray> valueList = new ArrayList<ByteArray>(1);
  valueList.add(key);
  return valueList;
}

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

int[] rowIndex = new int[n];
for (int i = 0; i < n; i++) {
  rowIndex[i] = dict.getIdFromValue(row[i]);

代码示例来源: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

Assert.assertEquals(dict.getIdFromValue(value), dShrunkenDict.getIdFromValue(value));

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

int[] rowIndex = new int[tableDesc.getColumnCount()];
for (ColumnDesc column : tableDesc.getColumns()) {
  rowIndex[column.getZeroBasedIndex()] = dict.getIdFromValue(row[column.getZeroBasedIndex()]);

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

idInMergedDict = mergedDict.nullId();
} else {
  idInMergedDict = mergedDict.getIdFromValue(v);

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

/**
 * Convenient form of <code>getIdFromValue(value, 0)</code>
 */
final public int getIdFromValue(T value) throws IllegalArgumentException {
  return getIdFromValue(value, 0);
}

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

/**
 * Convenient form of <code>getIdFromValue(value, 0)</code>
 */
final public int getIdFromValue(T value) throws IllegalArgumentException {
  return getIdFromValue(value, 0);
}

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

public void addValue(T value) {
  int id = fullDict.getIdFromValue(value);
  valueToIdMap.put(value, id);
}

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

@Override
public void encode(String valueStr, byte[] output, int outputOffset) {
  try {
    int id = dict.getIdFromValue(valueStr, roundingFlag);
    BytesUtil.writeUnsigned(id, output, outputOffset, fixedLen);
  } catch (IllegalArgumentException ex) {
    for (int i = outputOffset; i < outputOffset + fixedLen; i++) {
      output[i] = defaultByte;
    }
    logger.error("Can't translate value " + valueStr + " to dictionary ID, roundingFlag " + roundingFlag + "."
        + " Using default value " + String.format(Locale.ROOT, "\\x%02X", defaultByte));
  }
}

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

@Override
public void serialize(Object value, ByteBuffer buf) {
  int id = dict.getIdFromValue(value == null ? null : value.toString(), roundingFlag);
  BytesUtil.writeUnsigned(id, dict.getSizeOfId(), buf);
}

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

@Override
public List<ByteArray> valueOf(String[] values, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
  if (values.length != 1)
    throw new IllegalArgumentException();
  //source input column value
  String literal = values[0];
  // encode literal using dictionary
  TblColRef literalCol = getRawColumn(measureDesc.getFunction());
  Dictionary<String> dictionary = dictionaryMap.get(literalCol);
  int keyEncodedValue = dictionary.getIdFromValue(literal);
  ByteArray key = new ByteArray(dictionary.getSizeOfId());
  BytesUtil.writeUnsigned(keyEncodedValue, key.array(), key.offset(), dictionary.getSizeOfId());
  List<ByteArray> valueList = new ArrayList<ByteArray>(1);
  valueList.add(key);
  return valueList;
}

相关文章