本文整理了Java中org.apache.kylin.metadata.datatype.DataType.isDate()
方法的一些代码示例,展示了DataType.isDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataType.isDate()
方法的具体详情如下:
包路径:org.apache.kylin.metadata.datatype.DataType
类名称:DataType
方法名:isDate
暂无
代码示例来源:origin: apache/kylin
public boolean isTimeFamily() {
return DATETIME_FAMILY.contains(name) && !isDate();
}
代码示例来源:origin: apache/kylin
private String formatTime(String dateStr, DataType dataType) {
if (dataType.isDatetime() || dataType.isTime()) {
throw new RuntimeException("Datetime and time type are not supported yet");
}
if (DateFormat.isSupportedDateFormat(dateStr)) {
return dateStr;
}
long millis = Long.parseLong(dateStr);
if (dataType.isTimestamp()) {
return DateFormat.formatToTimeStr(millis);
} else if (dataType.isDate()) {
return DateFormat.formatToDateStr(millis);
} else {
throw new RuntimeException("Unknown type " + dataType + " to formatTime");
}
}
}
代码示例来源:origin: apache/kylin
public static IDictionaryBuilder newDictionaryBuilder(DataType dataType) {
Preconditions.checkNotNull(dataType, "dataType cannot be null");
// build dict, case by data type
IDictionaryBuilder builder;
if (dataType.isDateTimeFamily()) {
if (dataType.isDate())
builder = new DateDictBuilder();
else
builder = new TimeDictBuilder();
} else {
boolean useForest = KylinConfig.getInstanceFromEnv().isUseForestTrieDictionary();
if (dataType.isNumberFamily())
builder = useForest ? new NumberTrieDictForestBuilder() : new NumberTrieDictBuilder();
else
builder = useForest ? new StringTrieDictForestBuilder() : new StringTrieDictBuilder();
}
return builder;
}
代码示例来源:origin: org.apache.kylin/kylin-core-dictionary
public static IDictionaryBuilder newDictionaryBuilder(DataType dataType) {
Preconditions.checkNotNull(dataType, "dataType cannot be null");
// build dict, case by data type
IDictionaryBuilder builder;
if (dataType.isDateTimeFamily()) {
if (dataType.isDate())
builder = new DateDictBuilder();
else
builder = new TimeDictBuilder();
} else {
boolean useForest = KylinConfig.getInstanceFromEnv().isUseForestTrieDictionary();
if (dataType.isNumberFamily())
builder = useForest ? new NumberTrieDictForestBuilder() : new NumberTrieDictBuilder();
else
builder = useForest ? new StringTrieDictForestBuilder() : new StringTrieDictBuilder();
}
return builder;
}
代码示例来源:origin: apache/kylin
public void init(int index, CubeDesc cubeDesc) {
bitIndex = index;
colRef = cubeDesc.getModel().findColumn(column);
column = colRef.getIdentity();
Preconditions.checkArgument(colRef != null, "Cannot find rowkey column %s in cube %s", column, cubeDesc);
Preconditions.checkState(StringUtils.isNotEmpty(this.encoding));
Object[] encodingConf = DimensionEncoding.parseEncodingConf(this.encoding);
encodingName = (String) encodingConf[0];
encodingArgs = (String[]) encodingConf[1];
if (!DimensionEncodingFactory.isValidEncoding(this.encodingName))
throw new IllegalArgumentException("Not supported row key col encoding: '" + this.encoding + "'");
// convert date/time dictionary on date/time column to DimensionEncoding implicitly
// however date/time dictionary on varchar column is still required
DataType type = colRef.getType();
if (DictionaryDimEnc.ENCODING_NAME.equals(encodingName)) {
if (type.isDate()) {
encoding = encodingName = DateDimEnc.ENCODING_NAME;
}
if (type.isTimeFamily()) {
encoding = encodingName = TimeDimEnc.ENCODING_NAME;
}
}
encodingArgs = DateDimEnc.replaceEncodingArgs(encoding, encodingArgs, encodingName, type);
if (encodingName.startsWith(FixedLenDimEnc.ENCODING_NAME) && (type.isIntegerFamily() || type.isNumberFamily())) {
logger.warn(colRef + " type is " + type + " and cannot apply fixed_length encoding");
}
}
代码示例来源:origin: org.apache.kylin/kylin-core-metadata
private String formatTime(String dateStr, DataType dataType) {
if (dataType.isDatetime() || dataType.isTime()) {
throw new RuntimeException("Datetime and time type are not supported yet");
}
if (DateFormat.isSupportedDateFormat(dateStr)) {
return dateStr;
}
long millis = Long.parseLong(dateStr);
if (dataType.isTimestamp()) {
return DateFormat.formatToTimeStr(millis);
} else if (dataType.isDate()) {
return DateFormat.formatToDateStr(millis);
} else {
throw new RuntimeException("Unknown type " + dataType + " to formatTime");
}
}
}
代码示例来源:origin: apache/kylin
private String tsRangeToStr(long ts, PartitionDesc part) {
String value;
DataType partitionColType = part.getPartitionDateColumnRef().getType();
if (partitionColType.isDate()) {
value = DateFormat.formatToDateStr(ts);
} else if (partitionColType.isTimeFamily()) {
value = DateFormat.formatToTimeWithoutMilliStr(ts);
} else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
String partitionDateFormat = part.getPartitionDateFormat();
if (StringUtils.isEmpty(partitionDateFormat)) {
value = "" + ts;
} else {
value = DateFormat.formatToDateStr(ts, partitionDateFormat);
}
} else {
throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
}
return value;
}
代码示例来源:origin: apache/kylin
private ByteArray encodeTime(long ts, int index, int roundingFlag) {
String value;
DataType partitionColType = info.getColumnType(index);
if (partitionColType.isDate()) {
value = DateFormat.formatToDateStr(ts);
} else if (partitionColType.isTimeFamily()) {
value = DateFormat.formatToTimeWithoutMilliStr(ts);
} else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat();
if (StringUtils.isEmpty(partitionDateFormat)) {
value = "" + ts;
} else {
value = DateFormat.formatToDateStr(ts, partitionDateFormat);
}
} else {
throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
}
ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength());
info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer);
return ByteArray.copyOf(buffer.array(), 0, buffer.position());
}
}
代码示例来源:origin: org.apache.kylin/kylin-core-metadata
public boolean isTimeFamily() {
return DATETIME_FAMILY.contains(name) && !isDate();
}
代码示例来源:origin: org.apache.kylin/kylin-core-cube
public void init(int index, CubeDesc cubeDesc) {
bitIndex = index;
colRef = cubeDesc.getModel().findColumn(column);
column = colRef.getIdentity();
Preconditions.checkArgument(colRef != null, "Cannot find rowkey column %s in cube %s", column, cubeDesc);
Preconditions.checkState(StringUtils.isNotEmpty(this.encoding));
Object[] encodingConf = DimensionEncoding.parseEncodingConf(this.encoding);
encodingName = (String) encodingConf[0];
encodingArgs = (String[]) encodingConf[1];
if (!DimensionEncodingFactory.isValidEncoding(this.encodingName))
throw new IllegalArgumentException("Not supported row key col encoding: '" + this.encoding + "'");
// convert date/time dictionary on date/time column to DimensionEncoding implicitly
// however date/time dictionary on varchar column is still required
DataType type = colRef.getType();
if (DictionaryDimEnc.ENCODING_NAME.equals(encodingName)) {
if (type.isDate()) {
encoding = encodingName = DateDimEnc.ENCODING_NAME;
}
if (type.isTimeFamily()) {
encoding = encodingName = TimeDimEnc.ENCODING_NAME;
}
}
encodingArgs = DateDimEnc.replaceEncodingArgs(encoding, encodingArgs, encodingName, type);
if (encodingName.startsWith(FixedLenDimEnc.ENCODING_NAME) && (type.isIntegerFamily() || type.isNumberFamily())) {
logger.warn(colRef + " type is " + type + " and cannot apply fixed_length encoding");
}
}
代码示例来源:origin: org.apache.kylin/kylin-core-cube
private String tsRangeToStr(long ts, PartitionDesc part) {
String value;
DataType partitionColType = part.getPartitionDateColumnRef().getType();
if (partitionColType.isDate()) {
value = DateFormat.formatToDateStr(ts);
} else if (partitionColType.isTimeFamily()) {
value = DateFormat.formatToTimeWithoutMilliStr(ts);
} else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
String partitionDateFormat = part.getPartitionDateFormat();
if (StringUtils.isEmpty(partitionDateFormat)) {
value = "" + ts;
} else {
value = DateFormat.formatToDateStr(ts, partitionDateFormat);
}
} else {
throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
}
return value;
}
代码示例来源:origin: org.apache.kylin/kylin-core-cube
private ByteArray encodeTime(long ts, int index, int roundingFlag) {
String value;
DataType partitionColType = info.getColumnType(index);
if (partitionColType.isDate()) {
value = DateFormat.formatToDateStr(ts);
} else if (partitionColType.isTimeFamily()) {
value = DateFormat.formatToTimeWithoutMilliStr(ts);
} else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat();
if (StringUtils.isEmpty(partitionDateFormat)) {
value = "" + ts;
} else {
value = DateFormat.formatToDateStr(ts, partitionDateFormat);
}
} else {
throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
}
ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength());
info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer);
return ByteArray.copyOf(buffer.array(), 0, buffer.position());
}
}
内容来源于网络,如有侵权,请联系作者删除!