[GitHub] incubator-carbondata pull request #100: Handle all dictionary exception more...

2016-08-30 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-carbondata/pull/100


---
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.
---


[GitHub] incubator-carbondata pull request #100: Handle all dictionary exception more...

2016-08-28 Thread foryou2030
Github user foryou2030 commented on a diff in the pull request:

https://github.com/apache/incubator-carbondata/pull/100#discussion_r76552945
  
--- Diff: 
integration/spark/src/main/scala/org/apache/carbondata/spark/util/GlobalDictionaryUtil.scala
 ---
@@ -591,29 +591,31 @@ object GlobalDictionaryUtil extends Logging {
   val basicRdd = sqlContext.sparkContext.textFile(allDictionaryPath)
 .map(x => {
 val tokens = x.split("" + CSVWriter.DEFAULT_SEPARATOR)
-var index: Int = 0
+if (tokens.size != 2) {
+  logError("[ALL_DICTIONARY] Read a bad dictionary record: " + x)
+}
+var columnName: String = CarbonCommonConstants.DEFAULT_COLUMN_NAME
 var value: String = ""
 try {
-  index = tokens(0).toInt
+  columnName = csvFileColumns(tokens(0).toInt)
   value = tokens(1)
 } catch {
   case ex: Exception =>
-logError("read a bad dictionary record" + x)
+logError("[ALL_DICTIONARY] Reset bad dictionary record as 
default value")
 }
-(index, value)
+(columnName, value)
   })
+
   // group by column index, and filter required columns
   val requireColumnsList = requireColumns.toList
   allDictionaryRdd = basicRdd
 .groupByKey()
-.map(x => (csvFileColumns(x._1), x._2))
 .filter(x => requireColumnsList.contains(x._1))
 } catch {
   case ex: Exception =>
-logError("read local dictionary files failed")
+logError("[ALL_DICTIONARY] Read dictionary files failed. Caused 
by" + ex.getMessage)
--- End diff --

ok, it no required, i have removed


---
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.
---


[GitHub] incubator-carbondata pull request #100: Handle all dictionary exception more...

2016-08-27 Thread sujith71955
Github user sujith71955 commented on a diff in the pull request:

https://github.com/apache/incubator-carbondata/pull/100#discussion_r76519992
  
--- Diff: 
integration/spark/src/main/scala/org/apache/carbondata/spark/util/GlobalDictionaryUtil.scala
 ---
@@ -629,22 +631,32 @@ object GlobalDictionaryUtil extends Logging {
 // filepath regex, look like "/path/*.dictionary"
 if (filePath.getName.startsWith("*")) {
   val dictExt = filePath.getName.substring(1)
-  val listFiles = filePath.getParentFile.listFiles()
-  if (listFiles.exists(file =>
-file.getName.endsWith(dictExt) && file.getSize > 0)) {
-true
+  if (filePath.getParentFile.exists()) {
+val listFiles = filePath.getParentFile.listFiles()
--- End diff --

what if filePath.getParentFile returns null?


---
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.
---


[GitHub] incubator-carbondata pull request #100: Handle all dictionary exception more...

2016-08-27 Thread sujith71955
Github user sujith71955 commented on a diff in the pull request:

https://github.com/apache/incubator-carbondata/pull/100#discussion_r76519971
  
--- Diff: 
integration/spark/src/main/scala/org/apache/carbondata/spark/util/GlobalDictionaryUtil.scala
 ---
@@ -591,29 +591,31 @@ object GlobalDictionaryUtil extends Logging {
   val basicRdd = sqlContext.sparkContext.textFile(allDictionaryPath)
 .map(x => {
 val tokens = x.split("" + CSVWriter.DEFAULT_SEPARATOR)
-var index: Int = 0
+if (tokens.size != 2) {
+  logError("[ALL_DICTIONARY] Read a bad dictionary record: " + x)
+}
+var columnName: String = CarbonCommonConstants.DEFAULT_COLUMN_NAME
 var value: String = ""
 try {
-  index = tokens(0).toInt
+  columnName = csvFileColumns(tokens(0).toInt)
   value = tokens(1)
 } catch {
   case ex: Exception =>
-logError("read a bad dictionary record" + x)
+logError("[ALL_DICTIONARY] Reset bad dictionary record as 
default value")
 }
-(index, value)
+(columnName, value)
   })
+
   // group by column index, and filter required columns
   val requireColumnsList = requireColumns.toList
   allDictionaryRdd = basicRdd
 .groupByKey()
-.map(x => (csvFileColumns(x._1), x._2))
 .filter(x => requireColumnsList.contains(x._1))
 } catch {
   case ex: Exception =>
-logError("read local dictionary files failed")
+logError("[ALL_DICTIONARY] Read dictionary files failed. Caused 
by" + ex.getMessage)
--- End diff --

ALL_DICTIONARY this term is really required in this context?


---
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.
---


[GitHub] incubator-carbondata pull request #100: Handle all dictionary exception more...

2016-08-27 Thread foryou2030
Github user foryou2030 commented on a diff in the pull request:

https://github.com/apache/incubator-carbondata/pull/100#discussion_r76513982
  
--- Diff: 
integration/spark/src/main/scala/org/apache/carbondata/spark/util/GlobalDictionaryUtil.scala
 ---
@@ -629,22 +631,32 @@ object GlobalDictionaryUtil extends Logging {
 // filepath regex, look like "/path/*.dictionary"
 if (filePath.getName.startsWith("*")) {
   val dictExt = filePath.getName.substring(1)
-  val listFiles = filePath.getParentFile.listFiles()
-  if (listFiles.exists(file =>
-file.getName.endsWith(dictExt) && file.getSize > 0)) {
-true
+  if (filePath.getParentFile.exists()) {
+val listFiles = filePath.getParentFile.listFiles()
+if (listFiles.exists(file =>
+  file.getName.endsWith(dictExt) && file.getSize > 0)) {
+  true
+} else {
+  logWarning("[ALL_DICTIONARY] No dictionary files found or empty 
dictionary files! " +
+"Won't generate new dictionary.")
+  false
+}
   } else {
-logInfo("No dictionary files found or empty dictionary files! " +
-  "Won't generate new dictionary.")
-false
+throw new FileNotFoundException(
+  "[ALL_DICTIONARY] The given dictionary file path not found!")
   }
 } else {
-  if (filePath.exists() && filePath.getSize > 0) {
-true
+  if (filePath.exists()) {
+if (filePath.getSize > 0) {
+  true
+} else {
+  logWarning("[ALL_DICTIONARY] No dictionary files found or empty 
dictionary files! " +
+"Won't generate new dictionary.")
+  false
+}
   } else {
-logInfo("No dictionary files found or empty dictionary files! " +
-  "Won't generate new dictionary.")
-false
+throw new FileNotFoundException(
+  "[ALL_DICTIONARY] The given dictionary file path not found!")
--- End diff --

ok, fixed


---
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.
---