kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [02/47] incubator-kylin git commit: KYLIN-875 rename modules: core-common, core-cube, core-dictionary, core-cube
Date Wed, 22 Jul 2015 04:12:52 GMT
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
deleted file mode 100644
index 6c153ad..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.project;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.kylin.metadata.MetadataManager;
-import org.apache.kylin.metadata.model.*;
-import org.apache.kylin.metadata.realization.IRealization;
-import org.apache.kylin.metadata.realization.RealizationRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * This is a second level cache that is built on top of first level cached objects,
- * including Realization, TableDesc, ColumnDesc etc, to speed up query time metadata lookup.
- * <p/>
- * On any object update, the L2 cache simply gets wiped out because it's cheap to rebuild.
- */
-class ProjectL2Cache {
-
-    private static final Logger logger = LoggerFactory.getLogger(ProjectL2Cache.class);
-
-    private ProjectManager mgr;
-    private Map<String, ProjectCache> projectCaches = Maps.newConcurrentMap();
-
-    ProjectL2Cache(ProjectManager mgr) {
-        this.mgr = mgr;
-    }
-
-    public void clear() {
-        projectCaches.clear();
-    }
-
-    public List<TableDesc> listDefinedTables(String project) {
-        ProjectCache prjCache = getCache(project);
-        List<TableDesc> result = Lists.newArrayListWithCapacity(prjCache.tables.size());
-        for (TableCache tableCache : prjCache.tables.values()) {
-            result.add(tableCache.tableDesc);
-        }
-        return result;
-    }
-
-    public Set<TableDesc> listExposedTables(String project) {
-        ProjectCache prjCache = getCache(project);
-        return Collections.unmodifiableSet(prjCache.exposedTables);
-    }
-
-    public Set<ColumnDesc> listExposedColumns(String project, String table) {
-        TableCache tableCache = getCache(project).tables.get(table);
-        if (tableCache == null)
-            return Collections.emptySet();
-        else
-            return Collections.unmodifiableSet(tableCache.exposedColumns);
-    }
-
-    public boolean isExposedTable(String project, String table) {
-        TableCache tableCache = getCache(project).tables.get(table);
-        if (tableCache == null)
-            return false;
-        else
-            return tableCache.exposed;
-    }
-
-    public boolean isExposedColumn(String project, String table, String col) {
-        TableCache tableCache = getCache(project).tables.get(table);
-        if (tableCache == null)
-            return false;
-
-
-        for (ColumnDesc colDesc : tableCache.exposedColumns) {
-            if (colDesc.getName().equals(col))
-                return true;
-        }
-        return false;
-    }
-
-    public Set<IRealization> listAllRealizations(String project) {
-        ProjectCache prjCache = getCache(project);
-        return Collections.unmodifiableSet(prjCache.realizations);
-    }
-
-    public Set<IRealization> getRealizationsByTable(String project, String table) {
-        TableCache tableCache = getCache(project).tables.get(table);
-        if (tableCache == null)
-            return Collections.emptySet();
-        else
-            return Collections.unmodifiableSet(tableCache.realizations);
-    }
-
-    public List<IRealization> getOnlineRealizationByFactTable(String project, String factTable) {
-        Set<IRealization> realizations = getRealizationsByTable(project, factTable);
-        List<IRealization> result = Lists.newArrayListWithCapacity(realizations.size());
-        for (IRealization r : realizations) {
-            if (r.getFactTable().equalsIgnoreCase(factTable) && r.isReady()) {
-                result.add(r);
-            }
-        }
-        return result;
-    }
-
-    public List<MeasureDesc> listEffectiveRewriteMeasures(String project, String factTable) {
-        Set<IRealization> realizations = getRealizationsByTable(project, factTable);
-        List<MeasureDesc> result = Lists.newArrayList();
-        for (IRealization r : realizations) {
-            if (r.getFactTable().equalsIgnoreCase(factTable) && r.isReady()) {
-                for (MeasureDesc m : r.getMeasures()) {
-                    FunctionDesc func = m.getFunction();
-                    if (func.needRewrite())
-                        result.add(m);
-                }
-            }
-        }
-        return result;
-    }
-
-    // ============================================================================
-    // build the cache
-    // ----------------------------------------------------------------------------
-
-    private ProjectCache getCache(String project) {
-        ProjectCache result = projectCaches.get(project);
-        if (result == null) {
-            result = loadCache(project);
-            projectCaches.put(project, result);
-        }
-        return result;
-    }
-
-    private ProjectCache loadCache(String project) {
-        logger.info("Loading L2 project cache for " + project);
-        ProjectCache result = new ProjectCache(project);
-
-        ProjectInstance pi = mgr.getProject(project);
-
-        if (pi == null)
-            throw new IllegalArgumentException("Project '" + project + "' does not exist;");
-
-        MetadataManager metaMgr = mgr.getMetadataManager();
-
-        for (String tableName : pi.getTables()) {
-            TableDesc tableDesc = metaMgr.getTableDesc(tableName);
-            if (tableDesc != null) {
-                result.tables.put(tableDesc.getIdentity(), new TableCache(tableDesc));
-            } else {
-                logger.warn("Table '" + tableName + "' defined under project '" + project + "' is not found");
-            }
-        }
-
-        RealizationRegistry registry = RealizationRegistry.getInstance(mgr.getConfig());
-        for (RealizationEntry entry : pi.getRealizationEntries()) {
-            IRealization realization = registry.getRealization(entry.getType(), entry.getRealization());
-            if (realization != null) {
-                result.realizations.add(realization);
-            } else {
-                logger.warn("Realization '" + entry + "' defined under project '" + project + "' is not found");
-            }
-        }
-
-        for (IRealization realization : result.realizations) {
-            if (sanityCheck(result, realization)) {
-                mapTableToRealization(result, realization);
-                markExposedTablesAndColumns(result, realization);
-            }
-        }
-
-        return result;
-    }
-
-    // check all columns reported by realization does exists
-    private boolean sanityCheck(ProjectCache prjCache, IRealization realization) {
-        if(realization == null)
-            return false;
-
-        MetadataManager metaMgr = mgr.getMetadataManager();
-
-        List<TblColRef> allColumns = realization.getAllColumns();
-        if (allColumns == null || allColumns.isEmpty()) {
-            logger.error("Realization '" + realization.getCanonicalName() + "' does not report any columns");
-            return false;
-        }
-
-        for (TblColRef col : allColumns) {
-            TableDesc table = metaMgr.getTableDesc(col.getTable());
-            if (table == null) {
-                logger.error("Realization '" + realization.getCanonicalName() + "' reports column '" + col.getCanonicalName() + "', but its table is not found by MetadataManager");
-                return false;
-            }
-            ColumnDesc foundCol = table.findColumnByName(col.getName());
-            if (col.getColumnDesc().equals(foundCol) == false) {
-                logger.error("Realization '" + realization.getCanonicalName() + "' reports column '" + col.getCanonicalName() + "', but it is not equal to '" + foundCol + "' according to MetadataManager");
-                return false;
-            }
-
-            // auto-define table required by realization for some legacy test case
-            if (prjCache.tables.get(table.getIdentity()) == null) {
-                prjCache.tables.put(table.getIdentity(), new TableCache(table));
-                logger.warn("Realization '" + realization.getCanonicalName() + "' reports columcn '" + col.getCanonicalName() + "' whose table is not defined in project '" + prjCache.project + "'");
-            }
-        }
-
-        return true;
-    }
-
-    private void mapTableToRealization(ProjectCache prjCache, IRealization realization) {
-        for (TblColRef col : realization.getAllColumns()) {
-            TableCache tableCache = prjCache.tables.get(col.getTable());
-            tableCache.realizations.add(realization);
-        }
-    }
-
-    private void markExposedTablesAndColumns(ProjectCache prjCache, IRealization realization) {
-        if (!realization.isReady()) {
-            return;
-        }
-
-        for (TblColRef col : realization.getAllColumns()) {
-            TableCache tableCache = prjCache.tables.get(col.getTable());
-            prjCache.exposedTables.add(tableCache.tableDesc);
-            tableCache.exposed = true;
-            tableCache.exposedColumns.add(col.getColumnDesc());
-        }
-    }
-
-    private static class ProjectCache {
-        private String project;
-        private Map<String, TableCache> tables = Maps.newHashMap();
-        private Set<TableDesc> exposedTables = Sets.newHashSet();
-        private Set<IRealization> realizations = Sets.newHashSet();
-
-        ProjectCache(String project) {
-            this.project = project;
-        }
-    }
-
-    private static class TableCache {
-        private boolean exposed = false;
-        private TableDesc tableDesc;
-        private Set<ColumnDesc> exposedColumns = Sets.newLinkedHashSet();
-        private Set<IRealization> realizations = Sets.newLinkedHashSet();
-
-        TableCache(TableDesc tableDesc) {
-            this.tableDesc = tableDesc;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
deleted file mode 100644
index dd146d9..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.project;
-
-import com.google.common.collect.Lists;
-import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.persistence.JsonSerializer;
-import org.apache.kylin.common.persistence.ResourceStore;
-import org.apache.kylin.common.persistence.Serializer;
-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.MeasureDesc;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.realization.IRealization;
-import org.apache.kylin.metadata.realization.RealizationRegistry;
-import org.apache.kylin.metadata.realization.RealizationType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class ProjectManager {
-    private static final Logger logger = LoggerFactory.getLogger(ProjectManager.class);
-    private static final ConcurrentHashMap<KylinConfig, ProjectManager> CACHE = new ConcurrentHashMap<KylinConfig, ProjectManager>();
-    public static final Serializer<ProjectInstance> PROJECT_SERIALIZER = new JsonSerializer<ProjectInstance>(ProjectInstance.class);
-
-    public static ProjectManager getInstance(KylinConfig config) {
-        ProjectManager r = CACHE.get(config);
-        if (r != null) {
-            return r;
-        }
-
-        synchronized (ProjectManager.class) {
-            r = CACHE.get(config);
-            if (r != null) {
-                return r;
-            }
-            try {
-                r = new ProjectManager(config);
-                CACHE.put(config, r);
-                if (CACHE.size() > 1) {
-                    logger.warn("More than one singleton exist");
-                }
-                return r;
-            } catch (IOException e) {
-                throw new IllegalStateException("Failed to init ProjectManager from " + config, e);
-            }
-        }
-    }
-
-    public static void clearCache() {
-        CACHE.clear();
-    }
-
-    // ============================================================================
-
-    private KylinConfig config;
-    private ProjectL2Cache l2Cache;
-    // project name => ProjrectInstance
-    private CaseInsensitiveStringCache<ProjectInstance> projectMap = new CaseInsensitiveStringCache<ProjectInstance>(Broadcaster.TYPE.PROJECT);
-
-    private ProjectManager(KylinConfig config) throws IOException {
-        logger.info("Initializing ProjectManager with metadata url " + config);
-        this.config = config;
-        this.l2Cache = new ProjectL2Cache(this);
-
-        reloadAllProjects();
-    }
-
-    public void clearL2Cache() {
-        l2Cache.clear();
-    }
-
-    private void reloadAllProjects() throws IOException {
-        ResourceStore store = getStore();
-        List<String> paths = store.collectResourceRecursively(ResourceStore.PROJECT_RESOURCE_ROOT, ".json");
-
-        logger.debug("Loading Project from folder " + store.getReadableResourcePath(ResourceStore.PROJECT_RESOURCE_ROOT));
-
-        for (String path : paths) {
-            reloadProjectLocalAt(path);
-        }
-        wireProjectAndRealizations(projectMap.values());
-        logger.debug("Loaded " + projectMap.size() + " Project(s)");
-    }
-
-    public ProjectInstance reloadProjectLocal(String project) throws IOException {
-        return reloadProjectLocalAt(ProjectInstance.concatResourcePath(project));
-    }
-
-    private ProjectInstance reloadProjectLocalAt(String path) throws IOException {
-
-        ProjectInstance projectInstance = getStore().getResource(path, ProjectInstance.class, PROJECT_SERIALIZER);
-        if (projectInstance == null) {
-            logger.warn("reload project at path:" + path + " not found, this:" + this.toString());
-            return null;
-        }
-
-        projectInstance.init();
-
-        projectMap.putLocal(projectInstance.getName(), projectInstance);
-        clearL2Cache();
-
-        return projectInstance;
-    }
-
-    private void wireProjectAndRealizations(Collection<ProjectInstance> projectInstances) {
-        if (projectInstances.isEmpty())
-            return;
-
-        RealizationRegistry registry = RealizationRegistry.getInstance(config);
-        for (ProjectInstance projectInstance : projectInstances) {
-            for (RealizationEntry realization : projectInstance.getRealizationEntries()) {
-                IRealization rel = registry.getRealization(realization.getType(), realization.getRealization());
-                if (rel != null) {
-                    rel.setProjectName(projectInstance.getName());
-                } else {
-                    logger.warn("Realization '" + realization + "' defined under project '" + projectInstance + "' is not found");
-                }
-            }
-        }
-    }
-
-    public List<ProjectInstance> listAllProjects() {
-        return new ArrayList<ProjectInstance>(projectMap.values());
-    }
-
-    public ProjectInstance getProject(String projectName) {
-        projectName = norm(projectName);
-        return projectMap.get(projectName);
-    }
-
-    public ProjectInstance createProject(String projectName, String owner, String description) throws IOException {
-        logger.info("Creating project " + projectName);
-
-        ProjectInstance currentProject = getProject(projectName);
-        if (currentProject == null) {
-            currentProject = ProjectInstance.create(projectName, owner, description, null, null);
-        } else {
-            throw new IllegalStateException("The project named " + projectName + "already exists");
-        }
-
-        updateProject(currentProject);
-
-        return currentProject;
-    }
-
-    public ProjectInstance dropProject(String projectName) throws IOException {
-        if (projectName == null)
-            throw new IllegalArgumentException("Project name not given");
-
-        ProjectInstance projectInstance = getProject(projectName);
-
-        if (projectInstance == null) {
-            throw new IllegalStateException("The project named " + projectName + " does not exist");
-        }
-
-        if (projectInstance.getRealizationCount(null) != 0) {
-            throw new IllegalStateException("The project named " + projectName + " can not be deleted because there's still realizations in it. Delete them first.");
-        }
-
-        logger.info("Dropping project '" + projectInstance.getName() + "'");
-
-        removeProject(projectInstance);
-
-        return projectInstance;
-    }
-
-    //passive update due to underlying realization update
-    public void updateProject(RealizationType type, String realizationName) throws IOException {
-        for (ProjectInstance proj : findProjects(type, realizationName)) {
-            updateProject(proj);
-        }
-    }
-
-    //update project itself
-    public ProjectInstance updateProject(ProjectInstance project, String newName, String newDesc) throws IOException {
-        if (!project.getName().equals(newName)) {
-            ProjectInstance newProject = this.createProject(newName, project.getOwner(), newDesc);
-
-            newProject.setCreateTimeUTC(project.getCreateTimeUTC());
-            newProject.recordUpdateTime(System.currentTimeMillis());
-            newProject.setRealizationEntries(project.getRealizationEntries());
-            newProject.setTables(project.getTables());
-
-            removeProject(project);
-            updateProject(newProject);
-
-            return newProject;
-        } else {
-            project.setName(newName);
-            project.setDescription(newDesc);
-
-            if (project.getUuid() == null)
-                project.updateRandomUuid();
-
-            updateProject(project);
-
-            return project;
-        }
-    }
-
-    private void updateProject(ProjectInstance prj) throws IOException {
-        synchronized (prj) {
-            getStore().putResource(prj.getResourcePath(), prj, PROJECT_SERIALIZER);
-            projectMap.put(norm(prj.getName()), prj); // triggers update broadcast
-            clearL2Cache();
-        }
-    }
-
-    private void removeProject(ProjectInstance proj) throws IOException {
-        getStore().deleteResource(proj.getResourcePath());
-        projectMap.remove(norm(proj.getName()));
-        clearL2Cache();
-    }
-
-    public boolean isModelInProject(String projectName, String modelName) {
-        return this.getProject(projectName).containsModel(modelName);
-    }
-
-    public ProjectInstance updateModelToProject(String modelName, String newProjectName) throws IOException {
-        removeModelFromProjects(modelName);
-        return addModelToProject(modelName, newProjectName);
-    }
-
-    public void removeModelFromProjects(String modelName) throws IOException {
-        for (ProjectInstance projectInstance : findProjects(modelName)) {
-            projectInstance.removeModel(modelName);
-            updateProject(projectInstance);
-        }
-    }
-
-    private ProjectInstance addModelToProject(String modelName, String project) throws IOException {
-        String newProjectName = ProjectInstance.getNormalizedProjectName(project);
-        ProjectInstance newProject = getProject(newProjectName);
-        if (newProject == null) {
-            throw new IllegalArgumentException("Project " + newProjectName + " does not exist.");
-        }
-        newProject.addModel(modelName);
-        updateProject(newProject);
-
-        return newProject;
-    }
-
-    public ProjectInstance moveRealizationToProject(RealizationType type, String realizationName, String newProjectName, String owner) throws IOException {
-        removeRealizationsFromProjects(type, realizationName);
-        return addRealizationToProject(type, realizationName, newProjectName, owner);
-    }
-
-    private ProjectInstance addRealizationToProject(RealizationType type, String realizationName, String project, String user) throws IOException {
-        String newProjectName = norm(project);
-        ProjectInstance newProject = getProject(newProjectName);
-        if (newProject == null) {
-            newProject = this.createProject(newProjectName, user, "This is a project automatically added when adding realization " + realizationName + "(" + type + ")");
-        }
-        newProject.addRealizationEntry(type, realizationName);
-        updateProject(newProject);
-
-        return newProject;
-    }
-
-    public void removeRealizationsFromProjects(RealizationType type, String realizationName) throws IOException {
-        for (ProjectInstance projectInstance : findProjects(type, realizationName)) {
-            projectInstance.removeRealization(type, realizationName);
-            updateProject(projectInstance);
-        }
-    }
-
-    public ProjectInstance addTableDescToProject(String[] tableIdentities, String projectName) throws IOException {
-        MetadataManager metaMgr = getMetadataManager();
-        ProjectInstance projectInstance = getProject(projectName);
-        for (String tableId : tableIdentities) {
-            TableDesc table = metaMgr.getTableDesc(tableId);
-            if (table == null) {
-                throw new IllegalStateException("Cannot find table '" + table + "' in metadata manager");
-            }
-            projectInstance.addTable(table.getIdentity());
-        }
-
-        updateProject(projectInstance);
-        return projectInstance;
-    }
-
-    public List<ProjectInstance> findProjects(RealizationType type, String realizationName) {
-        List<ProjectInstance> result = Lists.newArrayList();
-        for (ProjectInstance prj : projectMap.values()) {
-            for (RealizationEntry entry : prj.getRealizationEntries()) {
-                if (entry.getType().equals(type) && entry.getRealization().equalsIgnoreCase(realizationName)) {
-                    result.add(prj);
-                    break;
-                }
-            }
-        }
-        return result;
-    }
-
-    private List<ProjectInstance> findProjects(String modelName) {
-        List<ProjectInstance> projects = new ArrayList<ProjectInstance>();
-        for (ProjectInstance projectInstance : projectMap.values()) {
-            if (projectInstance.containsModel(modelName)) {
-                projects.add(projectInstance);
-            }
-        }
-
-        return projects;
-    }
-
-    public List<TableDesc> listDefinedTables(String project) throws IOException {
-        return l2Cache.listDefinedTables(norm(project));
-    }
-
-    public Set<TableDesc> listExposedTables(String project) {
-        return l2Cache.listExposedTables(norm(project));
-    }
-
-    public Set<ColumnDesc> listExposedColumns(String project, String table) {
-        return l2Cache.listExposedColumns(norm(project), table);
-    }
-
-    public boolean isExposedTable(String project, String table) {
-        return l2Cache.isExposedTable(norm(project), table);
-    }
-
-    public boolean isExposedColumn(String project, String table, String col) {
-        return l2Cache.isExposedColumn(norm(project), table, col);
-    }
-
-    public Set<IRealization> listAllRealizations(String project) {
-        return l2Cache.listAllRealizations(norm(project));
-    }
-
-    public Set<IRealization> getRealizationsByTable(String project, String tableName) {
-        return l2Cache.getRealizationsByTable(norm(project), tableName.toUpperCase());
-    }
-
-    public List<IRealization> getOnlineRealizationByFactTable(String project, String factTable) {
-        return l2Cache.getOnlineRealizationByFactTable(norm(project), factTable.toUpperCase());
-    }
-
-    public List<MeasureDesc> listEffectiveRewriteMeasures(String project, String factTable) {
-        return l2Cache.listEffectiveRewriteMeasures(norm(project), factTable.toUpperCase());
-    }
-
-    KylinConfig getConfig() {
-        return config;
-    }
-
-    ResourceStore getStore() {
-        return ResourceStore.getStore(this.config);
-    }
-
-    MetadataManager getMetadataManager() {
-        return MetadataManager.getInstance(config);
-    }
-
-    private String norm(String project) {
-        return project;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectStatusEnum.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectStatusEnum.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectStatusEnum.java
deleted file mode 100644
index 25f7329..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectStatusEnum.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.project;
-
-public enum ProjectStatusEnum {
-
-    DISABLED, ENABLED
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectTable.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectTable.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectTable.java
deleted file mode 100644
index 036fcc6..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectTable.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.project;
-
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Multiset;
-import org.apache.kylin.metadata.realization.IRealization;
-
-/**
- * @author xduo
- */
-public class ProjectTable {
-
-    private final String name;
-
-    private Multiset<String> columns = HashMultiset.create();
-
-    private Multiset<IRealization> realizations = HashMultiset.create();
-
-    /**
-     * @param name
-     */
-    public ProjectTable(String name) {
-        super();
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public Multiset<String> getColumns() {
-        return columns;
-    }
-
-    public void setColumns(Multiset<String> columns) {
-        this.columns = columns;
-    }
-
-    public Multiset<IRealization> getRealizations() {
-        return realizations;
-    }
-
-    public void setRealizations(Multiset<IRealization> realizations) {
-        this.realizations = realizations;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        ProjectTable other = (ProjectTable) obj;
-        if (name == null) {
-            if (other.name != null)
-                return false;
-        } else if (!name.equalsIgnoreCase(other.name))
-            return false;
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "ProjectTable [name=" + name + ", columns=" + columns + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/project/RealizationEntry.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/RealizationEntry.java b/metadata/src/main/java/org/apache/kylin/metadata/project/RealizationEntry.java
deleted file mode 100644
index 7541d77..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/RealizationEntry.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.project;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.kylin.metadata.realization.RealizationType;
-
-/**
- */
-@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
-public class RealizationEntry {
-
-    @JsonProperty("type")
-    private RealizationType type;
-
-    @JsonProperty("realization")
-    private String realization;
-
-    public RealizationType getType() {
-        return type;
-    }
-
-    public void setType(RealizationType type) {
-        this.type = type;
-    }
-
-    public String getRealization() {
-        return realization;
-    }
-
-    public void setRealization(String realization) {
-        this.realization = realization;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        RealizationEntry entry = (RealizationEntry) o;
-
-        if (realization != null ? !realization.equalsIgnoreCase(entry.realization) : entry.realization != null)
-            return false;
-        if (type != entry.type) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = type != null ? type.hashCode() : 0;
-        result = 31 * result + (realization != null ? realization.hashCode() : 0);
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "" + type.name() + "." + realization;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealization.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealization.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealization.java
deleted file mode 100644
index ef80b39..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealization.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-import org.apache.kylin.metadata.model.DataModelDesc;
-import org.apache.kylin.metadata.model.MeasureDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-
-import java.util.List;
-
-public interface IRealization {
-
-    public boolean isCapable(SQLDigest digest);
-
-    /**
-     * Given the features of a query, return an integer indicating how capable the realization
-     * is to answer the query.
-     *
-     * @return -1 if the realization cannot fulfill the query;
-     * or a number between 0-100 if the realization can answer the query, the smaller
-     * the number, the more efficient the realization.
-     * Especially,
-     * 0 - means the realization has the exact result pre-calculated, no less no more;
-     * 100 - means the realization will scan the full table with little or no indexing.
-     */
-    public int getCost(SQLDigest digest);
-
-    /**
-     * Get whether this specific realization is a cube or InvertedIndex
-     *
-     * @return
-     */
-    public RealizationType getType();
-
-    public DataModelDesc getDataModelDesc();
-
-    public String getFactTable();
-
-    public List<TblColRef> getAllColumns();
-
-    public List<TblColRef> getAllDimensions();
-
-    public List<MeasureDesc> getMeasures();
-
-    public boolean isReady();
-
-    public String getName();
-
-    public String getCanonicalName();
-
-    public String getProjectName();
-
-    public void setProjectName(String prjName);
-
-    public long getDateRangeStart();
-
-    public long getDateRangeEnd();
-
-    public String getModelName();
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationConstants.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationConstants.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationConstants.java
deleted file mode 100644
index 0f2c012..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationConstants.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-/**
- */
-public class IRealizationConstants {
-
-    public final static String SharedHbaseStorageLocationPrefix = "KYLIN_";
-    public final static String CubeHbaseStorageLocationPrefix = "KYLIN_";
-    public final static String IIHbaseStorageLocationPrefix = "KYLIN_II_";
-
-    /**
-     * For each cube htable, we leverage htable's metadata to keep track of
-     * which kylin server(represented by its kylin_metadata prefix) owns this htable
-     */
-    public final static String HTableTag = "KYLIN_HOST";
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationProvider.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationProvider.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationProvider.java
deleted file mode 100644
index 802dfb3..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/IRealizationProvider.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-public interface IRealizationProvider {
-
-    RealizationType getRealizationType();
-
-    IRealization getRealization(String name);
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationRegistry.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationRegistry.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationRegistry.java
deleted file mode 100644
index 618dff5..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationRegistry.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-import com.google.common.collect.*;
-import org.apache.kylin.common.KylinConfig;
-
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- */
-public class RealizationRegistry {
-
-    private static final Logger logger = LoggerFactory.getLogger(RealizationRegistry.class);
-    private static final ConcurrentHashMap<KylinConfig, RealizationRegistry> CACHE = new ConcurrentHashMap<KylinConfig, RealizationRegistry>();
-
-    public static RealizationRegistry getInstance(KylinConfig config) {
-        RealizationRegistry r = CACHE.get(config);
-        if (r != null) {
-            return r;
-        }
-
-        synchronized (RealizationRegistry.class) {
-            r = CACHE.get(config);
-            if (r != null) {
-                return r;
-            }
-            try {
-                r = new RealizationRegistry(config);
-                CACHE.put(config, r);
-                return r;
-            } catch (IOException e) {
-                throw new IllegalStateException("Failed to init CubeManager from " + config, e);
-            }
-        }
-    }
-
-    public static void clearCache() {
-        CACHE.clear();
-    }
-
-    // ============================================================================
-
-    private Map<RealizationType, IRealizationProvider> providers;
-    private KylinConfig config;
-
-    private RealizationRegistry(KylinConfig config) throws IOException {
-        logger.info("Initializing RealizationRegistry with metadata url " + config);
-        this.config = config;
-        init();
-    }
-
-    private void init() {
-        providers = Maps.newConcurrentMap();
-
-        // use reflection to load providers
-        final Set<Class<? extends IRealizationProvider>> realizationProviders = new Reflections("org.apache.kylin", new SubTypesScanner()).getSubTypesOf(IRealizationProvider.class);
-        List<Throwable> es = Lists.newArrayList();
-        for (Class<? extends IRealizationProvider> cls : realizationProviders) {
-            try {
-                IRealizationProvider p = (IRealizationProvider) cls.getMethod("getInstance", KylinConfig.class).invoke(null, config);
-                providers.put(p.getRealizationType(), p);
-
-            } catch (Exception | NoClassDefFoundError e) {
-                es.add(e);
-            }
-
-            if (es.size() > 0) {
-                for (Throwable exceptionOrError : es) {
-                    logger.error("Create new store instance failed ", exceptionOrError);
-                }
-                throw new IllegalArgumentException("Failed to find metadata store by url: " + config.getMetadataUrl());
-            }
-        }
-
-        logger.info("RealizationRegistry is " + providers);
-    }
-
-    public Set<RealizationType> getRealizationTypes() {
-        return Collections.unmodifiableSet(providers.keySet());
-    }
-
-    public IRealization getRealization(RealizationType type, String name) {
-        IRealizationProvider p = providers.get(type);
-        if (p == null) {
-            logger.warn("No provider for realization type " + type);
-            return null;
-        }
-
-        try {
-            return p.getRealization(name);
-        } catch (Exception ex) {
-            // exception is possible if e.g. cube metadata is wrong
-            logger.warn("Failed to load realization " + type + ":" + name, ex);
-            return null;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationStatusEnum.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationStatusEnum.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationStatusEnum.java
deleted file mode 100644
index e4583f2..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationStatusEnum.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-public enum RealizationStatusEnum {
-
-    DISABLED, BUILDING, READY, DESCBROKEN
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationType.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationType.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationType.java
deleted file mode 100644
index 3fcfe63..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/RealizationType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-/**
- */
-
-//TODO: change to String for plugin
-public enum RealizationType {
-    CUBE, INVERTED_INDEX, HYBRID
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java
deleted file mode 100644
index 7811858..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-import java.util.Collection;
-
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.model.FunctionDesc;
-import org.apache.kylin.metadata.model.JoinDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-
-/**
- */
-public class SQLDigest {
-    public String factTable;
-    public TupleFilter filter;
-    public Collection<JoinDesc> joinDescs;
-    public Collection<TblColRef> allColumns;
-    public Collection<TblColRef> groupbyColumns;
-    public Collection<TblColRef> filterColumns;
-    public Collection<TblColRef> metricColumns;
-    public Collection<FunctionDesc> aggregations;
-
-    public SQLDigest(String factTable, TupleFilter filter, Collection<JoinDesc> joinDescs, Collection<TblColRef> allColumns, //
-            Collection<TblColRef> groupbyColumns, Collection<TblColRef> filterColumns, Collection<TblColRef> aggregatedColumns, Collection<FunctionDesc> aggregateFunnc) {
-        this.factTable = factTable;
-        this.filter = filter;
-        this.joinDescs = joinDescs;
-        this.allColumns = allColumns;
-        this.groupbyColumns = groupbyColumns;
-        this.filterColumns = filterColumns;
-        this.metricColumns = aggregatedColumns;
-        this.aggregations = aggregateFunnc;
-    }
-
-    @Override
-    public String toString() {
-        return "fact table " + this.factTable + "," + //
-                "group by " + this.groupbyColumns + "," + //
-                "filter on " + this.filterColumns + "," + //
-                "with aggregates" + this.aggregations + ".";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
deleted file mode 100644
index 19b9ee7..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.kylin.metadata.realization;
-
-import org.apache.kylin.common.util.DateFormat;
-import org.apache.kylin.metadata.filter.*;
-import org.apache.kylin.metadata.model.DataType;
-import org.apache.kylin.metadata.model.TblColRef;
-
-import com.google.common.base.Function;
-import com.google.common.collect.BoundType;
-import com.google.common.collect.Range;
-
-/**
- */
-public class SQLDigestUtil {
-
-    public static <F, T> T appendTsFilterToExecute(SQLDigest sqlDigest, TblColRef partitionColRef, Range<Long> tsRange, Function<F, T> action) {
-
-        // add the boundary condition to query real-time
-        TupleFilter originalFilter = sqlDigest.filter;
-        sqlDigest.filter = createFilterForRealtime(originalFilter, partitionColRef, tsRange);
-
-        boolean addFilterColumn = false, addAllColumn = false;
-
-        if (!sqlDigest.filterColumns.contains(partitionColRef)) {
-            sqlDigest.filterColumns.add(partitionColRef);
-            addFilterColumn = true;
-        }
-
-        if (!sqlDigest.allColumns.contains(partitionColRef)) {
-            sqlDigest.allColumns.add(partitionColRef);
-            addAllColumn = true;
-        }
-
-        T ret = action.apply(null);
-
-        // restore the sqlDigest
-        sqlDigest.filter = originalFilter;
-
-        if (addFilterColumn)
-            sqlDigest.filterColumns.remove(partitionColRef);
-
-        if (addAllColumn)
-            sqlDigest.allColumns.remove(partitionColRef);
-
-        return ret;
-    }
-
-    //ts column type differentiate
-    private static String formatTimeStr(DataType type, long ts) {
-        String ret;
-        if (type == DataType.getInstance("date")) {
-            ret = DateFormat.formatToDateStr(ts);
-        } else if (type == DataType.getInstance("long")) {
-            ret = String.valueOf(ts);
-        } else {
-            throw new IllegalArgumentException("Illegal type for partition column " + type);
-        }
-        return ret;
-    }
-
-    private static TupleFilter createFilterForRealtime(TupleFilter originFilter, TblColRef partitionColRef, Range<Long> tsRange) {
-        DataType type = partitionColRef.getColumnDesc().getType();
-
-        String startTimeStr, endTimeStr;
-        CompareTupleFilter startFilter = null, endFilter = null;
-        if (tsRange.hasLowerBound()) {
-            startTimeStr = formatTimeStr(type, tsRange.lowerEndpoint());
-            if (tsRange.lowerBoundType() == BoundType.CLOSED) {
-                startFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GTE);
-            } else {
-                startFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
-            }
-            ColumnTupleFilter columnTupleFilter = new ColumnTupleFilter(partitionColRef);
-            ConstantTupleFilter constantTupleFilter = new ConstantTupleFilter(startTimeStr);
-            startFilter.addChild(columnTupleFilter);
-            startFilter.addChild(constantTupleFilter);
-        }
-
-        if (tsRange.hasUpperBound()) {
-            endTimeStr = formatTimeStr(type, tsRange.upperEndpoint());
-            if (tsRange.upperBoundType() == BoundType.CLOSED) {
-                endFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
-            } else {
-                endFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LT);
-            }
-            ColumnTupleFilter columnTupleFilter = new ColumnTupleFilter(partitionColRef);
-            ConstantTupleFilter constantTupleFilter = new ConstantTupleFilter(endTimeStr);
-            endFilter.addChild(columnTupleFilter);
-            endFilter.addChild(constantTupleFilter);
-        }
-
-        if (originFilter == null) {
-            if (endFilter == null) {
-                return startFilter;
-            }
-            if (startFilter == null) {
-                return endFilter;
-            }
-        }
-
-        LogicalTupleFilter logicalTupleFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
-
-        if (originFilter != null) {
-            logicalTupleFilter.addChild(originFilter);
-        }
-        if (startFilter != null) {
-            logicalTupleFilter.addChild(startFilter);
-        }
-        if (endFilter != null) {
-            logicalTupleFilter.addChild(endFilter);
-        }
-
-        return logicalTupleFilter;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/realization/StreamSQLDigest.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/realization/StreamSQLDigest.java b/metadata/src/main/java/org/apache/kylin/metadata/realization/StreamSQLDigest.java
deleted file mode 100644
index 4fd9f17..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/realization/StreamSQLDigest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.kylin.metadata.realization;
-
-import java.util.Arrays;
-
-import org.apache.kylin.metadata.filter.TsConditionEraser;
-import org.apache.kylin.metadata.filter.StringCodeSystem;
-import org.apache.kylin.metadata.filter.TupleFilterSerializer;
-import org.apache.kylin.metadata.model.TblColRef;
-
-/**
- *
- * A encapsulation of {@link SQLDigest},
- * This class makes {@link SQLDigest} being able to compare with other {@link SQLDigest}
- * regardless of the timestamp conditions(In top level where conditions concatenated by ANDs)
- */
-public class StreamSQLDigest {
-
-    private final SQLDigest sqlDigest;
-
-    private final int hashCode;
-    private final byte[] filterSerialized;
-
-    public StreamSQLDigest(SQLDigest sqlDigest, TblColRef tsCol) {
-        this.sqlDigest = sqlDigest;
-
-        //must use new instance of IgnoreTsCondition
-        TsConditionEraser decorator = new TsConditionEraser(tsCol, sqlDigest.filter);
-        filterSerialized = TupleFilterSerializer.serialize(sqlDigest.filter, decorator, StringCodeSystem.INSTANCE);
-
-        int nonFilterHashCode = calculateNonFilterHashCode();
-        this.hashCode = 31 * nonFilterHashCode + (filterSerialized != null ? Arrays.hashCode(filterSerialized) : 0);
-    }
-
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        StreamSQLDigest other = (StreamSQLDigest) o;
-
-        if (filterSerialized != null ? !Arrays.equals(filterSerialized, other.filterSerialized) : other.filterSerialized != null)
-            return false;
-        if (sqlDigest.aggregations != null ? !sqlDigest.aggregations.equals(other.sqlDigest.aggregations) : other.sqlDigest.aggregations != null)
-            return false;
-        if (sqlDigest.allColumns != null ? !sqlDigest.allColumns.equals(other.sqlDigest.allColumns) : other.sqlDigest.allColumns != null)
-            return false;
-        if (sqlDigest.factTable != null ? !sqlDigest.factTable.equals(other.sqlDigest.factTable) : other.sqlDigest.factTable != null)
-            return false;
-        if (sqlDigest.filterColumns != null ? !sqlDigest.filterColumns.equals(other.sqlDigest.filterColumns) : other.sqlDigest.filterColumns != null)
-            return false;
-        if (sqlDigest.groupbyColumns != null ? !sqlDigest.groupbyColumns.equals(other.sqlDigest.groupbyColumns) : other.sqlDigest.groupbyColumns != null)
-            return false;
-        if (sqlDigest.joinDescs != null ? !sqlDigest.joinDescs.equals(other.sqlDigest.joinDescs) : other.sqlDigest.joinDescs != null)
-            return false;
-        if (sqlDigest.metricColumns != null ? !sqlDigest.metricColumns.equals(other.sqlDigest.metricColumns) : other.sqlDigest.metricColumns != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        return this.hashCode;
-    }
-
-    public int calculateNonFilterHashCode() {
-        int result = sqlDigest.factTable != null ? sqlDigest.factTable.hashCode() : 0;
-        result = 31 * result + (sqlDigest.joinDescs != null ? sqlDigest.joinDescs.hashCode() : 0);
-        result = 31 * result + (sqlDigest.allColumns != null ? sqlDigest.allColumns.hashCode() : 0);
-        result = 31 * result + (sqlDigest.groupbyColumns != null ? sqlDigest.groupbyColumns.hashCode() : 0);
-        result = 31 * result + (sqlDigest.filterColumns != null ? sqlDigest.filterColumns.hashCode() : 0);
-        result = 31 * result + (sqlDigest.metricColumns != null ? sqlDigest.metricColumns.hashCode() : 0);
-        result = 31 * result + (sqlDigest.aggregations != null ? sqlDigest.aggregations.hashCode() : 0);
-        return result;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/BigDecimalSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/BigDecimalSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/BigDecimalSerializer.java
deleted file mode 100644
index 72e3696..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/BigDecimalSerializer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.serializer;
-
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.common.util.BytesUtil;
-import org.apache.kylin.metadata.model.DataType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-
-/**
- * @author yangli9
- * 
- */
-public class BigDecimalSerializer extends DataTypeSerializer<BigDecimal> {
-
-    private static final Logger logger = LoggerFactory.getLogger(BigDecimalSerializer.class);
-    
-    final DataType type;
-    final int maxLength;
-    
-    int avoidVerbose = 0;
-    
-    public BigDecimalSerializer(DataType type) {
-        this.type = type;
-        // see serialize(): 1 byte scale, 1 byte length, assume every 2 digits takes 1 byte
-        this.maxLength = 1 + 1 + (type.getPrecision() + 1) / 2;
-    }
-
-    @Override
-    public void serialize(BigDecimal value, ByteBuffer out) {
-        if (value.scale() > type.getScale()) {
-            if (avoidVerbose % 10000 == 0) {
-                logger.warn("value's scale has exceeded the " + type.getScale() + ", cut it off, to ensure encoded value do not exceed maxLength " + maxLength + " times:" + (avoidVerbose++));
-            }
-            value = value.setScale(type.getScale(), BigDecimal.ROUND_HALF_EVEN);
-        }
-        byte[] bytes = value.unscaledValue().toByteArray();
-        if (bytes.length + 2 > maxLength) {
-            throw new IllegalArgumentException("'" + value + "' exceeds the expected length for type " + type);
-        }
-
-        BytesUtil.writeVInt(value.scale(), out);
-        BytesUtil.writeVInt(bytes.length, out);
-        out.put(bytes);
-    }
-
-    @Override
-    public BigDecimal deserialize(ByteBuffer in) {
-        int scale = BytesUtil.readVInt(in);
-        int n = BytesUtil.readVInt(in);
-
-        byte[] bytes = new byte[n];
-        in.get(bytes);
-
-        return new BigDecimal(new BigInteger(bytes), scale);
-    }
-
-
-    @Override
-    public int peekLength(ByteBuffer in) {
-        int mark = in.position();
-        
-        @SuppressWarnings("unused")
-        int scale = BytesUtil.readVInt(in);
-        int n = BytesUtil.readVInt(in);
-        int len = in.position() - mark + n;
-        
-        in.position(mark);
-        return len;
-    }
-    
-    @Override
-    public int maxLength() {
-        return maxLength;
-    }
-
-    @Override
-    public BigDecimal valueOf(byte[] value) {
-        if (value == null)
-            return new BigDecimal(0);
-        else
-            return new BigDecimal(Bytes.toString(value));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/DataTypeSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DataTypeSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/DataTypeSerializer.java
deleted file mode 100644
index 739cde4..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DataTypeSerializer.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.serializer;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-import org.apache.kylin.common.util.BytesSerializer;
-import org.apache.kylin.metadata.model.DataType;
-
-/**
- * @author yangli9
- * 
- */
-abstract public class DataTypeSerializer<T> implements BytesSerializer<T> {
-
-    final static Map<String, Class<?>> implementations;
-    static {
-        HashMap<String, Class<?>> impl = Maps.newHashMap();
-        impl.put("varchar", StringSerializer.class);
-        impl.put("decimal", BigDecimalSerializer.class);
-        impl.put("double", DoubleSerializer.class);
-        impl.put("float", DoubleSerializer.class);
-        impl.put("bigint", LongSerializer.class);
-        impl.put("long", LongSerializer.class);
-        impl.put("integer", LongSerializer.class);
-        impl.put("int", LongSerializer.class);
-        impl.put("smallint", LongSerializer.class);
-        impl.put("date", DateTimeSerializer.class);
-        impl.put("datetime", DateTimeSerializer.class);
-        impl.put("timestamp", DateTimeSerializer.class);
-        implementations = Collections.unmodifiableMap(impl);
-
-    }
-
-    public static DataTypeSerializer<?> create(String dataType) {
-        return create(DataType.getInstance(dataType));
-    }
-    
-    public static DataTypeSerializer<?> create(DataType type) {
-        if (type.isHLLC()) {
-            return new HLLCSerializer(type);
-        }
-
-        Class<?> clz = implementations.get(type.getName());
-        if (clz == null)
-            throw new RuntimeException("No MeasureSerializer for type " + type);
-
-        try {
-            return (DataTypeSerializer<?>) clz.getConstructor(DataType.class).newInstance(type);
-        } catch (Exception e) {
-            throw new RuntimeException(e); // never happen
-        }
-    }
-    
-    /** peek into buffer and return the length of serialization */
-    abstract public int peekLength(ByteBuffer in);
-    
-    /** return the max number of bytes to the longest serialization */
-    abstract public int maxLength();
-    
-    /** convert from String to obj (string often come as byte[] in mapred) */
-    abstract public T valueOf(byte[] value);
-    
-    /** convert from String to obj */
-    public T valueOf(String value) {
-        try {
-            return valueOf(value.getBytes("UTF-8"));
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e); // never happen
-        }
-    }
-
-    /** convert from obj to string */
-    public String toString(T value) {
-        if (value == null)
-            return "NULL";
-        else
-            return value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/DateTimeSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DateTimeSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/DateTimeSerializer.java
deleted file mode 100644
index 7c0fd8e..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DateTimeSerializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.apache.kylin.metadata.serializer;
-
-import java.nio.ByteBuffer;
-
-import org.apache.kylin.common.util.Bytes;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.kylin.metadata.model.DataType;
-import org.apache.kylin.common.util.DateFormat;
-
-public class DateTimeSerializer extends DataTypeSerializer<LongWritable> {
-    
-    // be thread-safe and avoid repeated obj creation
-    private ThreadLocal<LongWritable> current = new ThreadLocal<LongWritable>();
-
-    public DateTimeSerializer(DataType type) {
-    }
-
-    @Override
-    public void serialize(LongWritable value, ByteBuffer out) {
-        out.putLong(value.get());
-    }
-
-    private LongWritable current() {
-        LongWritable l = current.get();
-        if (l == null) {
-            l = new LongWritable();
-            current.set(l);
-        }
-        return l;
-    }
-    
-    @Override
-    public LongWritable deserialize(ByteBuffer in) {
-        LongWritable l = current();
-        l.set(in.getLong());
-        return l;
-    }
-
-    @Override
-    public int peekLength(ByteBuffer in) {
-        return 8;
-    }
-    
-    @Override
-    public int maxLength() {
-        return 8;
-    }
-
-    @Override
-    public LongWritable valueOf(byte[] value) {
-        LongWritable l = current();
-        if (value == null)
-            l.set(0L);
-        else
-            l.set(DateFormat.stringToMillis(Bytes.toString(value)));
-        return l;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/DoubleSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DoubleSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/DoubleSerializer.java
deleted file mode 100644
index 2a92535..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/DoubleSerializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.serializer;
-
-import java.nio.ByteBuffer;
-
-import org.apache.hadoop.io.DoubleWritable;
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.metadata.model.DataType;
-
-/**
- * @author yangli9
- * 
- */
-public class DoubleSerializer extends DataTypeSerializer<DoubleWritable> {
-
-    // be thread-safe and avoid repeated obj creation
-    private ThreadLocal<DoubleWritable> current = new ThreadLocal<DoubleWritable>();
-
-    public DoubleSerializer(DataType type) {
-    }
-
-    @Override
-    public void serialize(DoubleWritable value, ByteBuffer out) {
-        out.putDouble(value.get());
-    }
-
-    private DoubleWritable current() {
-        DoubleWritable d = current.get();
-        if (d == null) {
-            d = new DoubleWritable();
-            current.set(d);
-        }
-        return d;
-    }
-    
-    @Override
-    public DoubleWritable deserialize(ByteBuffer in) {
-        DoubleWritable d = current();
-        d.set(in.getDouble());
-        return d;
-    }
-
-    @Override
-    public int peekLength(ByteBuffer in) {
-        return 8;
-    }
-
-    @Override
-    public int maxLength() {
-        return 8;
-    }
-    
-    @Override
-    public DoubleWritable valueOf(byte[] value) {
-        DoubleWritable d = current();
-        if (value == null)
-            d.set(0d);
-        else
-            d.set(Double.parseDouble(Bytes.toString(value)));
-        return d;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/HLLCSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/HLLCSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/HLLCSerializer.java
deleted file mode 100644
index 3f923e8..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/HLLCSerializer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.serializer;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.kylin.common.hll.HyperLogLogPlusCounter;
-import org.apache.kylin.metadata.model.DataType;
-
-/**
- * @author yangli9
- * 
- */
-public class HLLCSerializer extends DataTypeSerializer<HyperLogLogPlusCounter> {
-
-    // be thread-safe and avoid repeated obj creation
-    private ThreadLocal<HyperLogLogPlusCounter> current = new ThreadLocal<HyperLogLogPlusCounter>();
-    
-    private int precision;
-
-    public HLLCSerializer(DataType type) {
-        this.precision = type.getPrecision();
-    }
-
-    @Override
-    public void serialize(HyperLogLogPlusCounter value, ByteBuffer out) {
-        try {
-            value.writeRegisters(out);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private HyperLogLogPlusCounter current() {
-        HyperLogLogPlusCounter hllc = current.get();
-        if (hllc == null) {
-            hllc = new HyperLogLogPlusCounter(precision);
-            current.set(hllc);
-        }
-        return hllc;
-    }
-    
-    @Override
-    public HyperLogLogPlusCounter deserialize(ByteBuffer in) {
-        HyperLogLogPlusCounter hllc = current();
-        try {
-            hllc.readRegisters(in);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        return hllc;
-    }
-
-    @Override
-    public int peekLength(ByteBuffer in) {
-        return current().peekLength(in);
-    }
-    
-    @Override
-    public int maxLength() {
-        return current().maxLength();
-    }
-
-    @Override
-    public HyperLogLogPlusCounter valueOf(byte[] value) {
-        HyperLogLogPlusCounter hllc = current();
-        hllc.clear();
-        if (value == null)
-            hllc.add("__nUlL__");
-        else
-            hllc.add(value);
-        return hllc;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/LongSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/LongSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/LongSerializer.java
deleted file mode 100644
index 81b4b20..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/LongSerializer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.serializer;
-
-import java.nio.ByteBuffer;
-
-import org.apache.hadoop.io.LongWritable;
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.common.util.BytesUtil;
-import org.apache.kylin.metadata.model.DataType;
-
-/**
- * @author yangli9
- * 
- */
-public class LongSerializer extends DataTypeSerializer<LongWritable> {
-
-    // be thread-safe and avoid repeated obj creation
-    private ThreadLocal<LongWritable> current = new ThreadLocal<LongWritable>();
-
-    public LongSerializer(DataType type) {
-    }
-
-    @Override
-    public void serialize(LongWritable value, ByteBuffer out) {
-        BytesUtil.writeVLong(value.get(), out);
-    }
-
-    private LongWritable current() {
-        LongWritable l = current.get();
-        if (l == null) {
-            l = new LongWritable();
-            current.set(l);
-        }
-        return l;
-    }
-    
-    @Override
-    public LongWritable deserialize(ByteBuffer in) {
-        LongWritable l = current();
-        l.set(BytesUtil.readVLong(in));
-        return l;
-    }
-
-    @Override
-    public int peekLength(ByteBuffer in) {
-        int mark = in.position();
-        
-        BytesUtil.readVLong(in);
-        int len = in.position() - mark;
-        
-        in.position(mark);
-        return len;
-    }
-    
-    @Override
-    public int maxLength() {
-        return 9; // vlong: 1 + 8
-    }
-
-    @Override
-    public LongWritable valueOf(byte[] value) {
-        LongWritable l = current();
-        if (value == null)
-            l.set(0L);
-        else
-            l.set(Long.parseLong(Bytes.toString(value)));
-        return l;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/serializer/StringSerializer.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/serializer/StringSerializer.java b/metadata/src/main/java/org/apache/kylin/metadata/serializer/StringSerializer.java
deleted file mode 100644
index 8686fb7..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/serializer/StringSerializer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.kylin.metadata.serializer;
-
-import java.nio.ByteBuffer;
-
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.common.util.BytesUtil;
-import org.apache.kylin.metadata.model.DataType;
-
-public class StringSerializer extends DataTypeSerializer<String> {
-
-    final DataType type;
-    final int maxLength;
-
-    public StringSerializer(DataType type) {
-        this.type = type;
-        // see serialize(): 2 byte length, rest is String.toBytes()
-        this.maxLength = 2 + type.getPrecision();
-    }
-
-    @Override
-    public void serialize(String value, ByteBuffer out) {
-        int start = out.position();
-
-        BytesUtil.writeUTFString(value, out);
-
-        if (out.position() - start > maxLength)
-            throw new IllegalArgumentException("'" + value + "' exceeds the expected length for type " + type);
-    }
-
-    @Override
-    public String deserialize(ByteBuffer in) {
-        return BytesUtil.readUTFString(in);
-    }
-    
-    @Override
-    public int peekLength(ByteBuffer in) {
-        return BytesUtil.peekByteArrayLength(in);
-    }
-
-    @Override
-    public int maxLength() {
-        return maxLength;
-    }
-
-    @Override
-    public String valueOf(byte[] value) {
-        return Bytes.toString(value);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/tuple/CompoundTupleIterator.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/tuple/CompoundTupleIterator.java b/metadata/src/main/java/org/apache/kylin/metadata/tuple/CompoundTupleIterator.java
deleted file mode 100644
index f5d8dd6..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/tuple/CompoundTupleIterator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.apache.kylin.metadata.tuple;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterators;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- */
-public class CompoundTupleIterator implements ITupleIterator {
-    private static final Logger logger = LoggerFactory.getLogger(CompoundTupleIterator.class);
-    private List<ITupleIterator> backends;
-    private Iterator<ITuple> compoundIterator;
-
-    public CompoundTupleIterator(List<ITupleIterator> backends) {
-        Preconditions.checkArgument(backends != null && backends.size() != 0, "backends not exists");
-        this.backends = backends;
-        this.compoundIterator = Iterators.concat(backends.iterator());
-    }
-
-    @Override
-    public void close() {
-        for (ITupleIterator i : backends) {
-            i.close();
-        }
-    }
-
-    @Override
-    public boolean hasNext() {
-        return this.compoundIterator.hasNext();
-    }
-
-    @Override
-    public ITuple next() {
-        return this.compoundIterator.next();
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/tuple/IEvaluatableTuple.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/tuple/IEvaluatableTuple.java b/metadata/src/main/java/org/apache/kylin/metadata/tuple/IEvaluatableTuple.java
deleted file mode 100644
index d5a5061..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/tuple/IEvaluatableTuple.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.kylin.metadata.tuple;
-
-import org.apache.kylin.metadata.model.TblColRef;
-
-public interface IEvaluatableTuple {
-
-    Object getValue(TblColRef col);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/7e8896ac/metadata/src/main/java/org/apache/kylin/metadata/tuple/ITuple.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/tuple/ITuple.java b/metadata/src/main/java/org/apache/kylin/metadata/tuple/ITuple.java
deleted file mode 100644
index 7d401ec..0000000
--- a/metadata/src/main/java/org/apache/kylin/metadata/tuple/ITuple.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.tuple;
-
-import java.util.List;
-
-import org.apache.kylin.metadata.model.TblColRef;
-
-/**
- * Tuple is a record row, contains multiple values being lookup by either field
- * (calcite notion) or column (kylin notion).
- * 
- * @author yangli9
- */
-public interface ITuple extends IEvaluatableTuple {
-
-    List<String> getAllFields();
-
-    List<TblColRef> getAllColumns();
-
-    Object[] getAllValues();
-
-    ITuple makeCopy();
-
-    // declared from IEvaluatableTuple:  public Object getValue(TblColRef col);
-
-}



Mime
View raw message