Github user ravipesala commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1238#discussion_r131575443
  
    --- Diff: 
processing/src/main/java/org/apache/carbondata/processing/datamap/DataMapWriterListener.java
 ---
    @@ -0,0 +1,109 @@
    +/*
    + * 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.processing.datamap;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.ConcurrentHashMap;
    +
    +import org.apache.carbondata.common.logging.LogService;
    +import org.apache.carbondata.common.logging.LogServiceFactory;
    +import org.apache.carbondata.core.datamap.DataMapMeta;
    +import org.apache.carbondata.core.datamap.dev.DataMapWriter;
    +import org.apache.carbondata.core.datastore.page.ColumnPage;
    +import org.apache.carbondata.processing.store.TablePage;
    +
    +/**
    + * It is for writing DataMap for one table
    + */
    +public class DataMapWriterListener {
    +
    +  private static final LogService LOG = LogServiceFactory.getLogService(
    +      DataMapWriterListener.class.getCanonicalName());
    +
    +  // indexed column name -> list of data map writer
    +  private static Map<String, List<DataMapWriter>> registry = new 
ConcurrentHashMap<>();
    +
    +  /**
    +   * Register a DataMapWriter
    +   */
    +  public void register(DataMapWriter writer) {
    +    DataMapMeta meta = writer.getMeta();
    +    List<DataMapWriter> writers = registry.get(meta.getIndexedColumn());
    +    if (writers != null) {
    +      writers.add(writer);
    +    } else {
    +      writers = new ArrayList<>();
    +      writers.add(writer);
    +      registry.put(meta.getIndexedColumn(), writers);
    +    }
    +    LOG.info("DataMapWriter " + writer + " added");
    +  }
    +
    +  public void onBlockStart(String blockId) {
    +    for (List<DataMapWriter> writers : registry.values()) {
    +      for (DataMapWriter writer : writers) {
    +        writer.onBlockStart(blockId);
    +      }
    +    }
    +  }
    +
    +  public void onBlockEnd(String blockId) {
    +    for (List<DataMapWriter> writers : registry.values()) {
    +      for (DataMapWriter writer : writers) {
    +        writer.onBlockEnd(blockId);
    +      }
    +    }
    +  }
    +
    +  public void onBlockletStart(int blockletId) {
    +    for (List<DataMapWriter> writers : registry.values()) {
    +      for (DataMapWriter writer : writers) {
    +        writer.onBlockletStart(blockletId);
    +      }
    +    }
    +  }
    +
    +  public void onBlockletEnd(int blockletId) {
    +    for (List<DataMapWriter> writers : registry.values()) {
    +      for (DataMapWriter writer : writers) {
    +        writer.onBlockletEnd(blockletId);
    +      }
    +    }
    +  }
    +
    +  /**
    +   * Pick corresponding column page and add to all registered datamap
    +   *
    +   * @param pageId     sequence number of page, start from 0
    +   * @param tablePage  page data
    +   */
    +  public void add(int blockletId, int pageId, TablePage tablePage) {
    --- End diff --
    
    I think listener should be only for sending events, not for adding rows. So 
better remove from here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to