简体   繁体   English

如何获得现有德鲁伊数据源的粒度

[英]how to get granularity of existing druid data source

I am working to update existing records in druid by retrieving existing records ,updating and then ingesting back with updated records. 我正在通过检索现有记录,更新然后使用更新后的记录提取回来来更新druid中的现有记录。 So ,i need to fetch the granularity of existing datasource which will be used while ingesting back the updated records. 因此,我需要获取将在提取回更新记录时使用的现有数据源的粒度。

As none of the queryType is returning the granularity. 由于没有任何queryType返回粒度。 I have retrieved the datasource details using http://localhost:8081/druid/coordinator/v1/metadata/datasources/wikiticker 我已经使用http:// localhost:8081 / druid / coordinator / v1 / metadata / datasources / wikiticker检索了数据源详细信息

then fetch the last or any segment's interval 然后获取最后一个或任何段的间隔

JSONArray segmentArray = (JSONArray) dataSourceObj.get("segments");
      JSONObject lastSegmentObject = new JSONObject(segmentArray.get(segmentArray.length()-1).toString());
      String granularityInterval = lastSegmentObject.get("interval").toString();

then calculate difference between the date interval using any api eg: joda 然后使用任何api计算日期间隔之间的差异,例如:joda

SimpleDateFormat format = new SimpleDateFormat(Constants.DATE_FORMAT);
            Date intervalStart = format.parse(interval.split("/")[0]);
            Date intervalEnd = format.parse(interval.split("/")[1]);
DateTime startTime = new DateTime(intervalStart) ; DateTime endTime = new DateTime(intervalEnd) ;

Period jodaPeriod = new Period(startTime, endTime); if(jodaPeriod.getYears() == 1){ return DesignerConstants.DRUID_GRANULARITY_YEAR; }else if(jodaPeriod.getMonths() == 1){ return DesignerConstants.DRUID_GRANULARITY_MONTH; }else if(jodaPeriod.getWeeks() == 1){ return DesignerConstants.DRUID_GRANULARITY_WEEK; }else if(jodaPeriod.getDays() == 1){ return DesignerConstants.DRUID_GRANULARITY_DAY; }else if(jodaPeriod.getHours() == 1){ return DesignerConstants.DRUID_GRANULARITY_HOUR; } return "none"; } </pre>

FYI a data source can have multiple segment granularity, that's why there is no query that will do that for you. 仅供参考,数据源可以具有多个细分粒度,这就是为什么没有查询可以为您做到这一点的原因。 Although the code above will return the granularity of the last segment which is different from the original question you have asked. 尽管上面的代码将返回最后一段的粒度,该粒度与您最初询问的问题不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从 Druid 中已经存在的 Druid 导出为 csv 格式? - How to export data as csv format from Druid that already exits in the Druid? 如何在Visual Studio 2010中将现有数据模型添加为数据源? - How to add an existing data model as a Data Source in Visual Studio 2010? Tableau:如何在现有的 tableau 工作簿中加入新的数据源 - Tableau: How to join new data source in existing tableau workbook 如何在Microsoft Expression Bend 3中使现有对象成为数据源? - How to make an existing object a data source in Microsoft Expression Bend 3? 对于给定的数据源,如何获得给定的连接是xa还是非xa? - How to get given connection is xa or non xa for given data source? 如何在java中使用数据源对象获取数据库配置 - How to get database configurations using data source object in java 如何从WSO2 DSS获取数据源信息? - How to get data source information from WSO2 DSS? 我如何获得阵列数据源kendo-grid? - how can i get array data source, kendo-grid? 如何从collectionview的数据源获取项目数 - How to get number of items from collectionview's data source Sitecore如何获取控件的数据源值 - Sitecore How to Get Control's Data Source Value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM