Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asifmansoora committed Feb 23, 2017
1 parent 01f6b6f commit d2cc90e
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 Yahoo Inc.
// Copyright 2017 Yahoo Inc.
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.data.config.dimension;

Expand All @@ -12,9 +12,9 @@


/**
* A Dimension instance holds all of the information needed to construct a Dimension.
* A Default Key Value Store Dimension holds all of the information needed to construct a Dimension.
*/
public class DefaultDimensionConfig implements DimensionConfig {
public class DefaultKeyValueStoreDimensionConfig implements DimensionConfig {

private final DimensionName apiName;
private final String physicalName;
Expand All @@ -27,7 +27,8 @@ public class DefaultDimensionConfig implements DimensionConfig {
private final SearchProvider searchProvider;

/**
* Construct a DefaultDimensionConfig Instance from Dimension Name , dimension fields and default dimension fields.
* Construct a DefaultKeyValueStoreDimensionConfig instance from dimension name, dimension fields and
* default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
* @param physicalName The internal, physical name for the dimension.
Expand All @@ -39,12 +40,12 @@ public class DefaultDimensionConfig implements DimensionConfig {
* @param keyValueStore The key value store holding dimension row data.
* @param searchProvider The search provider for field value lookups on this dimension.
*/
public DefaultDimensionConfig(
public DefaultKeyValueStoreDimensionConfig(
@NotNull DimensionName apiName,
@NotNull String physicalName,
@NotNull String description,
@NotNull String longName,
@NotNull String category,
String physicalName,
String description,
String longName,
String category,
@NotNull LinkedHashSet<DimensionField> fields,
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields,
@NotNull KeyValueStore keyValueStore,
Expand All @@ -62,7 +63,8 @@ public DefaultDimensionConfig(
}

/**
* Construct a DefaultDimensionConfig Instance from Dimension Name and only using default dimension fields.
* Construct a DefaultKeyValueStoreDimensionConfig instance from dimension name and
* only using default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
* @param physicalName The internal, physical name for the dimension.
Expand All @@ -73,7 +75,7 @@ public DefaultDimensionConfig(
* @param keyValueStore The key value store holding dimension row data.
* @param searchProvider The search provider for field value lookups on this dimension.
*/
public DefaultDimensionConfig(
public DefaultKeyValueStoreDimensionConfig(
DimensionName apiName,
String physicalName,
String description,
Expand All @@ -96,38 +98,47 @@ public DefaultDimensionConfig(
);
}

@Override
public String getApiName() {
return apiName.asName();
}

@Override
public String getLongName() {
return longName;
}

@Override
public String getCategory() {
return category;
}

@Override
public String getPhysicalName() {
return physicalName;
}

@Override
public String getDescription() {
return description;
}

@Override
public LinkedHashSet<DimensionField> getFields() {
return fields;
}

@Override
public LinkedHashSet<DimensionField> getDefaultDimensionFields() {
return defaultDimensionFields;
}

@Override
public KeyValueStore getKeyValueStore() {
return keyValueStore;
}

@Override
public SearchProvider getSearchProvider() {
return searchProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import javax.validation.constraints.NotNull;

/**
* A Lookup Dimension instance holds all of the information needed to construct a Lookup Dimension.
* A Default Lookup Dimension holds all of the information needed to construct a Lookup Dimension.
*/
public class LookupDefaultDimensionConfig extends DefaultDimensionConfig implements LookupDimensionConfig {
public class DefaultLookupDimensionConfig extends DefaultKeyValueStoreDimensionConfig implements LookupDimensionConfig {
private final List<String> namespaces;

/**
* Construct a LookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and
* Construct a LookupDefaultDimensionConfig instance from dimension name, dimension fields and
* default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
Expand All @@ -32,12 +32,12 @@ public class LookupDefaultDimensionConfig extends DefaultDimensionConfig impleme
* @param searchProvider The search provider for field value lookups on this dimension.
* @param namespaces A list of namespaces used to configure the Lookup dimension.
*/
public LookupDefaultDimensionConfig(
public DefaultLookupDimensionConfig(
@NotNull DimensionName apiName,
@NotNull String physicalName,
@NotNull String description,
@NotNull String longName,
@NotNull String category,
String physicalName,
String description,
String longName,
String category,
@NotNull LinkedHashSet<DimensionField> fields,
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields,
@NotNull KeyValueStore keyValueStore,
Expand All @@ -59,7 +59,7 @@ public LookupDefaultDimensionConfig(
}

/**
* Construct a LookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and default dimension fields.
* Construct a LookupDefaultDimensionConfig instance from dimension name and only using default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
* @param physicalName The internal, physical name for the dimension.
Expand All @@ -71,7 +71,7 @@ public LookupDefaultDimensionConfig(
* @param searchProvider The search provider for field value lookups on this dimension.
* @param namespaces A list of namespaces used to configure the Lookup dimension.
*/
public LookupDefaultDimensionConfig(
public DefaultLookupDimensionConfig(
DimensionName apiName,
String physicalName,
String description,
Expand All @@ -96,6 +96,7 @@ public LookupDefaultDimensionConfig(
);
}

@Override
public List<String> getNamespaces() {
return namespaces;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@


/**
* A Registered Dimension Instance holds all of the information needed to construct a Registered Lookup Dimension.
* A Default Registered Lookup Dimension holds all of the information needed to construct a Registered Lookup Dimension.
*/
public class RegisteredLookupDefaultDimensionConfig extends DefaultDimensionConfig
public class DefaultRegisteredLookupDimensionConfig extends DefaultKeyValueStoreDimensionConfig
implements RegisteredLookupDimensionConfig {
private final List<String> lookups;

/**
* Construct a RegisteredLookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and
* Construct a RegisteredLookupDefaultDimensionConfig instance from dimension name , dimension fields and
* default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
Expand All @@ -34,12 +34,12 @@ public class RegisteredLookupDefaultDimensionConfig extends DefaultDimensionConf
* @param searchProvider The search provider for field value lookups on this dimension.
* @param lookups A list of lookups used to configure the Lookup dimension.
*/
public RegisteredLookupDefaultDimensionConfig(
public DefaultRegisteredLookupDimensionConfig(
@NotNull DimensionName apiName,
@NotNull String physicalName,
@NotNull String description,
@NotNull String longName,
@NotNull String category,
String physicalName,
String description,
String longName,
String category,
@NotNull LinkedHashSet<DimensionField> fields,
@NotNull LinkedHashSet<DimensionField> defaultDimensionFields,
@NotNull KeyValueStore keyValueStore,
Expand All @@ -61,8 +61,8 @@ public RegisteredLookupDefaultDimensionConfig(
}

/**
* Construct a RegisteredLookupDefaultDimensionConfig Instance from Dimension Name , dimension fields and
* default dimension fields.
* Construct a RegisteredLookupDefaultDimensionConfig instance from Dimension Name ,
* and only using default dimension fields.
*
* @param apiName The API Name is the external, end-user-facing name for the dimension.
* @param physicalName The internal, physical name for the dimension.
Expand All @@ -74,7 +74,7 @@ public RegisteredLookupDefaultDimensionConfig(
* @param searchProvider The search provider for field value lookups on this dimension.
* @param lookups A list of lookups used to configure the Lookup dimension.
*/
public RegisteredLookupDefaultDimensionConfig(
public DefaultRegisteredLookupDimensionConfig(
DimensionName apiName,
String physicalName,
String description,
Expand All @@ -99,6 +99,7 @@ public RegisteredLookupDefaultDimensionConfig(
);
}

@Override
public List<String> getLookups() {
return lookups;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
package com.yahoo.bard.webservice.data.config.names;

/**
* Defines the name of a Dimension.
* Defines the logical name of a Dimension as used in the api query.
*/
public interface DimensionName {

/**
* The name of this dimension.
* The logical name of this dimension as used in the api query.
*
* @return Dimension Name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.yahoo.bard.webservice.config.SystemConfig;
import com.yahoo.bard.webservice.config.SystemConfigProvider;
import com.yahoo.bard.webservice.data.config.dimension.DefaultDimensionConfig;
import com.yahoo.bard.webservice.data.config.dimension.DefaultKeyValueStoreDimensionConfig;
import com.yahoo.bard.webservice.data.config.dimension.DimensionConfig;
import com.yahoo.bard.webservice.data.dimension.DimensionField;
import com.yahoo.bard.webservice.data.dimension.KeyValueStore;
Expand All @@ -13,7 +13,7 @@
import com.yahoo.bard.webservice.data.dimension.impl.ScanSearchProviderManager;
import com.yahoo.bard.webservice.util.StreamUtils;
import com.yahoo.bard.webservice.util.Utils;
import com.yahoo.wiki.webservice.data.config.names.WikiApiDimensionName;
import com.yahoo.wiki.webservice.data.config.names.WikiApiDimensionConfigInfo;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -41,9 +41,9 @@ public class WikiDimensions {
public WikiDimensions() {

this.dimensionConfigs = Collections.unmodifiableSet(
Arrays.stream(WikiApiDimensionName.values())
Arrays.stream(WikiApiDimensionConfigInfo.values())
.map(
dimensionName -> new DefaultDimensionConfig(
dimensionName -> new DefaultKeyValueStoreDimensionConfig(
dimensionName,
dimensionName.asName(),
dimensionName.getDescription(),
Expand Down Expand Up @@ -78,9 +78,10 @@ public Set<DimensionConfig> getAllDimensionConfigurations() {
*
* @return set of dimension configurations
*/
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName(WikiApiDimensionName... dimensionNames) {
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName(
WikiApiDimensionConfigInfo... dimensionNames) {
return Arrays.stream(dimensionNames)
.map(WikiApiDimensionName::asName)
.map(WikiApiDimensionConfigInfo::asName)
.map(wikiApiDimensionNameToConfig::get)
.collect(Collectors.toCollection(LinkedHashSet<DimensionConfig>::new));
}
Expand All @@ -92,7 +93,7 @@ public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName(WikiAp
*
* @return A KeyValueStore instance
*/
private KeyValueStore getDefaultKeyValueStore(WikiApiDimensionName storeName) {
private KeyValueStore getDefaultKeyValueStore(WikiApiDimensionConfigInfo storeName) {
return MapStoreManager.getInstance(storeName.asName());
}

Expand All @@ -103,7 +104,7 @@ private KeyValueStore getDefaultKeyValueStore(WikiApiDimensionName storeName) {
*
* @return A Scanning Search Provider for the provider name.
*/
private SearchProvider getDefaultSearchProvider(WikiApiDimensionName providerName) {
private SearchProvider getDefaultSearchProvider(WikiApiDimensionConfigInfo providerName) {
return ScanSearchProviderManager.getInstance(providerName.asName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
/**
* Hold all the Wikipedia API dimension names.
*/
public enum WikiApiDimensionName implements DimensionName {
PAGE("Description of Page", "wikipedia page", "General"),
LANGUAGE("Description of Language", "wikipedia language", "General"),
USER("Description of User", "wikipedia user", "General"),
UNPATROLLED("Description of Unpatrolled", "wikipedia unpatrolled", "General"),
NEW_PAGE("Description of New page", "wikipedia newPage", "General"),
ROBOT("Description of Robot", "wikipedia robot", "General"),
ANONYMOUS("Description of Anonymous", "wikipedia anonymous", "General"),
NAMESPACE("Description of Namespace", "wikipedia namespace", "General"),
CONTINENT("Description of Continent", "wikipedia continent", "General"),
COUNTRY("Description of Country", "wikipedia country", "General"),
REGION("Description of Region", "wikipedia region", "General"),
CITY("Description of City", "wikipedia city", "General");
public enum WikiApiDimensionConfigInfo implements DimensionName {
PAGE("Page is a document that is suitable for World Wide Web and web browsers", "wiki page", "General"),
LANGUAGE("Language used to write the wiki page", "wiki language", "General"),
USER("User is a person who generally use or own wiki services", "wiki user", "General"),
UNPATROLLED("Unpatrolled are class of pages that are not been patrolled", "wiki unpatrolled", "General"),
NEW_PAGE("New Page is the first page that is created in wiki ", "wiki newPage", "General"),
ROBOT("Robot is an tool that carries out repetitive and mundane tasks", "wiki robot", "General"),
ANONYMOUS("Anonymous are individual or entity whose identity is unknown", "wiki anonymous", "General"),
NAMESPACE("Namespace is a set of wiki pages that begins with a reserved word", "wiki namespace", "General"),
CONTINENT("Continent refers to one of the seven region", "wiki continent", "General"),
COUNTRY("Country is identified as a distinct national entity in political geography", "wiki country", "General"),
REGION("Regions are areas that are broadly divided by several distinct characteristics ", "wiki region", "General"),
CITY("City is a large and permanent human settlement", "wiki city", "General");

private final String camelName;
private final String description;
Expand All @@ -34,7 +34,7 @@ public enum WikiApiDimensionName implements DimensionName {
* @param longName The Long Name is the external, end-user-facing long name for the dimension.
* @param category The Category is the external, end-user-facing category for the dimension.
*/
WikiApiDimensionName(String description, String longName, String category) {
WikiApiDimensionConfigInfo(String description, String longName, String category) {
this.camelName = EnumUtils.camelCase(name());
this.description = description;
this.longName = longName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.yahoo.bard.webservice.table.TableGroup;
import com.yahoo.bard.webservice.util.Utils;
import com.yahoo.wiki.webservice.data.config.dimension.WikiDimensions;
import com.yahoo.wiki.webservice.data.config.names.WikiApiDimensionName;
import com.yahoo.wiki.webservice.data.config.names.WikiApiDimensionConfigInfo;
import com.yahoo.wiki.webservice.data.config.names.WikiApiMetricName;
import com.yahoo.wiki.webservice.data.config.names.WikiDruidMetricName;
import com.yahoo.wiki.webservice.data.config.names.WikiDruidTableName;
Expand Down Expand Up @@ -62,7 +62,7 @@ private void configureSample(WikiDimensions wikiDimensions) {

// Dimensions
Set<DimensionConfig> dimsBasefactDruidTableName = wikiDimensions.getDimensionConfigurationsByApiName(
WikiApiDimensionName.values()
WikiApiDimensionConfigInfo.values()
);

// Physical Tables
Expand Down
Loading

0 comments on commit d2cc90e

Please sign in to comment.