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

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

本文整理了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

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

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

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

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

  1. public List<T> enumeratorValues() {
  2. List<T> ret = Lists.newArrayListWithExpectedSize(getSize());
  3. for (int i = getMinId(); i <= getMaxId(); i++) {
  4. ret.add(getValueFromId(i));
  5. }
  6. return ret;
  7. }

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

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

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

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

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

  1. @Override
  2. public boolean contains(Dictionary other) {
  3. if (other.getSize() > this.getSize()) {
  4. return false;
  5. }
  6. for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
  7. T v = (T) other.getValueFromId(i);
  8. if (!this.containsValue(v)) {
  9. return false;
  10. }
  11. }
  12. return true;
  13. }

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

  1. @Override
  2. public boolean contains(Dictionary other) {
  3. if (other.getSize() > this.getSize()) {
  4. return false;
  5. }
  6. for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
  7. T v = (T) other.getValueFromId(i);
  8. if (!this.containsValue(v)) {
  9. return false;
  10. }
  11. }
  12. return true;
  13. }

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

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

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

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

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

  1. public List<T> enumeratorValues() {
  2. List<T> ret = Lists.newArrayListWithExpectedSize(getSize());
  3. for (int i = getMinId(); i <= getMaxId(); i++) {
  4. ret.add(getValueFromId(i));
  5. }
  6. return ret;
  7. }

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

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

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

  1. public static org.apache.kylin.common.util.Dictionary<?> buildDictionaryFromValueEnumerator(DictionaryInfo info, IDictionaryValueEnumerator valueEnumerator) throws IOException{
  2. org.apache.kylin.common.util.Dictionary dict = null;
  3. int baseId = 0; // always 0 for now
  4. final int nSamples = 5;
  5. ArrayList samples = Lists.newArrayListWithCapacity(nSamples);
  6. // build dict, case by data type
  7. DataType dataType = DataType.getInstance(info.getDataType());
  8. if (dataType.isDateTimeFamily())
  9. dict = buildDateStrDict(valueEnumerator, baseId, nSamples, samples);
  10. else if (dataType.isNumberFamily())
  11. dict = buildNumberDict(valueEnumerator, baseId, nSamples, samples);
  12. else
  13. dict = buildStringDict(valueEnumerator, baseId, nSamples, samples);
  14. // log a few samples
  15. StringBuilder buf = new StringBuilder();
  16. for (Object s : samples) {
  17. if (buf.length() > 0)
  18. buf.append(", ");
  19. buf.append(s.toString()).append("=>").append(dict.getIdFromValue(s));
  20. }
  21. logger.info("Dictionary value samples: " + buf.toString());
  22. logger.info("Dictionary cardinality: " + dict.getSize());
  23. if (dict instanceof TrieDictionary && dict.getSize() > DICT_MAX_CARDINALITY)
  24. throw new IllegalArgumentException("Too high cardinality is not suitable for dictionary -- " + info.getSourceTable() + "." + info.getSourceColumn() + " cardinality: " + dict.getSize());
  25. return dict;
  26. }

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

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

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

  1. public DictionaryInfo trySaveNewDict(Dictionary<?> newDict, DictionaryInfo newDictInfo) throws IOException {
  2. String dupDict = checkDupByContent(newDictInfo, newDict);
  3. if (dupDict != null) {
  4. logger.info("Identical dictionary content " + newDict + ", reuse existing dictionary at " + dupDict);
  5. return getDictionaryInfo(dupDict);
  6. }
  7. newDictInfo.setCardinality(newDict.getSize());
  8. newDictInfo.setDictionaryObject(newDict);
  9. newDictInfo.setDictionaryClass(newDict.getClass().getName());
  10. save(newDictInfo);
  11. dictCache.put(newDictInfo.getResourcePath(), newDictInfo);
  12. return newDictInfo;
  13. }

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

  1. @Override
  2. public boolean contains(Dictionary other) {
  3. if (other.getSize() > this.getSize()) {
  4. return false;
  5. }
  6. for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
  7. T v = (T) other.getValueFromId(i);
  8. if (!this.containsValue(v)) {
  9. return false;
  10. }
  11. }
  12. return true;
  13. }

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

  1. @Override
  2. public boolean contains(Dictionary other) {
  3. if (other.getSize() > this.getSize()) {
  4. return false;
  5. }
  6. for (int i = other.getMinId(); i <= other.getMaxId(); ++i) {
  7. T v = (T) other.getValueFromId(i);
  8. if (!this.containsValue(v)) {
  9. return false;
  10. }
  11. }
  12. return true;
  13. }

相关文章