@Override public String toString() { return "< field type: TIME, incoming granularity spec: " + _incomingGranularitySpec + ", outgoing granularity spec: " + getOutgoingGranularitySpec() + ", default null value: " + _defaultNullValue + " >"; }
@JsonIgnore public TimeUnit getOutgoingTimeUnit() { return (_timeFieldSpec != null) ? _timeFieldSpec.getOutgoingGranularitySpec().getTimeType() : null; }
@Override public boolean equals(Object o) { if (!super.equals(o)) { return false; } TimeFieldSpec that = (TimeFieldSpec) o; return EqualityUtils.isEqual(_incomingGranularitySpec, that._incomingGranularitySpec) && EqualityUtils .isEqual(getOutgoingGranularitySpec(), that.getOutgoingGranularitySpec()); }
public TimeUnit getSegmentTimeUnit() { if (_segmentTimeUnit != null) { return _segmentTimeUnit; } else { TimeFieldSpec timeFieldSpec = _schema.getTimeFieldSpec(); if (timeFieldSpec != null) { // Outgoing granularity is always non-null. return timeFieldSpec.getOutgoingGranularitySpec().getTimeType(); } return TimeUnit.DAYS; } }
@Nonnull @Override public ObjectNode toJsonObject() { ObjectNode jsonObject = JsonUtils.newObjectNode(); jsonObject.set("incomingGranularitySpec", _incomingGranularitySpec.toJsonObject()); if (!getOutgoingGranularitySpec().equals(_incomingGranularitySpec)) { jsonObject.set("outgoingGranularitySpec", _outgoingGranularitySpec.toJsonObject()); } appendDefaultNullValue(jsonObject); return jsonObject; }
@Override public int hashCode() { int result = EqualityUtils.hashCodeOf(super.hashCode(), _incomingGranularitySpec); result = EqualityUtils.hashCodeOf(result, getOutgoingGranularitySpec()); return result; } }
TimeUnit timeUnit = timeFieldSpec.getOutgoingGranularitySpec().getTimeType(); if (timeUnit != TimeUnit.DAYS) { LOGGER.warn("Table: {}, time column {] has non-DAYS time unit: {}", timeColumnName, timeUnit);
/** * Returns a new schema based on the original one. The new schema removes columns as needed (for ex, virtual cols) * and adds the new timespec to the schema. */ @VisibleForTesting public Schema getUpdatedSchema(Schema original) { TimeFieldSpec tfs = original.getTimeFieldSpec(); // Use outgoing granularity for creating segment TimeGranularitySpec outgoing = tfs.getOutgoingGranularitySpec(); TimeFieldSpec newTimeSpec = new TimeFieldSpec(outgoing); Schema newSchema = new Schema(); newSchema.addField(newTimeSpec); for (String col : original.getPhysicalColumnNames()) { if (!col.equals(tfs.getName())) { newSchema.addField(original.getFieldSpecFor(col)); } } return newSchema; } }
/** * Converts the time column value from timeFieldSpec to dateTimeFieldSpec * @param timeColumnValue - time column value from timeFieldSpec * @return */ private Object convertTimeFieldToDateTimeFieldSpec(Object timeColumnValue) { TimeGranularitySpec timeGranularitySpec = _timeFieldSpec.getOutgoingGranularitySpec(); DateTimeFormatSpec formatFromTimeSpec = new DateTimeFormatSpec(timeGranularitySpec.getTimeUnitSize(), timeGranularitySpec.getTimeType().toString(), timeGranularitySpec.getTimeFormat()); if (formatFromTimeSpec.getFormat().equals(_dateTimeFieldSpec.getFormat())) { return timeColumnValue; } long timeColumnValueMS = timeGranularitySpec.toMillis(timeColumnValue); DateTimeFormatSpec toFormat = new DateTimeFormatSpec(_dateTimeFieldSpec.getFormat()); return toFormat.fromMillisToFormat(timeColumnValueMS, Object.class); }
public TimeTransformer(Schema schema) { TimeFieldSpec timeFieldSpec = schema.getTimeFieldSpec(); if (timeFieldSpec != null) { TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); // Perform time conversion only if incoming and outgoing granularity spec are different if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { _incomingTimeColumn = incomingGranularitySpec.getName(); _outgoingTimeColumn = outgoingGranularitySpec.getName(); _incomingTimeConverter = new TimeConverter(incomingGranularitySpec); _outgoingTimeConverter = new TimeConverter(outgoingGranularitySpec); } } }
long segEndTime = realtimeSegment.getMaxTime(); TimeUnit timeUnit = schema.getTimeFieldSpec().getOutgoingGranularitySpec().getTimeType(); ImmutableSegment segment = ImmutableSegmentLoader.load(new File(resourceDir, segmentMetatdaZk.getSegmentName()), indexLoadingConfig);
private String getDefaultSegmentName(TableConfig tableConfig, Schema schema, List<File> inputIndexDirs, long minStartTime, long maxEndTime) throws Exception { String tableName = tableConfig.getTableName(); // Fetch time related configurations from schema and table config. String pushFrequency = tableConfig.getValidationConfig().getSegmentPushFrequency(); String timeColumnType = tableConfig.getValidationConfig().getTimeType(); String pushType = tableConfig.getValidationConfig().getSegmentPushType(); String timeFormat = schema.getTimeFieldSpec().getOutgoingGranularitySpec().getTimeFormat(); // Generate the final segment name using segment name generator NormalizedDateSegmentNameGenerator segmentNameGenerator = new NormalizedDateSegmentNameGenerator(tableName, DEFAULT_SEQUENCE_ID, timeColumnType, pushFrequency, pushType, null, null, timeFormat); return segmentNameGenerator.generateSegmentName(minStartTime, maxEndTime); }
genConfig.setSegmentTimeUnit(dataSchema.getTimeFieldSpec().getOutgoingGranularitySpec().getTimeType()); if (segmentVersion != null) { genConfig.setSegmentVersion(segmentVersion);