carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipesala <...@git.apache.org>
Subject [GitHub] carbondata pull request #1359: [CARBONDATA-1480]Min Max Index Example for Da...
Date Tue, 10 Oct 2017 12:28:07 GMT
Github user ravipesala commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1359#discussion_r143711222
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/MinMaxDataMapFactory.java
---
    @@ -0,0 +1,157 @@
    +/*
    + * 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.carbondata.examples;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.carbondata.core.cache.Cache;
    +import org.apache.carbondata.core.cache.CacheProvider;
    +import org.apache.carbondata.core.cache.CacheType;
    +import org.apache.carbondata.core.datamap.DataMapDistributable;
    +import org.apache.carbondata.core.datamap.DataMapMeta;
    +import org.apache.carbondata.core.datamap.TableDataMap;
    +import org.apache.carbondata.core.datamap.dev.DataMap;
    +import org.apache.carbondata.core.datamap.dev.DataMapFactory;
    +import org.apache.carbondata.core.datamap.dev.DataMapWriter;
    +import org.apache.carbondata.core.datastore.filesystem.CarbonFile;
    +import org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter;
    +import org.apache.carbondata.core.datastore.impl.FileFactory;
    +import org.apache.carbondata.core.events.ChangeEvent;
    +import org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier;
    +import org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMap;
    +import org.apache.carbondata.core.indexstore.schema.FilterType;
    +import org.apache.carbondata.core.memory.MemoryException;
    +import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
    +
    +
    +/**
    + * Min Max DataMap Factory
    + */
    +public class MinMaxDataMapFactory implements DataMapFactory {
    +
    +  private AbsoluteTableIdentifier identifier;
    +
    +  // segmentId -> list of index file
    +  private Map<String, List<TableBlockIndexUniqueIdentifier>> segmentMap =
new HashMap<>();
    +
    +  @Override
    +  public void init(AbsoluteTableIdentifier identifier, String dataMapName) {
    +    this.identifier = identifier;
    +  }
    +
    +  /**
    +   * createWriter will return the MinMaxDataWriter.
    +   * @param segmentId
    +   * @return
    +   */
    +  @Override
    +  public DataMapWriter createWriter(String segmentId) {
    +    return new MinMaxDataWriter();
    +  }
    +
    +  /**
    +   * getDataMaps Factory method Initializes the Min Max Data Map and returns.
    +   * @param segmentId
    +   * @return
    +   * @throws IOException
    +   */
    +  @Override
    +  public List<DataMap> getDataMaps(String segmentId) throws IOException {
    +    List<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers =
    +        segmentMap.get(segmentId);
    +    List<DataMap> dataMapList = new ArrayList<>();
    +    if (tableBlockIndexUniqueIdentifiers == null) {
    +      tableBlockIndexUniqueIdentifiers = new ArrayList<>();
    +      CarbonFile[] listFiles = getCarbonIndexFiles(segmentId);
    +      for (int i = 0; i < listFiles.length; i++) {
    +        tableBlockIndexUniqueIdentifiers.add(
    +            new TableBlockIndexUniqueIdentifier(identifier, segmentId, listFiles[i].getName()));
    +      }
    +    }
    +    // Form a dataMap of Type MinMaxDataMap.
    +    MinMaxDataMap dataMap = new MinMaxDataMap();
    +    try {
    +      dataMap.init(tableBlockIndexUniqueIdentifiers.get(0).getFilePath());
    +    } catch (MemoryException ex) {
    +
    +    }
    +    dataMapList.add(dataMap);
    +    return dataMapList;
    +  }
    +
    +  /**
    +   * Routine to retrieve the carbonIndex.
    +   * @param segmentId
    +   * @return
    +   */
    +  private CarbonFile[] getCarbonIndexFiles(String segmentId) {
    --- End diff --
    
    why this method required


---

Mime
View raw message