You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by lu...@apache.org on 2015/01/14 15:15:47 UTC

[12/51] [partial] incubator-kylin git commit: cleanup for migration from github.com

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubeDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubeDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubeDesc.java
deleted file mode 100644
index f6c638a..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubeDesc.java
+++ /dev/null
@@ -1,827 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.net.util.Base64;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.kylinolap.common.KylinConfig;
-import com.kylinolap.common.persistence.ResourceStore;
-import com.kylinolap.common.persistence.RootPersistentEntity;
-import com.kylinolap.common.util.Array;
-import com.kylinolap.common.util.JsonUtil;
-import com.kylinolap.metadata.MetadataConstances;
-import com.kylinolap.metadata.MetadataManager;
-import com.kylinolap.metadata.model.schema.ColumnDesc;
-import com.kylinolap.metadata.model.schema.DataType;
-import com.kylinolap.metadata.model.schema.TableDesc;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/24/13 Time: 10:40 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class CubeDesc extends RootPersistentEntity {
-
-    public static enum CubeCapacity {
-        SMALL, MEDIUM, LARGE;
-    }
-
-    public static enum DeriveType {
-        LOOKUP, PK_FK
-    }
-
-    public static class DeriveInfo {
-        public DeriveType type;
-        public DimensionDesc dimension;
-        public TblColRef[] columns;
-        public boolean isOneToOne; // only used when ref from derived to host
-
-        DeriveInfo(DeriveType type, DimensionDesc dimension, TblColRef[] columns, boolean isOneToOne) {
-            this.type = type;
-            this.dimension = dimension;
-            this.columns = columns;
-            this.isOneToOne = isOneToOne;
-        }
-
-        @Override
-        public String toString() {
-            return "DeriveInfo [type=" + type + ", dimension=" + dimension + ", columns=" + Arrays.toString(columns) + ", isOneToOne=" + isOneToOne + "]";
-        }
-
-    }
-
-    private KylinConfig config;
-
-    @JsonProperty("name")
-    private String name;
-    @JsonProperty("description")
-    private String description;
-    @JsonProperty("fact_table")
-    private String factTable;
-    @JsonProperty("null_string")
-    private String[] nullStrings;
-    @JsonProperty("filter_condition")
-    private String filterCondition;
-    @JsonProperty("cube_partition_desc")
-    CubePartitionDesc cubePartitionDesc;
-    @JsonProperty("dimensions")
-    private List<DimensionDesc> dimensions;
-    @JsonProperty("measures")
-    private List<MeasureDesc> measures;
-    @JsonProperty("rowkey")
-    private RowKeyDesc rowkey;
-    @JsonProperty("hbase_mapping")
-    private HBaseMappingDesc hbaseMapping;
-    @JsonProperty("signature")
-    private String signature;
-    @JsonProperty("capacity")
-    private CubeCapacity capacity = CubeCapacity.MEDIUM;
-    @JsonProperty("notify_list")
-    private List<String> notifyList;
-
-    private Map<String, Map<String, TblColRef>> columnMap = new HashMap<String, Map<String, TblColRef>>();
-    private LinkedHashSet<TblColRef> allColumns = new LinkedHashSet<TblColRef>();
-    private LinkedHashSet<TblColRef> dimensionColumns = new LinkedHashSet<TblColRef>();
-    private Map<TblColRef, DeriveInfo> derivedToHostMap = Maps.newHashMap();
-    private Map<Array<TblColRef>, List<DeriveInfo>> hostToDerivedMap = Maps.newHashMap();
-
-    /**
-     * Error messages during resolving json metadata
-     */
-    private List<String> errors = new ArrayList<String>();
-
-    /**
-     * @return all columns this cube can support, including derived
-     */
-    public Set<TblColRef> listAllColumns() {
-        return allColumns;
-    }
-
-    /**
-     * @return dimension columns including derived, BUT NOT measures
-     */
-    public Set<TblColRef> listDimensionColumnsIncludingDerived() {
-        return dimensionColumns;
-    }
-
-    /**
-     * @return dimension columns excluding derived and measures
-     */
-    public List<TblColRef> listDimensionColumnsExcludingDerived() {
-        List<TblColRef> result = new ArrayList<TblColRef>();
-        for (TblColRef col : dimensionColumns) {
-            if (isDerived(col) == false)
-                result.add(col);
-        }
-        return result;
-    }
-
-    /**
-     * Find FunctionDesc by Full Expression.
-     * 
-     * @return
-     */
-    public FunctionDesc findFunctionOnCube(FunctionDesc manualFunc) {
-        for (MeasureDesc m : measures) {
-            if (m.getFunction().equals(manualFunc))
-                return m.getFunction();
-        }
-        return null;
-    }
-
-    public TblColRef findColumnRef(String table, String column) {
-        Map<String, TblColRef> cols = columnMap.get(table);
-        if (cols == null)
-            return null;
-        else
-            return cols.get(column);
-    }
-
-    public DimensionDesc findDimensionByColumn(TblColRef col) {
-        for (DimensionDesc dim : dimensions) {
-            if (ArrayUtils.contains(dim.getColumnRefs(), col))
-                return dim;
-        }
-        return null;
-    }
-
-    public DimensionDesc findDimensionByTable(String lookupTableName) {
-        lookupTableName = lookupTableName.toUpperCase();
-        for (DimensionDesc dim : dimensions)
-            if (dim.getTable() != null && dim.getTable().equals(lookupTableName))
-                return dim;
-        return null;
-    }
-
-    public DimensionDesc findDimensionByName(String dimName) {
-        dimName = dimName.toUpperCase();
-        for (DimensionDesc dim : dimensions) {
-            if (dimName.equals(dim.getName()))
-                return dim;
-        }
-        return null;
-    }
-
-    public TblColRef findPKByFK(TblColRef fk) {
-        assert isFactTable(fk.getTable());
-
-        TblColRef candidate = null;
-
-        for (DimensionDesc dim : dimensions) {
-            JoinDesc join = dim.getJoin();
-            if (join == null)
-                continue;
-
-            int find = ArrayUtils.indexOf(join.getForeignKeyColumns(), fk);
-            if (find >= 0) {
-                candidate = join.getPrimaryKeyColumns()[find];
-                if (join.getForeignKeyColumns().length == 1) { // is single
-                                                               // column join?
-                    break;
-                }
-            }
-        }
-        return candidate;
-    }
-
-    /**
-     * Get all functions from each measure.
-     * 
-     * @return
-     */
-    public List<FunctionDesc> listAllFunctions() {
-        List<FunctionDesc> functions = new ArrayList<FunctionDesc>();
-        for (MeasureDesc m : measures) {
-            functions.add(m.getFunction());
-        }
-        return functions;
-    }
-
-    public List<TableDesc> listTables() {
-        MetadataManager metaMgr = MetadataManager.getInstance(config);
-        HashSet<String> tableNames = new HashSet<String>();
-        List<TableDesc> result = new ArrayList<TableDesc>();
-
-        tableNames.add(factTable.toUpperCase());
-        for (DimensionDesc dim : dimensions) {
-            String table = dim.getTable();
-            if (table != null)
-                tableNames.add(table.toUpperCase());
-        }
-
-        for (String tableName : tableNames) {
-            result.add(metaMgr.getTableDesc(tableName));
-        }
-
-        return result;
-    }
-
-    public boolean isFactTable(String factTable) {
-        return this.factTable.equalsIgnoreCase(factTable);
-    }
-
-    public boolean isDerived(TblColRef col) {
-        return derivedToHostMap.containsKey(col);
-    }
-
-    public DeriveInfo getHostInfo(TblColRef derived) {
-        return derivedToHostMap.get(derived);
-    }
-
-    public Map<Array<TblColRef>, List<DeriveInfo>> getHostToDerivedInfo(List<TblColRef> rowCols, Collection<TblColRef> wantedCols) {
-        Map<Array<TblColRef>, List<DeriveInfo>> result = new HashMap<Array<TblColRef>, List<DeriveInfo>>();
-        for (Entry<Array<TblColRef>, List<DeriveInfo>> entry : hostToDerivedMap.entrySet()) {
-            Array<TblColRef> hostCols = entry.getKey();
-            boolean hostOnRow = rowCols.containsAll(Arrays.asList(hostCols.data));
-            if (!hostOnRow)
-                continue;
-
-            List<DeriveInfo> wantedInfo = new ArrayList<DeriveInfo>();
-            for (DeriveInfo info : entry.getValue()) {
-                if (wantedCols == null || Collections.disjoint(wantedCols, Arrays.asList(info.columns)) == false) // has
-                                                                                                                  // any
-                                                                                                                  // wanted
-                                                                                                                  // columns?
-                    wantedInfo.add(info);
-            }
-
-            if (wantedInfo.size() > 0)
-                result.put(hostCols, wantedInfo);
-        }
-        return result;
-    }
-
-    public String getResourcePath() {
-        return getCubeDescResourcePath(name);
-    }
-
-    public static String getCubeDescResourcePath(String descName) {
-        return ResourceStore.CUBE_DESC_RESOURCE_ROOT + "/" + descName + MetadataConstances.FILE_SURFIX;
-    }
-
-    // ============================================================================
-
-    public HBaseMappingDesc getHBaseMapping() {
-        return hbaseMapping;
-    }
-
-    public void setHBaseMapping(HBaseMappingDesc hbaseMapping) {
-        this.hbaseMapping = hbaseMapping;
-    }
-
-    public KylinConfig getConfig() {
-        return config;
-    }
-
-    public void setConfig(KylinConfig config) {
-        this.config = config;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public String getFactTable() {
-        return factTable;
-    }
-
-    public void setFactTable(String factTable) {
-        this.factTable = factTable;
-    }
-
-    public String[] getNullStrings() {
-        return nullStrings;
-    }
-
-    public String getFilterCondition() {
-        return filterCondition;
-    }
-
-    public void setFilterCondition(String filterCondition) {
-        this.filterCondition = filterCondition;
-    }
-
-    public CubePartitionDesc getCubePartitionDesc() {
-        return cubePartitionDesc;
-    }
-
-    public void setCubePartitionDesc(CubePartitionDesc cubePartitionDesc) {
-        this.cubePartitionDesc = cubePartitionDesc;
-    }
-
-    public List<DimensionDesc> getDimensions() {
-        return dimensions;
-    }
-
-    public void setDimensions(List<DimensionDesc> dimensions) {
-        this.dimensions = dimensions;
-    }
-
-    public List<MeasureDesc> getMeasures() {
-        return measures;
-    }
-
-    public void setMeasures(List<MeasureDesc> measures) {
-        this.measures = measures;
-    }
-
-    public RowKeyDesc getRowkey() {
-        return rowkey;
-    }
-
-    public void setRowkey(RowKeyDesc rowkey) {
-        this.rowkey = rowkey;
-    }
-
-    public String getSignature() {
-        return signature;
-    }
-
-    public void setSignature(String signature) {
-        this.signature = signature;
-    }
-
-    public CubeCapacity getCapacity() {
-        return capacity;
-    }
-
-    public void setCapacity(CubeCapacity capacity) {
-        this.capacity = capacity;
-    }
-
-    public List<String> getNotifyList() {
-        return notifyList;
-    }
-
-    public void setNotifyList(List<String> notifyList) {
-        this.notifyList = notifyList;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        CubeDesc cubeDesc = (CubeDesc) o;
-
-        if (!name.equals(cubeDesc.name))
-            return false;
-        if (!factTable.equals(cubeDesc.factTable))
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = 0;
-        result = 31 * result + name.hashCode();
-        result = 31 * result + factTable.hashCode();
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "CubeDesc [name=" + name + ", factTable=" + factTable + ", cubePartitionDesc=" + cubePartitionDesc + ", dimensions=" + dimensions + ", measures=" + measures + ", rowkey=" + rowkey + ", hbaseMapping=" + hbaseMapping + "]";
-    }
-
-    public String calculateSignature() {
-        MessageDigest md = null;
-        try {
-            md = MessageDigest.getInstance("MD5");
-            StringBuilder sigString = new StringBuilder();
-            sigString.append(this.name).append("|").append(this.factTable).append("|").append(JsonUtil.writeValueAsString(this.cubePartitionDesc)).append("|").append(JsonUtil.writeValueAsString(this.dimensions)).append("|").append(JsonUtil.writeValueAsString(this.measures)).append("|").append(JsonUtil.writeValueAsString(this.rowkey)).append("|").append(JsonUtil.writeValueAsString(this.hbaseMapping));
-
-            byte[] signature = md.digest(sigString.toString().getBytes());
-            return new String(Base64.encodeBase64(signature));
-        } catch (NoSuchAlgorithmException e) {
-            throw new RuntimeException("Failed to calculate signature");
-        } catch (JsonProcessingException e) {
-            throw new RuntimeException("Failed to calculate signature");
-        }
-    }
-
-    public Map<String, TblColRef> buildColumnNameAbbreviation() {
-        Map<String, TblColRef> r = new HashMap<String, TblColRef>();
-        for (TblColRef col : listDimensionColumnsExcludingDerived()) {
-            r.put(col.getName(), col);
-        }
-        return r;
-    }
-
-    public void init(KylinConfig config, Map<String, TableDesc> tables) {
-        this.errors.clear();
-        this.config = config;
-
-        if (factTable != null)
-            factTable = factTable.toUpperCase();
-
-        for (DimensionDesc dim : dimensions) {
-            dim.init(tables);
-        }
-
-        sortDimAndMeasure();
-
-        initJoinColumns(tables);
-        initDimensionColumns(tables);
-        initMeasureColumns(tables);
-
-        rowkey.init(this);
-        if (hbaseMapping != null) {
-            hbaseMapping.init(this);
-        }
-
-        initMeasureReferenceToColumnFamily();
-
-        if (null != this.cubePartitionDesc) {
-            this.cubePartitionDesc.init(columnMap);
-        }
-
-        // check all dimension columns are presented on rowkey
-        List<TblColRef> dimCols = listDimensionColumnsExcludingDerived();
-        if (rowkey.getRowKeyColumns().length != dimCols.size()) {
-            addError("RowKey columns count (" + rowkey.getRowKeyColumns().length + ") does not match dimension columns count (" + dimCols.size() + "). ");
-        }
-    }
-
-    private void initDimensionColumns(Map<String, TableDesc> tables) {
-        // fill back ColRefDesc
-        for (DimensionDesc dim : dimensions) {
-            TableDesc dimTable = tables.get(dim.getTable());
-            JoinDesc join = dim.getJoin();
-
-            ArrayList<TblColRef> dimColList = new ArrayList<TblColRef>();
-            ArrayList<TblColRef> hostColList = new ArrayList<TblColRef>();
-
-            // dimension column
-            if (dim.getColumn() != null) {
-                if ("{FK}".equals(dim.getColumn())) {
-                    for (TblColRef ref : join.getForeignKeyColumns()) {
-                        TblColRef inited = initDimensionColRef(ref);
-                        dimColList.add(inited);
-                        hostColList.add(inited);
-                    }
-                } else {
-                    TblColRef ref = initDimensionColRef(dimTable, dim.getColumn());
-                    dimColList.add(ref);
-                    hostColList.add(ref);
-                }
-            }
-            // hierarchy columns
-            if (dim.getHierarchy() != null) {
-                for (HierarchyDesc hier : dim.getHierarchy()) {
-                    TblColRef ref = initDimensionColRef(dimTable, hier.getColumn());
-                    hier.setColumnRef(ref);
-                    dimColList.add(ref);
-                }
-                if (hostColList.isEmpty()) { // the last hierarchy could serve
-                                             // as host when col is
-                                             // unspecified
-                    hostColList.add(dimColList.get(dimColList.size() - 1));
-                }
-            }
-            TblColRef[] dimCols = (TblColRef[]) dimColList.toArray(new TblColRef[dimColList.size()]);
-            dim.setColumnRefs(dimCols);
-
-            // lookup derived columns
-            TblColRef[] hostCols = (TblColRef[]) hostColList.toArray(new TblColRef[hostColList.size()]);
-            String[] derived = dim.getDerived();
-            if (derived != null) {
-                String[][] split = splitDerivedColumnAndExtra(derived);
-                String[] derivedNames = split[0];
-                String[] derivedExtra = split[1];
-                TblColRef[] derivedCols = new TblColRef[derivedNames.length];
-                for (int i = 0; i < derivedNames.length; i++) {
-                    derivedCols[i] = initDimensionColRef(dimTable, derivedNames[i]);
-                }
-                initDerivedMap(hostCols, DeriveType.LOOKUP, dim, derivedCols, derivedExtra);
-            }
-
-            // FK derived column
-            if (join != null) {
-                TblColRef[] fk = join.getForeignKeyColumns();
-                TblColRef[] pk = join.getPrimaryKeyColumns();
-                for (int i = 0; i < fk.length; i++) {
-                    int find = ArrayUtils.indexOf(hostCols, fk[i]);
-                    if (find >= 0) {
-                        TblColRef derivedCol = initDimensionColRef(pk[i]);
-                        initDerivedMap(hostCols[find], DeriveType.PK_FK, dim, derivedCol);
-                    }
-                }
-                for (int i = 0; i < pk.length; i++) {
-                    int find = ArrayUtils.indexOf(hostCols, pk[i]);
-                    if (find >= 0) {
-                        TblColRef derivedCol = initDimensionColRef(fk[i]);
-                        initDerivedMap(hostCols[find], DeriveType.PK_FK, dim, derivedCol);
-                    }
-                }
-            }
-        }
-    }
-
-    private String[][] splitDerivedColumnAndExtra(String[] derived) {
-        String[] cols = new String[derived.length];
-        String[] extra = new String[derived.length];
-        for (int i = 0; i < derived.length; i++) {
-            String str = derived[i];
-            int cut = str.indexOf(":");
-            if (cut >= 0) {
-                cols[i] = str.substring(0, cut);
-                extra[i] = str.substring(cut + 1).trim();
-            } else {
-                cols[i] = str;
-                extra[i] = "";
-            }
-        }
-        return new String[][] { cols, extra };
-    }
-
-    private void initDerivedMap(TblColRef hostCol, DeriveType type, DimensionDesc dimension, TblColRef derivedCol) {
-        initDerivedMap(new TblColRef[] { hostCol }, type, dimension, new TblColRef[] { derivedCol }, null);
-    }
-
-    private void initDerivedMap(TblColRef[] hostCols, DeriveType type, DimensionDesc dimension, TblColRef[] derivedCols, String[] extra) {
-        if (hostCols.length == 0 || derivedCols.length == 0)
-            throw new IllegalStateException("host/derived columns must not be empty");
-
-        Array<TblColRef> hostColArray = new Array<TblColRef>(hostCols);
-        List<DeriveInfo> infoList = hostToDerivedMap.get(hostColArray);
-        if (infoList == null) {
-            hostToDerivedMap.put(hostColArray, infoList = new ArrayList<DeriveInfo>());
-        }
-        infoList.add(new DeriveInfo(type, dimension, derivedCols, false));
-
-        for (int i = 0; i < derivedCols.length; i++) {
-            TblColRef derivedCol = derivedCols[i];
-            boolean isOneToOne = type == DeriveType.PK_FK || ArrayUtils.contains(hostCols, derivedCol) || (extra != null && extra[i].contains("1-1"));
-            derivedToHostMap.put(derivedCol, new DeriveInfo(type, dimension, hostCols, isOneToOne));
-        }
-    }
-
-    private TblColRef initDimensionColRef(TableDesc table, String colName) {
-        ColumnDesc col = table.findColumnByName(colName);
-        if (col == null)
-            throw new IllegalArgumentException("No column '" + colName + "' found in table " + table);
-
-        TblColRef ref = new TblColRef(col);
-        return initDimensionColRef(ref);
-    }
-
-    private TblColRef initDimensionColRef(TblColRef ref) {
-        TblColRef existing = findColumnRef(ref.getTable(), ref.getName());
-        if (existing != null) {
-            return existing;
-        }
-
-        allColumns.add(ref);
-        dimensionColumns.add(ref);
-
-        Map<String, TblColRef> cols = columnMap.get(ref.getTable());
-        if (cols == null) {
-            columnMap.put(ref.getTable(), cols = new HashMap<String, TblColRef>());
-        }
-        cols.put(ref.getName(), ref);
-        return ref;
-    }
-
-    private void initJoinColumns(Map<String, TableDesc> tables) {
-        // join columns may or may not present in cube;
-        // here we don't modify 'allColumns' and 'dimensionColumns';
-        // initDimensionColumns() will do the update
-        for (DimensionDesc dim : dimensions) {
-            TableDesc dimTable = tables.get(dim.getTable());
-
-            JoinDesc join = dim.getJoin();
-            if (join == null)
-                continue;
-
-            // primary key
-            String[] pks = join.getPrimaryKey();
-            TblColRef[] pkCols = new TblColRef[pks.length];
-            for (int i = 0; i < pks.length; i++) {
-                ColumnDesc col = dimTable.findColumnByName(pks[i]);
-                if (col == null) {
-                    addError("Can't find column " + pks[i] + " in table " + dimTable.getName());
-                }
-                TblColRef colRef = new TblColRef(col);
-                pks[i] = colRef.getName();
-                pkCols[i] = colRef;
-            }
-            join.setPrimaryKeyColumns(pkCols);
-            // foreign key
-            TableDesc factTable = tables.get(this.factTable);
-            if (factTable == null) {
-                addError("Fact table does not exist:" + this.factTable);
-            }
-            String[] fks = join.getForeignKey();
-            TblColRef[] fkCols = new TblColRef[fks.length];
-            for (int i = 0; i < fks.length; i++) {
-                ColumnDesc col = factTable.findColumnByName(fks[i]);
-                if (col == null) {
-                    addError("Can't find column " + fks[i] + " in table " + this.factTable);
-                }
-                TblColRef colRef = new TblColRef(col);
-                fks[i] = colRef.getName();
-                fkCols[i] = colRef;
-            }
-            join.setForeignKeyColumns(fkCols);
-            // Validate join in dimension
-            if (pkCols.length != fkCols.length) {
-                addError("Primary keys(" + dim.getTable() + ")" + Arrays.toString(pks) + " are not consistent with Foreign keys(" + this.factTable + ") " + Arrays.toString(fks));
-            }
-            for (int i = 0; i < fkCols.length; i++) {
-                if (!fkCols[i].getDatatype().equals(pkCols[i].getDatatype())) {
-                    addError("Primary key " + dim.getTable() + "." + pkCols[i].getName() + "." + pkCols[i].getDatatype() + " are not consistent with Foreign key " + this.factTable + "." + fkCols[i].getName() + "." + fkCols[i].getDatatype());
-                }
-            }
-
-        }
-    }
-
-    private void initMeasureColumns(Map<String, TableDesc> tables) {
-        if (measures == null || measures.isEmpty()) {
-            return;
-        }
-
-        TableDesc factTable = tables.get(getFactTable());
-        for (MeasureDesc m : measures) {
-            m.setName(m.getName().toUpperCase());
-
-            if (m.getDependentMeasureRef() != null) {
-                m.setDependentMeasureRef(m.getDependentMeasureRef().toUpperCase());
-            }
-
-            FunctionDesc f = m.getFunction();
-            f.setExpression(f.getExpression().toUpperCase());
-            f.setReturnDataType(DataType.getInstance(f.getReturnType()));
-
-            ParameterDesc p = f.getParameter();
-            p.normalizeColumnValue();
-
-            if (p.isColumnType()) {
-                ArrayList<TblColRef> colRefs = Lists.newArrayList();
-                for (String cName : p.getValue().split("\\s*,\\s*")) {
-                    ColumnDesc sourceColumn = factTable.findColumnByName(cName);
-                    TblColRef colRef = new TblColRef(sourceColumn);
-                    colRefs.add(colRef);
-                    allColumns.add(colRef);
-                }
-                if (colRefs.isEmpty() == false)
-                    p.setColRefs(colRefs);
-            }
-        }
-    }
-
-    private void initMeasureReferenceToColumnFamily() {
-        if (measures == null || measures.size() == 0)
-            return;
-
-        Map<String, MeasureDesc> measureCache = new HashMap<String, MeasureDesc>();
-        for (MeasureDesc m : measures)
-            measureCache.put(m.getName(), m);
-
-        for (HBaseColumnFamilyDesc cf : getHBaseMapping().getColumnFamily()) {
-            for (HBaseColumnDesc c : cf.getColumns()) {
-                MeasureDesc[] measureDescs = new MeasureDesc[c.getMeasureRefs().length];
-                for (int i = 0; i < c.getMeasureRefs().length; i++) {
-                    measureDescs[i] = measureCache.get(c.getMeasureRefs()[i]);
-                }
-                c.setMeasures(measureDescs);
-                c.setColumnFamilyName(cf.getName());
-            }
-        }
-    }
-
-    private void sortDimAndMeasure() {
-        sortDimensionsByID();
-        sortMeasuresByID();
-        for (DimensionDesc dim : dimensions) {
-            sortHierarchiesByLevel(dim.getHierarchy());
-        }
-    }
-
-    private void sortDimensionsByID() {
-        Collections.sort(dimensions, new Comparator<DimensionDesc>() {
-            @Override
-            public int compare(DimensionDesc d1, DimensionDesc d2) {
-                Integer id1 = d1.getId();
-                Integer id2 = d2.getId();
-                return id1.compareTo(id2);
-            }
-        });
-    }
-
-    private void sortMeasuresByID() {
-        if (measures == null) {
-            measures = Lists.newArrayList();
-        }
-
-        Collections.sort(measures, new Comparator<MeasureDesc>() {
-            @Override
-            public int compare(MeasureDesc m1, MeasureDesc m2) {
-                Integer id1 = m1.getId();
-                Integer id2 = m2.getId();
-                return id1.compareTo(id2);
-            }
-        });
-    }
-
-    private void sortHierarchiesByLevel(HierarchyDesc[] hierarchies) {
-        if (hierarchies != null) {
-            Arrays.sort(hierarchies, new Comparator<HierarchyDesc>() {
-                @Override
-                public int compare(HierarchyDesc h1, HierarchyDesc h2) {
-                    Integer level1 = Integer.parseInt(h1.getLevel());
-                    Integer level2 = Integer.parseInt(h2.getLevel());
-                    return level1.compareTo(level2);
-                }
-            });
-        }
-    }
-
-    public boolean hasHolisticCountDistinctMeasures() {
-        for (MeasureDesc measure : measures) {
-            if (measure.getFunction().isHolisticCountDistinct()) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Add error info and thrown exception out
-     * 
-     * @param message
-     */
-    public void addError(String message) {
-        addError(message, false);
-    }
-
-    /**
-     * @param message
-     *            error message
-     * @param silent
-     *            if throw exception
-     */
-    public void addError(String message, boolean silent) {
-        if (!silent) {
-            throw new IllegalStateException(message);
-        } else {
-            this.errors.add(message);
-        }
-    }
-
-    public List<String> getError() {
-        return this.errors;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubePartitionDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubePartitionDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubePartitionDesc.java
deleted file mode 100644
index 270370f..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/CubePartitionDesc.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * @author xduo
- * 
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class CubePartitionDesc {
-
-    public static enum CubePartitionType {
-        APPEND, UPDATE_INSERT
-    }
-
-    @JsonProperty("partition_date_column")
-    private String partitionDateColumn;
-    @JsonProperty("partition_date_start")
-    private long partitionDateStart = 0L;
-    @JsonProperty("cube_partition_type")
-    private CubePartitionType cubePartitionType = CubePartitionType.APPEND;
-
-    private TblColRef partitionDateColumnRef;
-
-    public void init(Map<String, Map<String, TblColRef>> columnMap) {
-        if (null != partitionDateColumn) {
-            String[] columns = partitionDateColumn.split("\\.");
-
-            if (null != columns && columns.length == 2) {
-                Map<String, TblColRef> cols = columnMap.get(columns[0].toUpperCase());
-                if (cols != null)
-                    partitionDateColumnRef = cols.get(columns[1].toUpperCase());
-
-            }
-        }
-    }
-
-    public String getPartitionDateColumn() {
-        return partitionDateColumn;
-    }
-
-    public void setPartitionDateColumn(String partitionDateColumn) {
-        this.partitionDateColumn = partitionDateColumn;
-    }
-
-    public long getPartitionDateStart() {
-        return partitionDateStart;
-    }
-
-    public void setPartitionDateStart(long partitionDateStart) {
-        this.partitionDateStart = partitionDateStart;
-    }
-
-    public CubePartitionType getCubePartitionType() {
-        return cubePartitionType;
-    }
-
-    public void setCubePartitionType(CubePartitionType cubePartitionType) {
-        this.cubePartitionType = cubePartitionType;
-    }
-
-    public TblColRef getPartitionDateColumnRef() {
-        return partitionDateColumnRef;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/DimensionDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/DimensionDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/DimensionDesc.java
deleted file mode 100644
index 142fc27..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/DimensionDesc.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Arrays;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.kylinolap.common.util.StringUtil;
-import com.kylinolap.metadata.model.schema.TableDesc;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/24/13 Time: 10:40 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class DimensionDesc {
-
-    @JsonProperty("id")
-    private int id;
-    @JsonProperty("name")
-    private String name;
-    @JsonProperty("join")
-    private JoinDesc join;
-    @JsonProperty("hierarchy")
-    private HierarchyDesc[] hierarchy;
-    @JsonProperty("table")
-    private String table;
-    @JsonProperty("column")
-    private String column;
-    @JsonProperty("datatype")
-    private String datatype;
-    @JsonProperty("derived")
-    private String[] derived;
-
-    // computed
-    private TblColRef[] columnRefs;
-    private TblColRef[] derivedColRefs;
-
-    public boolean isHierarchyColumn(TblColRef col) {
-        if (hierarchy == null)
-            return false;
-
-        for (HierarchyDesc hier : hierarchy) {
-            if (hier.getColumnRef().equals(col))
-                return true;
-        }
-        return false;
-    }
-
-    public String getDatatype() {
-        return datatype;
-    }
-
-    public void setDatatype(String datatype) {
-        this.datatype = datatype;
-    }
-
-    public String getTable() {
-        return table.toUpperCase();
-    }
-
-    public void setTable(String table) {
-        this.table = table;
-    }
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public JoinDesc getJoin() {
-        return join;
-    }
-
-    public void setJoin(JoinDesc join) {
-        this.join = join;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public TblColRef[] getColumnRefs() {
-        return this.columnRefs;
-    }
-
-    public void setColumnRefs(TblColRef[] colRefs) {
-        this.columnRefs = colRefs;
-    }
-
-    public String getColumn() {
-        return this.column;
-    }
-
-    public void setColumn(String column) {
-        this.column = column;
-        if (this.column != null)
-            this.column = this.column.toUpperCase();
-    }
-
-    public HierarchyDesc[] getHierarchy() {
-        return hierarchy;
-    }
-
-    public void setHierarchy(HierarchyDesc[] hierarchy) {
-        this.hierarchy = hierarchy;
-    }
-
-    public String[] getDerived() {
-        return derived;
-    }
-
-    public void setDerived(String[] derived) {
-        this.derived = derived;
-    }
-
-    public TblColRef[] getDerivedColRefs() {
-        return derivedColRefs;
-    }
-
-    public void setDerivedColRefs(TblColRef[] derivedColRefs) {
-        this.derivedColRefs = derivedColRefs;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        DimensionDesc that = (DimensionDesc) o;
-
-        if (id != that.id)
-            return false;
-        if (!name.equals(that.name))
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = id;
-        result = 31 * result + name.hashCode();
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "DimensionDesc [name=" + name + ", join=" + join + ", hierarchy=" + Arrays.toString(hierarchy) + ", table=" + table + ", column=" + column + ", datatype=" + datatype + ", derived=" + Arrays.toString(derived) + "]";
-    }
-
-    public void init(Map<String, TableDesc> tables) {
-        if (name != null)
-            name = name.toUpperCase();
-        if (table != null)
-            table = table.toUpperCase();
-        if (column != null)
-            column = column.toUpperCase();
-
-        TableDesc tableDesc = tables.get(table);
-        if (tableDesc == null)
-            throw new IllegalStateException("Can't find table " + table + " on dimension " + name);
-
-        if (hierarchy != null && hierarchy.length == 0)
-            hierarchy = null;
-        if (derived != null && derived.length == 0)
-            derived = null;
-
-        if (join != null) {
-            StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey());
-            StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey());
-        }
-
-        if (hierarchy != null) {
-            for (HierarchyDesc h : hierarchy)
-                h.setColumn(h.getColumn().toUpperCase());
-        }
-
-        if (derived != null) {
-            StringUtil.toUpperCaseArray(derived, derived);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/FunctionDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/FunctionDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/FunctionDesc.java
deleted file mode 100644
index 6b3f92f..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/FunctionDesc.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.kylinolap.metadata.model.schema.DataType;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/26/13 Time: 1:30 PM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class FunctionDesc {
-
-    public static final String FUNC_SUM = "SUM";
-    public static final String FUNC_MIN = "MIN";
-    public static final String FUNC_MAX = "MAX";
-    public static final String FUNC_COUNT = "COUNT";
-    public static final String FUNC_COUNT_DISTINCT = "COUNT_DISTINCT";
-
-    public static final String PARAMTER_TYPE_CONSTANT = "constant";
-    public static final String PARAMETER_TYPE_COLUMN = "column";
-
-    @JsonProperty("expression")
-    private String expression;
-    @JsonProperty("parameter")
-    private ParameterDesc parameter;
-    @JsonProperty("returntype")
-    private String returnType;
-
-    private DataType returnDataType;
-    private boolean isAppliedOnDimension = false;
-
-    public String getRewriteFieldName() {
-        if (isSum()) {
-            return getParameter().getValue();
-        } else if (isCount()) {
-            return "COUNT__"; // ignores parameter, count(*), count(1),
-                              // count(col) are all the same
-        } else {
-            return getFullExpression().replaceAll("[(), ]", "_");
-        }
-    }
-
-    public boolean needRewrite() {
-        return !isSum() && !isHolisticCountDistinct() && !isAppliedOnDimension();
-    }
-
-    public boolean isMin() {
-        return FUNC_MIN.equalsIgnoreCase(expression);
-    }
-
-    public boolean isMax() {
-        return FUNC_MAX.equalsIgnoreCase(expression);
-    }
-
-    public boolean isSum() {
-        return FUNC_SUM.equalsIgnoreCase(expression);
-    }
-
-    public boolean isCount() {
-        return FUNC_COUNT.equalsIgnoreCase(expression);
-    }
-
-    public boolean isCountDistinct() {
-        return FUNC_COUNT_DISTINCT.equalsIgnoreCase(expression);
-    }
-
-    public boolean isHolisticCountDistinct() {
-        if (isCountDistinct() && returnDataType != null && returnDataType.isBigInt()) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Get Full Expression such as sum(amount), count(1), count(*)...
-     */
-    public String getFullExpression() {
-        StringBuilder sb = new StringBuilder(expression);
-        sb.append("(");
-        if (parameter != null) {
-            sb.append(parameter.getValue());
-        }
-        sb.append(")");
-        return sb.toString();
-    }
-
-    public boolean isAppliedOnDimension() {
-        return isAppliedOnDimension;
-    }
-
-    public void setAppliedOnDimension(boolean isAppliedOnDimension) {
-        this.isAppliedOnDimension = isAppliedOnDimension;
-    }
-
-    public String getExpression() {
-        return expression;
-    }
-
-    public void setExpression(String expression) {
-        this.expression = expression;
-    }
-
-    public ParameterDesc getParameter() {
-        return parameter;
-    }
-
-    public void setParameter(ParameterDesc parameter) {
-        this.parameter = parameter;
-    }
-
-    public DataType getReturnDataType() {
-        return returnDataType;
-    }
-
-    void setReturnDataType(DataType returnDataType) {
-        this.returnDataType = returnDataType;
-    }
-
-    public String getSQLType() {
-        if (isCountDistinct())
-            return "any";
-        else if (isSum() || isMax() || isMin())
-            return parameter.getColRefs().get(0).getType().getName();
-        else
-            return returnType;
-    }
-
-    public String getReturnType() {
-        return returnType;
-    }
-
-    public void setReturnType(String returnType) {
-        this.returnType = returnType;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((expression == null) ? 0 : expression.hashCode());
-        result = prime * result + ((parameter == null) ? 0 : parameter.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;
-        FunctionDesc other = (FunctionDesc) obj;
-        if (expression == null) {
-            if (other.expression != null)
-                return false;
-        } else if (!expression.equals(other.expression))
-            return false;
-        // NOTE: don't check the parameter of count()
-        if (isCount() == false) {
-            if (parameter == null) {
-                if (other.parameter != null)
-                    return false;
-            } else if (!parameter.equals(other.parameter))
-                return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "FunctionDesc [expression=" + expression + ", parameter=" + parameter + ", returnType=" + returnType + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnDesc.java
deleted file mode 100644
index 5f80eb7..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnDesc.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/30/13 Time: 10:57 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class HBaseColumnDesc {
-
-    @JsonProperty("qualifier")
-    private String qualifier;
-    @JsonProperty("measure_refs")
-    private String[] measureRefs;
-
-    // these two will be assemble in runtime.
-    private MeasureDesc[] measures;
-    private String columnFamilyName;
-
-    public String getQualifier() {
-        return qualifier;
-    }
-
-    public void setQualifier(String qualifier) {
-        this.qualifier = qualifier;
-    }
-
-    public String[] getMeasureRefs() {
-        return measureRefs;
-    }
-
-    public void setMeasureRefs(String[] measureRefs) {
-        this.measureRefs = measureRefs;
-    }
-
-    public MeasureDesc[] getMeasures() {
-        return measures;
-    }
-
-    public int findMeasureIndex(FunctionDesc function) {
-        for (int i = 0; i < measures.length; i++) {
-            if (measures[i].getFunction().equals(function)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    public void setMeasures(MeasureDesc[] measures) {
-        this.measures = measures;
-    }
-
-    public String getColumnFamilyName() {
-        return columnFamilyName;
-    }
-
-    public void setColumnFamilyName(String columnFamilyName) {
-        this.columnFamilyName = columnFamilyName;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((columnFamilyName == null) ? 0 : columnFamilyName.hashCode());
-        result = prime * result + ((qualifier == null) ? 0 : qualifier.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;
-        HBaseColumnDesc other = (HBaseColumnDesc) obj;
-        if (columnFamilyName == null) {
-            if (other.columnFamilyName != null)
-                return false;
-        } else if (!columnFamilyName.equals(other.columnFamilyName))
-            return false;
-        if (qualifier == null) {
-            if (other.qualifier != null)
-                return false;
-        } else if (!qualifier.equals(other.qualifier))
-            return false;
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "HBaseColumnDesc [qualifier=" + qualifier + ", measureRefs=" + Arrays.toString(measureRefs) + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnFamilyDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnFamilyDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnFamilyDesc.java
deleted file mode 100644
index 4560ec9..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseColumnFamilyDesc.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/30/13 Time: 10:41 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class HBaseColumnFamilyDesc {
-
-    @JsonProperty("name")
-    private String name;
-    @JsonProperty("columns")
-    private HBaseColumnDesc[] columns;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public HBaseColumnDesc[] getColumns() {
-        return columns;
-    }
-
-    public void setColumns(HBaseColumnDesc[] columns) {
-        this.columns = columns;
-    }
-
-    @Override
-    public String toString() {
-        return "HBaseColumnFamilyDesc [name=" + name + ", columns=" + Arrays.toString(columns) + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseMappingDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseMappingDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseMappingDesc.java
deleted file mode 100644
index 69488c5..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HBaseMappingDesc.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.kylinolap.common.util.StringUtil;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/24/13 Time: 10:44 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class HBaseMappingDesc {
-
-    @JsonProperty("column_family")
-    private HBaseColumnFamilyDesc[] columnFamily;
-
-    // point to the cube instance which contain this HBaseMappingDesc instance.
-    private CubeDesc cubeRef;
-
-    public Collection<HBaseColumnDesc> findHBaseColumnByFunction(FunctionDesc function) {
-        Collection<HBaseColumnDesc> result = new LinkedList<HBaseColumnDesc>();
-        HBaseMappingDesc hbaseMapping = cubeRef.getHBaseMapping();
-        if (hbaseMapping == null || hbaseMapping.getColumnFamily() == null) {
-            return result;
-        }
-        for (HBaseColumnFamilyDesc cf : hbaseMapping.getColumnFamily()) {
-            for (HBaseColumnDesc c : cf.getColumns()) {
-                for (MeasureDesc m : c.getMeasures()) {
-                    if (m.getFunction().equals(function)) {
-                        result.add(c);
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
-    public CubeDesc getCubeRef() {
-        return cubeRef;
-    }
-
-    public void setCubeRef(CubeDesc cubeRef) {
-        this.cubeRef = cubeRef;
-    }
-
-    public HBaseColumnFamilyDesc[] getColumnFamily() {
-        return columnFamily;
-    }
-
-    public void setColumnFamily(HBaseColumnFamilyDesc[] columnFamily) {
-        this.columnFamily = columnFamily;
-    }
-
-    public void init(CubeDesc cubeDesc) {
-        cubeRef = cubeDesc;
-
-        for (HBaseColumnFamilyDesc cf : columnFamily) {
-            cf.setName(cf.getName().toUpperCase());
-
-            for (HBaseColumnDesc c : cf.getColumns()) {
-                c.setQualifier(c.getQualifier().toUpperCase());
-                StringUtil.toUpperCaseArray(c.getMeasureRefs(), c.getMeasureRefs());
-            }
-        }
-    }
-
-    @Override
-    public String toString() {
-        return "HBaseMappingDesc [columnFamily=" + Arrays.toString(columnFamily) + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/HierarchyDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HierarchyDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/HierarchyDesc.java
deleted file mode 100644
index 37af9d9..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/HierarchyDesc.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/24/13 Time: 10:46 AM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class HierarchyDesc {
-
-    @JsonProperty("level")
-    private String level;
-    @JsonProperty("column")
-    private String column;
-
-    private TblColRef columnRef;
-
-    public String getLevel() {
-        return level;
-    }
-
-    public void setLevel(String level) {
-        this.level = level;
-    }
-
-    public TblColRef getColumnRef() {
-        return columnRef;
-    }
-
-    public void setColumnRef(TblColRef column) {
-        this.columnRef = column;
-    }
-
-    public String getColumn() {
-        return column;
-    }
-
-    public void setColumn(String columnName) {
-        this.column = columnName;
-    }
-
-    @Override
-    public String toString() {
-        return "HierarchyDesc [level=" + level + ", column=" + column + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/JoinDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/JoinDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/JoinDesc.java
deleted file mode 100644
index 44ce795..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/JoinDesc.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 10/14/13 Time: 2:16 PM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class JoinDesc {
-
-    // inner, left, right, outer...
-    @JsonProperty("type")
-    private String type;
-    @JsonProperty("primary_key")
-    private String[] primaryKey;
-    @JsonProperty("foreign_key")
-    private String[] foreignKey;
-
-    private TblColRef[] primaryKeyColumns;
-    private TblColRef[] foreignKeyColumns;
-
-    public void swapPKFK() {
-        String[] t = primaryKey;
-        primaryKey = foreignKey;
-        foreignKey = t;
-
-        TblColRef[] tt = primaryKeyColumns;
-        primaryKeyColumns = foreignKeyColumns;
-        foreignKeyColumns = tt;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String[] getPrimaryKey() {
-        return primaryKey;
-    }
-
-    public void setPrimaryKey(String[] primaryKey) {
-        this.primaryKey = primaryKey;
-    }
-
-    public String[] getForeignKey() {
-        return foreignKey;
-    }
-
-    public void setForeignKey(String[] foreignKey) {
-        this.foreignKey = foreignKey;
-    }
-
-    public TblColRef[] getPrimaryKeyColumns() {
-        return primaryKeyColumns;
-    }
-
-    public void setPrimaryKeyColumns(TblColRef[] primaryKeyColumns) {
-        this.primaryKeyColumns = primaryKeyColumns;
-    }
-
-    public TblColRef[] getForeignKeyColumns() {
-        return foreignKeyColumns;
-    }
-
-    public void setForeignKeyColumns(TblColRef[] foreignKeyColumns) {
-        this.foreignKeyColumns = foreignKeyColumns;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + Arrays.hashCode(primaryKeyColumns);
-        result = prime * result + Arrays.hashCode(foreignKeyColumns);
-        result = prime * result + this.type.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;
-        JoinDesc other = (JoinDesc) obj;
-
-        if (!this.columnsEqualIgnoringOrder(foreignKeyColumns, other.foreignKeyColumns))
-            return false;
-        if (!this.columnsEqualIgnoringOrder(primaryKeyColumns, other.primaryKeyColumns))
-            return false;
-
-        if (!this.type.equalsIgnoreCase(other.getType()))
-            return false;
-        return true;
-    }
-
-    private boolean columnsEqualIgnoringOrder(TblColRef[] a, TblColRef[] b) {
-        if (a.length != b.length)
-            return false;
-
-        return Arrays.asList(a).containsAll(Arrays.asList(b));
-    }
-
-    @Override
-    public String toString() {
-        return "JoinDesc [type=" + type + ", primary_key=" + Arrays.toString(primaryKey) + ", foreign_key=" + Arrays.toString(foreignKey) + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/MeasureDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/MeasureDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/MeasureDesc.java
deleted file mode 100644
index 3ee07a4..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/MeasureDesc.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/24/13 Time: 10:41 AM To
- * change this template use File | Settings | File Templates.
- */
-
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class MeasureDesc {
-
-    @JsonProperty("id")
-    private int id;
-    @JsonProperty("name")
-    private String name;
-    @JsonProperty("function")
-    private FunctionDesc function;
-    @JsonProperty("dependent_measure_ref")
-    private String dependentMeasureRef;
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public FunctionDesc getFunction() {
-        return function;
-    }
-
-    public void setFunction(FunctionDesc function) {
-        this.function = function;
-    }
-
-    public String getDependentMeasureRef() {
-        return dependentMeasureRef;
-    }
-
-    public void setDependentMeasureRef(String dependentMeasureRef) {
-        this.dependentMeasureRef = dependentMeasureRef;
-    }
-
-    public boolean isHolisticCountDistinct() {
-        return function.isHolisticCountDistinct();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        MeasureDesc that = (MeasureDesc) o;
-
-        if (id != that.id)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        return id;
-    }
-
-    @Override
-    public String toString() {
-        return "MeasureDesc [name=" + name + ", function=" + function + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/ParameterDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/ParameterDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/ParameterDesc.java
deleted file mode 100644
index b43df48..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/ParameterDesc.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.hadoop.util.StringUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Created with IntelliJ IDEA. User: lukhan Date: 9/30/13 Time: 2:46 PM To
- * change this template use File | Settings | File Templates.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class ParameterDesc {
-
-    public static final String COLUMN_TYPE = "column";
-
-    @JsonProperty("type")
-    private String type;
-    @JsonProperty("value")
-    private String value;
-
-    private List<TblColRef> colRefs;
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public byte[] getBytes() throws UnsupportedEncodingException {
-        return value.getBytes("UTF-8");
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-    public List<TblColRef> getColRefs() {
-        return colRefs;
-    }
-
-    public void setColRefs(List<TblColRef> colRefs) {
-        this.colRefs = colRefs;
-    }
-
-    public boolean isColumnType() {
-        return COLUMN_TYPE.equals(type);
-    }
-
-    public void normalizeColumnValue() {
-        if (isColumnType()) {
-            String values[] = value.split("\\s*,\\s*");
-            for (int i = 0; i < values.length; i++)
-                values[i] = values[i].toUpperCase();
-            Arrays.sort(values);
-            value = StringUtils.join(",", values);
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((type == null) ? 0 : type.hashCode());
-        result = prime * result + ((value == null) ? 0 : value.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;
-        ParameterDesc other = (ParameterDesc) obj;
-        if (type == null) {
-            if (other.type != null)
-                return false;
-        } else if (!type.equals(other.type))
-            return false;
-        if (value == null) {
-            if (other.value != null)
-                return false;
-        } else if (!value.equals(other.value))
-            return false;
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "ParameterDesc [type=" + type + ", value=" + value + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyColDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyColDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyColDesc.java
deleted file mode 100644
index e489f08..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyColDesc.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * @author yangli9
- * 
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class RowKeyColDesc {
-
-    @JsonProperty("column")
-    private String column;
-    @JsonProperty("length")
-    private int length;
-    @JsonProperty("dictionary")
-    private String dictionary;
-    @JsonProperty("mandatory")
-    private boolean mandatory = false;
-
-    // computed
-    private int bitIndex;
-    private TblColRef colRef;
-
-    public String getDictionary() {
-        return dictionary;
-    }
-
-    public String getColumn() {
-        return column;
-    }
-
-    void setColumn(String column) {
-        this.column = column;
-    }
-
-    public int getLength() {
-        return length;
-    }
-
-    public boolean isMandatory() {
-        return mandatory;
-    }
-
-    public int getBitIndex() {
-        return bitIndex;
-    }
-
-    void setBitIndex(int index) {
-        this.bitIndex = index;
-    }
-
-    public TblColRef getColRef() {
-        return colRef;
-    }
-
-    void setColRef(TblColRef colRef) {
-        this.colRef = colRef;
-    }
-
-    @Override
-    public String toString() {
-        return "RowKeyColDesc [column=" + column + ", length=" + length + ", dictionary=" + dictionary + ", mandatory=" + mandatory + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/a4fd4268/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyDesc.java b/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyDesc.java
deleted file mode 100644
index 97372f7..0000000
--- a/metadata/src/main/java/com/kylinolap/metadata/model/cube/RowKeyDesc.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright 2013-2014 eBay Software Foundation
- *
- * Licensed 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 com.kylinolap.metadata.model.cube;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.kylinolap.common.util.StringUtil;
-
-/**
- * Created by lukhan on 1/2/14.
- */
-@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
-public class RowKeyDesc {
-
-    public static class HierarchyMask {
-        public long fullMask;
-        public long[] allMasks;
-    }
-
-    public static class AggrGroupMask {
-        public AggrGroupMask(int size) {
-            groupOneBitMasks = new long[size];
-        }
-
-        public long groupMask;
-        public long groupOneBitMasks[];
-        public long uniqueMask;
-        public long leftoverMask;
-    }
-
-    @JsonProperty("rowkey_columns")
-    private RowKeyColDesc[] rowkeyColumns;
-    @JsonProperty("aggregation_groups")
-    private String[][] aggregationGroups;
-
-    // computed content
-    private CubeDesc cubeRef;
-    private Map<TblColRef, RowKeyColDesc> columnMap;
-
-    private long fullMask;
-    private long mandatoryColumnMask;
-    private AggrGroupMask[] aggrGroupMasks;
-    private long aggrGroupFullMask;
-    private long tailMask;
-
-    private List<HierarchyMask> hierarchyMasks;
-
-    public RowKeyColDesc[] getRowKeyColumns() {
-        return rowkeyColumns;
-    }
-
-    // search a specific row key col
-    public int getRowKeyIndexByColumnName(String columnName) {
-        if (this.rowkeyColumns == null)
-            return -1;
-
-        for (int i = 0; i < this.rowkeyColumns.length; ++i) {
-            RowKeyColDesc desc = this.rowkeyColumns[i];
-            if (desc.getColumn().equalsIgnoreCase(columnName)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    public int getNCuboidBuildLevels() {
-        // N aggregation columns requires N levels of cuboid build
-        // - N columns requires N-1 levels build
-        // - zero tail cuboid needs one more additional level
-        Set<String> aggDims = new HashSet<String>();
-        for (String[] aggrGroup : aggregationGroups) {
-            for (String dim : aggrGroup) {
-                aggDims.add(dim);
-            }
-        }
-        return aggDims.size();
-    }
-
-    public String[][] getAggregationGroups() {
-        return aggregationGroups;
-    }
-
-    public CubeDesc getCubeRef() {
-        return cubeRef;
-    }
-
-    public void setCubeRef(CubeDesc cubeRef) {
-        this.cubeRef = cubeRef;
-    }
-
-    public long getFullMask() {
-        return fullMask;
-    }
-
-    public long getMandatoryColumnMask() {
-        return mandatoryColumnMask;
-    }
-
-    public long getAggrGroupFullMask() {
-        return aggrGroupFullMask;
-    }
-
-    public AggrGroupMask[] getAggrGroupMasks() {
-        return aggrGroupMasks;
-    }
-
-    public List<HierarchyMask> getHierarchyMasks() {
-        return hierarchyMasks;
-    }
-
-    public long getTailMask() {
-        return tailMask;
-    }
-
-    public int getColumnBitIndex(TblColRef col) {
-        return getColDesc(col).getBitIndex();
-    }
-
-    public int getColumnLength(TblColRef col) {
-        return getColDesc(col).getLength();
-    }
-
-    public String getDictionary(TblColRef col) {
-        return getColDesc(col).getDictionary();
-    }
-
-    private RowKeyColDesc getColDesc(TblColRef col) {
-        RowKeyColDesc desc = columnMap.get(col);
-        if (desc == null)
-            throw new NullPointerException("Column " + col + " does not exist in row key desc");
-        return desc;
-    }
-    
-    public boolean isUseDictionary(TblColRef col) {
-        String useDictionary = getDictionary(col);
-        return !StringUtils.isBlank(useDictionary) && !"false".equals(useDictionary);
-    }
-
-    public boolean isUseDictionary() {
-        for (RowKeyColDesc col : getRowKeyColumns()) {
-            if (isUseDictionary(col.getColRef())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public void init(CubeDesc cube) {
-        setCubeRef(cube);
-        Map<String, TblColRef> colNameAbbr = cube.buildColumnNameAbbreviation();
-
-        buildRowKey(colNameAbbr);
-        buildAggregationGroups(colNameAbbr);
-        buildHierarchyMasks();
-    }
-
-    @Override
-    public String toString() {
-        return "RowKeyDesc [rowkeyColumns=" + Arrays.toString(rowkeyColumns) + ", aggregationGroups=" + Arrays.toString(aggregationGroups) + "]";
-    }
-
-    private void buildRowKey(Map<String, TblColRef> colNameAbbr) {
-        columnMap = new HashMap<TblColRef, RowKeyColDesc>();
-        mandatoryColumnMask = 0;
-
-        for (int i = 0; i < rowkeyColumns.length; i++) {
-            RowKeyColDesc col = rowkeyColumns[i];
-            col.setColumn(col.getColumn().toUpperCase());
-            col.setBitIndex(rowkeyColumns.length - i - 1);
-            col.setColRef(colNameAbbr.get(col.getColumn()));
-            if (col.getColRef() == null)
-                throw new IllegalArgumentException("Cannot find rowkey column " + col.getColumn() + " in cube " + cubeRef);
-
-            columnMap.put(col.getColRef(), col);
-
-            if (col.isMandatory()) {
-                mandatoryColumnMask |= 1L << col.getBitIndex();
-            }
-        }
-    }
-
-    private void buildAggregationGroups(Map<String, TblColRef> colNameAbbr) {
-        if (aggregationGroups == null) {
-            aggregationGroups = new String[0][];
-        }
-
-        for (int i = 0; i < aggregationGroups.length; i++) {
-            StringUtil.toUpperCaseArray(aggregationGroups[i], this.aggregationGroups[i]);
-        }
-
-        for (int i = 0; i < this.rowkeyColumns.length; i++) {
-            int index = rowkeyColumns[i].getBitIndex();
-            this.fullMask |= 1L << index;
-        }
-
-        this.aggrGroupMasks = new AggrGroupMask[aggregationGroups.length];
-        for (int i = 0; i < this.aggregationGroups.length; i++) {
-            String[] aggGrp = this.aggregationGroups[i];
-            AggrGroupMask mask = new AggrGroupMask(aggGrp.length);
-
-            for (int j = 0; j < aggGrp.length; j++) {
-                TblColRef aggCol = colNameAbbr.get(aggGrp[j].toUpperCase());
-                if (aggCol == null) {
-                    throw new IllegalArgumentException("Can't find aggregation column " + aggGrp[j] + " in  cube " + this.cubeRef.getName());
-                }
-                Integer index = getColumnBitIndex(aggCol);
-                mask.groupMask |= 1L << index;
-                mask.groupOneBitMasks[j] = 1L << index;
-                this.aggrGroupFullMask |= 1L << index;
-            }
-            this.aggrGroupMasks[i] = mask;
-        }
-
-        this.tailMask = fullMask ^ mandatoryColumnMask ^ aggrGroupFullMask;
-
-        // unique mask = (bits in this group) - (bits in following groups)
-        // leftover mask = (tail bits) + (bits in following groups) - (bits in
-        // this group)
-        for (int i = 0; i < aggrGroupMasks.length; i++) {
-            AggrGroupMask mask = aggrGroupMasks[i];
-
-            mask.uniqueMask = mask.groupMask;
-            for (int j = i + 1; j < aggrGroupMasks.length; j++) {
-                mask.uniqueMask &= ~aggrGroupMasks[j].groupMask;
-            }
-
-            mask.leftoverMask = tailMask;
-            for (int j = i + 1; j < aggrGroupMasks.length; j++) {
-                mask.leftoverMask |= aggrGroupMasks[j].groupMask;
-            }
-            mask.leftoverMask &= ~mask.groupMask;
-        }
-    }
-
-    private void buildHierarchyMasks() {
-        this.hierarchyMasks = new ArrayList<HierarchyMask>();
-
-        for (DimensionDesc dimension : this.cubeRef.getDimensions()) {
-            HierarchyDesc[] hierarchies = dimension.getHierarchy();
-            if (hierarchies == null || hierarchies.length == 0)
-                continue;
-
-            HierarchyMask mask = new HierarchyMask();
-            ArrayList<Long> allMaskList = new ArrayList<Long>();
-            for (int i = 0; i < hierarchies.length; i++) {
-                TblColRef hColumn = hierarchies[i].getColumnRef();
-                Integer index = getColumnBitIndex(hColumn);
-                long bit = 1L << index;
-
-                if ((tailMask & bit) > 0)
-                    continue; // ignore levels in tail, they don't participate
-                              // aggregation group combination anyway
-
-                mask.fullMask |= bit;
-                allMaskList.add(mask.fullMask);
-            }
-
-            mask.allMasks = new long[allMaskList.size()];
-            for (int i = 0; i < allMaskList.size(); i++)
-                mask.allMasks[i] = allMaskList.get(i);
-
-            this.hierarchyMasks.add(mask);
-        }
-    }
-
-}