/** * Returns a key that, when fed into a {@link com.yahoo.bard.webservice.data.dimension.KeyValueStore} returns the * field name used by Lucene. * * @param columnName The name of the column to extract from Lucene. * * @return A key that, when fed into a KeyValueStore, returns the ID used to query a dimension in Lucene. */ public static String getColumnKey(String columnName) { String key = ""; if (columnName != null) { key = BardFeatureFlag.CASE_SENSITIVE_KEYS.isOn() ? columnName : columnName.toLowerCase(Locale.ENGLISH); } return key + "_column_key"; }
@Override public boolean isOn() { if (on == null) { // TODO: Remove this if conditional after cache V1 & V2 configuration flags are removed if (BardFeatureFlag.DRUID_CACHE.isSet() || BardFeatureFlag.DRUID_CACHE_V2.isSet()) { // no cache if (this.value.equals("NoCache")) { return ! BardFeatureFlag.DRUID_CACHE.isOn(); } return (this.value.equals("Ttl") && !BardFeatureFlag.DRUID_CACHE_V2.isOn() && BardFeatureFlag.DRUID_CACHE.isOn() ) || (this.value.equals("LocalSignature") && BardFeatureFlag.DRUID_CACHE.isOn() && BardFeatureFlag.DRUID_CACHE_V2.isOn()); } on = value.equalsIgnoreCase(SYSTEM_CONFIG.getStringProperty( SYSTEM_CONFIG.getPackageVariableName("query_response_caching_strategy"), "NoCache") ); } return on; }
/** * Returns a key that allows access to the dimension rows of a given dimension. * <p> * Given a dimension field name (such as "id"), and the id of the dimension desired, returns a key. When * this key is passed into the appropriate {@link com.yahoo.bard.webservice.data.dimension.KeyValueStore}, * the KeyValueStore will return the metadata of the associated dimension. * * @param fieldName The dimension field name to be appended to the beginning of the key * @param fieldValue The key of the dimension whose data is desired * * @return A key that, when passed into the appropriate KeyValueStore, will return the associated dimension value. */ public static String getRowKey(@NotNull String fieldName, String fieldValue) { boolean caseSensitive = BardFeatureFlag.CASE_SENSITIVE_KEYS.isOn(); String lookupFieldValue = fieldValue == null ? "" : fieldValue; return new StringBuilder() .append(caseSensitive ? fieldName : fieldName.toLowerCase(Locale.ENGLISH)) .append(KEY_SEPARATOR) .append(caseSensitive ? lookupFieldValue : lookupFieldValue.toLowerCase(Locale.ENGLISH)) .append(ROW_KEY_SUFFIX) .toString(); }
@Override public BinaryOperator<PhysicalTable> getBetterTableOperator(QueryPlanningConstraint requestConstraint) { List<Comparator<PhysicalTable>> comparators = new ArrayList<>(); if (BardFeatureFlag.PARTIAL_DATA.isOn()) { comparators.add( new PartialTimeComparator(requestConstraint, partialDataHandler)); comparators.add( new VolatileTimeComparator(requestConstraint, partialDataHandler, volatileIntervalsService)); } comparators.add(COMPARE_GRANULARITY); comparators.add(CARDINALITY_COMPARATOR); ChainingComparator<PhysicalTable> tableComparator = new ChainingComparator<>(comparators); return BinaryOperator.minBy(tableComparator); } }
/** * Creates an object that constructs Druid dimension filters from Bard dimension filters. * <p> * Constructs a {@link DruidInFilterBuilder} by default. * * @return An object to build Druid filters from API filters */ protected DruidFilterBuilder buildDruidFilterBuilder() { if (BardFeatureFlag.DEFAULT_IN_FILTER.isOn()) { return new DruidInFilterBuilder(); } else { return new DruidOrFilterBuilder(); } }
/** * Determine if the optimization to a TopN query can be done. * * @param apiRequest The request data * @param templateDruidQuery The template query * * @return true if the optimization can be done, false if it can't */ protected boolean canOptimizeTopN(DataApiRequest apiRequest, TemplateDruidQuery templateDruidQuery) { return apiRequest.getDimensions().size() == 1 && apiRequest.getSorts().size() == 1 && !templateDruidQuery.isNested() && BardFeatureFlag.TOP_N.isOn() && apiRequest.getHavings().isEmpty(); }
@Override public void processResponse(JsonNode json, DruidAggregationQuery<?> druidQuery, LoggingContext metadata) { if (CACHE_PARTIAL_DATA.isOn() || isCacheable()) { String valueString = null; try {
containerRequestContext, status, UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "feature flags" : "rows", Arrays.asList("name", "value") );
Pagination pagination = responseData.getPagination(); boolean paginating = pagination != null; boolean haveMissingIntervals = BardFeatureFlag.PARTIAL_DATA.isOn() && !missingIntervals.isEmpty(); boolean haveVolatileIntervals = volatileIntervals != null && ! volatileIntervals.isEmpty();
containerRequestContext, getDimensionListSummaryView(apiRequest.getDimensions(), uriInfo), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "dimensions" : "rows", null );
containerRequestContext, apiRequest.getSlices(), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "slices" : "rows", null );
containerRequestContext, getLogicalTableListSummaryView(tablesApiRequestImpl.getTables(), uriInfo), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "tables" : "rows", null );
containerRequestContext, getLogicalMetricListSummaryView(apiRequest.getMetrics(), uriInfo), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "metrics" : "rows", null );
@Override protected DataCache<?> buildCache() { if (BardFeatureFlag.DRUID_CACHE.isOn()) { // test cache stored in memory if (BardFeatureFlag.DRUID_CACHE_V2.isOn()) { state.cache = new TestTupleDataCache(); } else { state.cache = new HashDataCache<>(new TestDataCache()); } } else { state.cache = new StubDataCache<>(); } return state.cache; }
@Override protected DataCache<?> buildCache() { if (BardFeatureFlag.DRUID_CACHE.isOn()) { // test cache stored in memory if (BardFeatureFlag.DRUID_CACHE_V2.isOn()) { state.cache = new TestTupleDataCache(); } else { state.cache = new HashDataCache<>(new TestDataCache()); } } else { state.cache = new StubDataCache<>(); } return state.cache; }
if (!BardFeatureFlag.DATA_FILTER_SUBSTRING_OPERATIONS.isOn()) { FilterOperation filterOperation = newFilter.getOperation(); if (filterOperation.equals(DefaultFilterOperation.startswith)
/** * Bind the query interval string to a list of intervals. * * @param intervalsName The query string describing the intervals * @param granularity The granularity for this request * @param timeZone The time zone to evaluate interval timestamps in * * @return A bound list of intervals for the query */ protected List<Interval> bindIntervals(String intervalsName, Granularity granularity, DateTimeZone timeZone) { DateTimeFormatter dateTimeFormatter = generateDateTimeFormatter(timeZone); List<Interval> result; if (BardFeatureFlag.CURRENT_MACRO_USES_LATEST.isOn()) { SimplifiedIntervalList availability = TableUtils.logicalTableAvailability(getTable()); DateTime adjustedNow = new DateTime(); if (! availability.isEmpty()) { DateTime firstUnavailable = availability.getLast().getEnd(); if (firstUnavailable.isBeforeNow()) { adjustedNow = firstUnavailable; } } result = generateIntervals(adjustedNow, intervalsName, granularity, dateTimeFormatter); } else { result = generateIntervals(intervalsName, granularity, dateTimeFormatter); } return result; }
if (BardFeatureFlag.PARTIAL_DATA.isOn()) { PartialDataResultSetMapper mapper = new PartialDataResultSetMapper( missingIntervals,
if (BardFeatureFlag.QUERY_SPLIT.isOn()) { handler = new SplitQueryRequestHandler(handler);
if (BardFeatureFlag.QUERY_SPLIT.isOn()) { handler = new SplitQueryRequestHandler(handler);