/** * 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; }
/** * Builds and returns an instance of local signature cache. * * @return the instance of local signature cache */ private DataCache<?> buildLocalSignatureCache() { if (BardFeatureFlag.DRUID_CACHE_V2.isSet()) { LOG.warn("Cache V2 feature flag is deprecated, " + "use the new configuration parameter to set desired caching strategy" ); } try { MemTupleDataCache<Long, String> cache = new MemTupleDataCache<>(); LOG.info("MemcachedClient Version 2 started {}", cache); return cache; } catch (IOException e) { LOG.error("MemcachedClient Version 2 failed to start {}", e); throw new IllegalStateException(e); } }
/** * Builds and returns an instance of TTL cache. * * @return the instance of TTL cache */ private DataCache<?> buildTtlCache() { if (BardFeatureFlag.DRUID_CACHE.isSet()) { LOG.warn("Cache V1 feature flag is deprecated, " + "use the new configuration parameter to set desired caching strategy" ); } try { DataCache<String> cache = new HashDataCache<>(new MemDataCache<HashDataCache.Pair<String, String>>()); LOG.info("MemcachedClient started {}", cache); return cache; } catch (IOException e) { LOG.error("MemcachedClient failed to start {}", e); throw new IllegalStateException(e); } }
/** * 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, getLogicalMetricListSummaryView(apiRequest.getMetrics(), uriInfo), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "metrics" : "rows", null );
containerRequestContext, getLogicalTableListSummaryView(tablesApiRequestImpl.getTables(), uriInfo), UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "tables" : "rows", null );
containerRequestContext, rows, UPDATED_METADATA_COLLECTION_NAMES.isOn() ? "dimensions" : "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.INTERSECTION_REPORTING.isOn()) { ArrayNode metricsJsonArray; try {
if (!BardFeatureFlag.DATA_FILTER_SUBSTRING_OPERATIONS.isOn()) { FilterOperation filterOperation = newFilter.getOperation(); if (filterOperation.equals(DefaultFilterOperation.startswith)