[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-04 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r342406568
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,24 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val allSegments = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+// If a path is already added then we should block the adding of the same 
path again.
+if (allSegments.exists(a =>
+  a.getPath != null && a.getPath.equalsIgnoreCase(segmentPath)
+)) {
+  throw new AnalysisException(s"Cannot add the segment. This path is 
already in use by " +
 
 Review comment:
   Done


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-04 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r342406601
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,24 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val allSegments = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+// If a path is already added then we should block the adding of the same 
path again.
+if (allSegments.exists(a =>
+  a.getPath != null && a.getPath.equalsIgnoreCase(segmentPath)
+)) {
+  throw new AnalysisException(s"Cannot add the segment. This path is 
already in use by " +
+  s"another segment.")
+}
+
+val format = options.getOrElse("format", "carbondata")
+val isCarbonFormat = format.equalsIgnoreCase("carbondata") || 
format.equalsIgnoreCase("carbon")
+
+// If in the given location no carbon files are found then we can throw an 
exception
 
 Review comment:
   Done.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-04 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r342388739
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,23 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val allSegments = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+// If a path is already added then we should block the adding of the same 
path again.
+allSegments.exists { a =>
+  a.getPath != null && a.getPath.equalsIgnoreCase(segmentPath)
+  throw new AnalysisException(s"Cannot add the segment. This path is 
already in use by " +
+  s"another segment.")
+}
+
+val format = options.getOrElse("format", "carbondata")
+val isCarbonFormat = format.equalsIgnoreCase("carbondata") || 
format.equalsIgnoreCase("carbon")
+
+// If in the given location no carbon files are found then we can throw an 
exception
+if (isCarbonFormat && 
SegmentFileStore.getListOfCarbonIndexFiles(segmentPath).isEmpty) {
 
 Review comment:
   @ravipesala Here we are just checking the presence of carbon files present 
in the current folder location and as there was a 'isCarbonFormat' below so I 
just shifted it above and used it.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341915293
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,22 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val format = options.getOrElse("format", "carbondata")
+val isCarbonFormat = format.equals("carbondata") || format.equals("carbon")
+
+val allSegments = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+for (currSegment <- allSegments) {
 
 Review comment:
   Done.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341914568
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,22 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val format = options.getOrElse("format", "carbondata")
+val isCarbonFormat = format.equals("carbondata") || format.equals("carbon")
 
 Review comment:
   Done.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341902454
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##
 @@ -184,6 +184,22 @@ public static String writeSegmentFile(CarbonTable 
carbonTable, String segmentId,
 return writeSegmentFile(carbonTable, segmentId, UUID, null, segPath);
   }
 
+  /**
+   * Returns the list of index files
+   *
+   * @param segmentPath
+   * @return
+   */
+  public static CarbonFile[] getListOfCarbonIndexFiles(String segmentPath) {
+CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
+CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
+  @Override public boolean accept(CarbonFile file) {
+return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || 
file.getName()
 
 Review comment:
   Done.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341902473
 
 

 ##
 File path: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##
 @@ -92,6 +92,22 @@ case class CarbonAddLoadCommand(
 val segmentPath = options.getOrElse(
   "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+val format = options.getOrElse("format", "carbondata")
+val isCarbonFormat = format.equals("carbondata") || format.equals("carbon")
+
+val allSegments = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+for (currSegment <- allSegments) {
+  if (currSegment.getPath != null && 
currSegment.getPath.equalsIgnoreCase(segmentPath)) {
+throw new AnalysisException(s"Cannot add the segment. This path is 
already in use by " +
+s"another segment.")
+  }
+}
+
+if (isCarbonFormat && 
SegmentFileStore.getListOfCarbonIndexFiles(segmentPath).isEmpty) {
 
 Review comment:
   Done.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341901800
 
 

 ##
 File path: 
core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
 ##
 @@ -184,6 +184,22 @@ public static String writeSegmentFile(CarbonTable 
carbonTable, String segmentId,
 return writeSegmentFile(carbonTable, segmentId, UUID, null, segPath);
   }
 
+  /**
+   * Returns the list of index files
+   *
+   * @param segmentPath
+   * @return
+   */
+  public static CarbonFile[] getListOfCarbonIndexFiles(String segmentPath) {
 
 Review comment:
   Yes, its the path to segment folder to get the carbon file.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

2019-11-03 Thread GitBox
manishnalla1994 commented on a change in pull request #3426: [CARBONDATA-3560] 
Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r341901364
 
 

 ##
 File path: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/addsegment/AddSegmentTestCase.scala
 ##
 @@ -542,7 +541,7 @@ class AddSegmentTestCase extends QueryTest with 
BeforeAndAfterAll {
 copy(path.toString, newPath)
 checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(30)))
 
-sql(s"alter table addsegment1 add segment options('path'='$newPath', 
'format'='parquet')").show()
+sql(s"alter table addsegment1 add segment options('path'='$newPath', 
'format'='PARQUET')").show()
 
 Review comment:
   This change is required just for the testing purpose of uppercase format, so 
that I need not add a new testcase just for case sensitivity.


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:
us...@infra.apache.org


With regards,
Apache Git Services