Repository: kylin Updated Branches: refs/heads/master ea5df5471 -> 068694191
Rest Support Massin UDF Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/06869419 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/06869419 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/06869419 Branch: refs/heads/master Commit: 068694191855e0901874b517814b4585f3e94c6b Parents: ea5df54 Author: Jason <jiat...@163.com> Authored: Sat Mar 26 01:53:10 2016 +0800 Committer: Jason <jiat...@163.com> Committed: Sat Mar 26 01:53:10 2016 +0800 ---------------------------------------------------------------------- .../apache/kylin/metadata/MetadataManager.java | 26 ++++++++++++++++++ .../metadata/model/ExternalFilterDesc.java | 14 +++++++++- .../kylin/metadata/project/ProjectInstance.java | 15 +++++++++++ .../kylin/metadata/project/ProjectManager.java | 28 ++++++++++++++++++++ .../kylin/rest/controller/CubeController.java | 21 +++++++++++---- 5 files changed, 98 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/06869419/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java b/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java index e7b345f..faea189 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java @@ -143,6 +143,10 @@ public class MetadataManager { return Lists.newArrayList(srcTableMap.values()); } + public List<ExternalFilterDesc> listAllExternalFilters(){ + return Lists.newArrayList(extFilterMap.values()); + } + public Map<String, TableDesc> getAllTablesMap() { return Collections.unmodifiableMap(srcTableMap.getMap()); } @@ -212,6 +216,28 @@ public class MetadataManager { srcTableMap.remove(tableIdentity); } + public void saveExternalFilter(ExternalFilterDesc desc) throws IOException { + if(desc.getUuid() == null){ + throw new IllegalArgumentException("UUID not set."); + } + desc.init(); + String path = desc.getResourcePath(); + getStore().putResource(path,desc,EXTERNAL_FILTER_DESC_SERIALIZER); + extFilterMap.put(desc.getName(),desc); + + } + + public void removeExternalFilter(String name) throws IOException { + if(name !=null ){ + name = name.toLowerCase(); + } + String path = ExternalFilterDesc.concatResourcePath(name); + getStore().deleteResource(path); + extFilterMap.remove(name); + + } + + private void init(KylinConfig config) throws IOException { this.config = config; this.srcTableMap = new CaseInsensitiveStringCache<>(config, Broadcaster.TYPE.TABLE); http://git-wip-us.apache.org/repos/asf/kylin/blob/06869419/core-metadata/src/main/java/org/apache/kylin/metadata/model/ExternalFilterDesc.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ExternalFilterDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ExternalFilterDesc.java index cf53aef..0110aa0 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ExternalFilterDesc.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ExternalFilterDesc.java @@ -45,13 +45,15 @@ public class ExternalFilterDesc extends RootPersistentEntity implements ISourceA private Functions.FilterTableType filterTableType; @JsonProperty("source_type") private int sourceType = ISourceAware.ID_EXTERNAL; + @JsonProperty("description") + private String description; public String getResourcePath() { return concatResourcePath(getName()); } public static String concatResourcePath(String name) { - return ResourceStore.TABLE_EXD_RESOURCE_ROOT + "/" + name + ".json"; + return ResourceStore.EXTERNAL_FILTER_RESOURCE_ROOT + "/" + name + ".json"; } // ============================================================================ @@ -82,6 +84,8 @@ public class ExternalFilterDesc extends RootPersistentEntity implements ISourceA } public void init() { + if (name != null) + name = name.toUpperCase(); } @Override @@ -104,4 +108,12 @@ public class ExternalFilterDesc extends RootPersistentEntity implements ISourceA public void setSourceType(int sourceType) { this.sourceType = sourceType; } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } http://git-wip-us.apache.org/repos/asf/kylin/blob/06869419/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java b/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java index e0ed3d9..9567da3 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java @@ -74,6 +74,9 @@ public class ProjectInstance extends RootPersistentEntity { @JsonProperty("models") private List<String> models; + @JsonProperty("ext_filters") + private Set<String> extFilters = new TreeSet<String>(); + public String getResourcePath() { return concatResourcePath(name); } @@ -208,6 +211,10 @@ public class ProjectInstance extends RootPersistentEntity { tables.remove(tableName.toUpperCase()); } + public void removeExtFilter(String filterName) { + extFilters.remove(filterName.toUpperCase()); + } + public int getTablesCount() { return this.getTables().size(); } @@ -220,6 +227,14 @@ public class ProjectInstance extends RootPersistentEntity { return tables; } + public void addExtFilter(String extFilterName){ + this.getExtFilters().add(extFilterName.toLowerCase()); + } + + public Set<String> getExtFilters(){ + return extFilters; + } + public String getOwner() { return owner; } http://git-wip-us.apache.org/repos/asf/kylin/blob/06869419/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java b/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java index b6e99b3..c8d0793 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java @@ -32,6 +32,7 @@ import org.apache.kylin.common.restclient.Broadcaster; import org.apache.kylin.common.restclient.CaseInsensitiveStringCache; import org.apache.kylin.metadata.MetadataManager; import org.apache.kylin.metadata.model.ColumnDesc; +import org.apache.kylin.metadata.model.ExternalFilterDesc; import org.apache.kylin.metadata.model.MeasureDesc; import org.apache.kylin.metadata.model.TableDesc; import org.apache.kylin.metadata.realization.IRealization; @@ -298,6 +299,33 @@ public class ProjectManager { updateProject(projectInstance); } + public ProjectInstance addExtFilterToProject(String[] filters, String projectName) throws IOException { + MetadataManager metaMgr = getMetadataManager(); + ProjectInstance projectInstance = getProject(projectName); + for (String filterName : filters) { + ExternalFilterDesc extFilter = metaMgr.getExtFilterDesc(filterName); + if (extFilter == null) { + throw new IllegalStateException("Cannot find external filter '" + filterName + "' in metadata manager"); + } + projectInstance.addExtFilter(filterName); + } + + updateProject(projectInstance); + return projectInstance; + } + + public void removeExtFilterFromProject(String filterName, String projectName) throws IOException { + MetadataManager metaMgr = getMetadataManager(); + ProjectInstance projectInstance = getProject(projectName); + ExternalFilterDesc filter = metaMgr.getExtFilterDesc(filterName); + if (filter == null) { + throw new IllegalStateException("Cannot find external filter '" + filterName + "' in metadata manager"); + } + + projectInstance.removeExtFilter(filterName); + updateProject(projectInstance); + } + public List<ProjectInstance> findProjects(RealizationType type, String realizationName) { List<ProjectInstance> result = Lists.newArrayList(); for (ProjectInstance prj : projectMap.values()) { http://git-wip-us.apache.org/repos/asf/kylin/blob/06869419/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java index 6f8ad51..b17378c 100644 --- a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java +++ b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java @@ -20,12 +20,9 @@ package org.apache.kylin.rest.controller; import java.io.IOException; import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; +import com.google.common.collect.Sets; import org.apache.commons.lang.StringUtils; import org.apache.kylin.common.util.JsonUtil; import org.apache.kylin.cube.CubeInstance; @@ -34,6 +31,7 @@ import org.apache.kylin.cube.CubeUpdate; import org.apache.kylin.cube.model.CubeBuildTypeEnum; import org.apache.kylin.cube.model.CubeDesc; import org.apache.kylin.cube.model.CubeJoinedFlatTableDesc; +import org.apache.kylin.dimension.DimensionEncodingFactory; import org.apache.kylin.engine.streaming.StreamingConfig; import org.apache.kylin.job.JobInstance; import org.apache.kylin.job.JoinedFlatTable; @@ -98,6 +96,19 @@ public class CubeController extends BasicController { return cubeService.getCubes(cubeName, projectName, modelName, limit, offset); } + @RequestMapping(value = "validEncodings", method = { RequestMethod.GET }) + @ResponseBody + public Set<String> getValidEncodings() { + Set<String> encodings; + try { + encodings = DimensionEncodingFactory.getValidEncodings(); + }catch (Exception e){ + return Sets.newTreeSet(); + } + return encodings; + } + + @RequestMapping(value = "/{cubeName}", method = { RequestMethod.GET }) @ResponseBody public CubeInstance getCube(@PathVariable String cubeName) {