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

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

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

Dictionary.getSize介绍

暂无

代码示例

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

private void initDictInfo(Dictionary<String> newDict, DictionaryInfo newDictInfo) {
  newDictInfo.setCardinality(newDict.getSize());
  newDictInfo.setDictionaryObject(newDict);
  newDictInfo.setDictionaryClass(newDict.getClass().getName());
}

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

private void saveDictionaryInfo(CubeSegment cubeSeg, TblColRef col, DictionaryInfo dictInfo)
    throws IOException {
  if (dictInfo == null)
    return;
  // work on copy instead of cached objects
  CubeInstance cubeCopy = cubeSeg.getCubeInstance().latestCopyForWrite(); // get a latest copy
  CubeSegment segCopy = cubeCopy.getSegmentById(cubeSeg.getUuid());
  Dictionary<?> dict = dictInfo.getDictionaryObject();
  segCopy.putDictResPath(col, dictInfo.getResourcePath());
  segCopy.getRowkeyStats().add(new Object[] { col.getIdentity(), dict.getSize(), dict.getSizeOfId() });
  CubeUpdate update = new CubeUpdate(cubeCopy);
  update.setToUpdateSegs(segCopy);
  updateCube(update);
}

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

public List<T> enumeratorValues() {
  List<T> ret = Lists.newArrayListWithExpectedSize(getSize());
  for (int i = getMinId(); i <= getMaxId(); i++) {
    ret.add(getValueFromId(i));
  }
  return ret;
}

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

private void saveDictionaryInfo(CubeSegment cubeSeg, TblColRef col, DictionaryInfo dictInfo)
    throws IOException {
  if (dictInfo == null)
    return;
  // work on copy instead of cached objects
  CubeInstance cubeCopy = cubeSeg.getCubeInstance().latestCopyForWrite(); // get a latest copy
  CubeSegment segCopy = cubeCopy.getSegmentById(cubeSeg.getUuid());
  Dictionary<?> dict = dictInfo.getDictionaryObject();
  segCopy.putDictResPath(col, dictInfo.getResourcePath());
  segCopy.getRowkeyStats().add(new Object[] { col.getIdentity(), dict.getSize(), dict.getSizeOfId() });
  CubeUpdate update = new CubeUpdate(cubeCopy);
  update.setToUpdateSegs(segCopy);
  updateCube(update);
}

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

logger.debug("Dictionary cardinality: " + dict.getSize());
logger.debug("Dictionary builder class: " + builder.getClass().getName());
logger.debug("Dictionary class: " + dict.getClass().getName());

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

@Override
public boolean contains(Dictionary other) {
  if (other.getSize() > this.getSize()) {
    return false;
  }
  for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
    T v = (T) other.getValueFromId(i);
    if (!this.containsValue(v)) {
      return false;
    }
  }
  return true;
}

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

@Override
public boolean contains(Dictionary other) {
  if (other.getSize() > this.getSize()) {
    return false;
  }
  for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
    T v = (T) other.getValueFromId(i);
    if (!this.containsValue(v)) {
      return false;
    }
  }
  return true;
}

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

assertEquals(3, info1.getDictionaryObject().getSize());

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

public List<T> enumeratorValues() {
  List<T> ret = Lists.newArrayListWithExpectedSize(getSize());
  for (int i = getMinId(); i <= getMaxId(); i++) {
    ret.add(getValueFromId(i));
  }
  return ret;
}

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

private void initDictInfo(Dictionary<String> newDict, DictionaryInfo newDictInfo) {
  newDictInfo.setCardinality(newDict.getSize());
  newDictInfo.setDictionaryObject(newDict);
  newDictInfo.setDictionaryClass(newDict.getClass().getName());
}

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

public static org.apache.kylin.common.util.Dictionary<?> buildDictionaryFromValueEnumerator(DictionaryInfo info, IDictionaryValueEnumerator valueEnumerator) throws IOException{
  org.apache.kylin.common.util.Dictionary dict = null;
  int baseId = 0; // always 0 for now
  final int nSamples = 5;
  ArrayList samples = Lists.newArrayListWithCapacity(nSamples);
  // build dict, case by data type
  DataType dataType = DataType.getInstance(info.getDataType());
  if (dataType.isDateTimeFamily())
    dict = buildDateStrDict(valueEnumerator, baseId, nSamples, samples);
  else if (dataType.isNumberFamily())
    dict = buildNumberDict(valueEnumerator, baseId, nSamples, samples);
  else
    dict = buildStringDict(valueEnumerator, baseId, nSamples, samples);
  // log a few samples
  StringBuilder buf = new StringBuilder();
  for (Object s : samples) {
    if (buf.length() > 0)
      buf.append(", ");
    buf.append(s.toString()).append("=>").append(dict.getIdFromValue(s));
  }
  logger.info("Dictionary value samples: " + buf.toString());
  logger.info("Dictionary cardinality: " + dict.getSize());
  if (dict instanceof TrieDictionary && dict.getSize() > DICT_MAX_CARDINALITY)
    throw new IllegalArgumentException("Too high cardinality is not suitable for dictionary -- " + info.getSourceTable() + "." + info.getSourceColumn() + " cardinality: " + dict.getSize());
  return dict;
}

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

logger.debug("Dictionary cardinality: " + dict.getSize());
logger.debug("Dictionary builder class: " + builder.getClass().getName());
logger.debug("Dictionary class: " + dict.getClass().getName());

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

public DictionaryInfo trySaveNewDict(Dictionary<?> newDict, DictionaryInfo newDictInfo) throws IOException {
  String dupDict = checkDupByContent(newDictInfo, newDict);
  if (dupDict != null) {
    logger.info("Identical dictionary content " + newDict + ", reuse existing dictionary at " + dupDict);
    return getDictionaryInfo(dupDict);
  }
  newDictInfo.setCardinality(newDict.getSize());
  newDictInfo.setDictionaryObject(newDict);
  newDictInfo.setDictionaryClass(newDict.getClass().getName());
  save(newDictInfo);
  dictCache.put(newDictInfo.getResourcePath(), newDictInfo);
  return newDictInfo;
}

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

@Override
public boolean contains(Dictionary other) {
  if (other.getSize() > this.getSize()) {
    return false;
  }
  for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
    T v = (T) other.getValueFromId(i);
    if (!this.containsValue(v)) {
      return false;
    }
  }
  return true;
}

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

@Override
public boolean contains(Dictionary other) {
  if (other.getSize() > this.getSize()) {
    return false;
  }
  for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
    T v = (T) other.getValueFromId(i);
    if (!this.containsValue(v)) {
      return false;
    }
  }
  return true;
}

相关文章