manishgupta88 commented on a change in pull request #3281: [WIP]Index server 
performance improvement
URL: https://github.com/apache/carbondata/pull/3281#discussion_r293699345
 
 

 ##########
 File path: 
core/src/main/java/org/apache/carbondata/core/indexstore/ExtendedBlockletWrapper.java
 ##########
 @@ -0,0 +1,240 @@
+/*
+ * 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.core.indexstore;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.datastore.compression.SnappyCompressor;
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile;
+import org.apache.carbondata.core.datastore.impl.FileFactory;
+import org.apache.carbondata.core.metadata.schema.table.Writable;
+import org.apache.carbondata.core.stream.ExtendedByteArrayInputStream;
+import org.apache.carbondata.core.stream.ExtendedByteArrayOutputStream;
+import org.apache.carbondata.core.stream.ExtendedDataInputStream;
+import org.apache.carbondata.core.util.CarbonProperties;
+import org.apache.carbondata.core.util.CarbonUtil;
+
+import org.apache.log4j.Logger;
+
+/**
+ * class will be used to send extended blocklet object from index executor to 
index driver
+ * if data size is more than it will be written in temp folder provided by user
+ * and only file name will send, if data size is less then complete data will 
be send to
+ * index executor
+ */
+public class ExtendedBlockletWrapper implements Writable, Serializable {
+
+  private static final Logger LOGGER =
+      LogServiceFactory.getLogService(ExtendedBlockletWrapper.class.getName());
+
+  private boolean isWrittenToFile;
+
+  private int dataSize;
+
+  private byte[] bytes;
+
+  private static final int BUFFER_SIZE = 8 * 1024 * 1024;
+
+  private static final int BLOCK_SIZE = 256 * 1024 * 1024;
+
+  public ExtendedBlockletWrapper() {
+
+  }
+
+  public ExtendedBlockletWrapper(List<ExtendedBlocklet> extendedBlockletList, 
String tablePath,
+      String queryId) {
+    Map<String, Short> uniqueLocations = new HashMap<>();
+    byte[] bytes = convertToBytes(tablePath, uniqueLocations, 
extendedBlockletList);
+    int serializeAllowedSize = Integer.parseInt(CarbonProperties.getInstance()
+        
.getProperty(CarbonCommonConstants.CARBON_INDEX_SERVER_SERIALIZATION_THRESHOLD))
 * 1024;
+    DataOutputStream stream = null;
+    // if data size is more then data will be written in file and file name 
will be sent from
+    // executor to driver, in case of any failure data will send through 
network
+    if (bytes.length > serializeAllowedSize) {
+      final String fileName = UUID.randomUUID().toString();
+      String folderPath = CarbonUtil.getIndexServerTempPath(tablePath, 
queryId);
+      try {
+        final CarbonFile carbonFile = FileFactory.getCarbonFile(folderPath);
+        boolean writeToFile = false;
+        if (carbonFile.isFileExist(folderPath)) {
+          writeToFile = true;
 
 Review comment:
   Add a warning logger here in case file does not exist to state that even 
though size was more the data is not written to file because the file does not 
exist

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to