Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/incubator-carbondata/pull/148#discussion_r82341356
--- Diff:
processing/src/main/java/org/apache/carbondata/processing/surrogatekeysgenerator/csvbased/BadRecordslogger.java
---
@@ -89,41 +95,55 @@ public static String hasBadRecord(String key) {
return badRecordEntry.remove(key);
}
- public void addBadRecordsToBilder(Object[] row, int size, String reason,
String valueComparer) {
+ public void addBadRecordsToBuilder(Object[] row, int size, String
reason, String valueComparer,
+ boolean badRecordsLogRedirect, boolean badRecordLoggerEnable) {
StringBuilder logStrings = new StringBuilder();
+ size = row.length;
int count = size;
for (int i = 0; i < size; i++) {
if (null == row[i]) {
- logStrings.append(row[i]);
+ char ch = logStrings.length() > 0 ?
logStrings.charAt(logStrings.length() - 1) : (char) -1;
+ if (ch == ',') {
+ logStrings =
logStrings.deleteCharAt(logStrings.lastIndexOf(","));
+ }
+ break;
} else if
(CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(row[i].toString())) {
logStrings.append(valueComparer);
} else {
logStrings.append(row[i]);
}
if (count > 1) {
- logStrings.append(" , ");
+ logStrings.append(',');
}
count--;
}
-
- logStrings.append("----->");
- if (null != reason) {
- if (reason.indexOf(CarbonCommonConstants.MEMBER_DEFAULT_VAL) > -1) {
-
logStrings.append(reason.replace(CarbonCommonConstants.MEMBER_DEFAULT_VAL,
valueComparer));
- } else {
- logStrings.append(reason);
- }
+ if (badRecordsLogRedirect) {
+ writeBadRecordsToCSVFile(logStrings);
}
+ if( badRecordLoggerEnable ) {
+ logStrings.append("----->");
+ if (null != reason) {
+ if (reason.indexOf(CarbonCommonConstants.MEMBER_DEFAULT_VAL) > -1)
{
+ logStrings
+
.append(reason.replace(CarbonCommonConstants.MEMBER_DEFAULT_VAL,
valueComparer));
+ } else {
+ logStrings.append(reason);
+ }
+ }
- writeBadRecordsToFile(logStrings);
+ writeBadRecordsToFile(logStrings);
+ } else {
+ badRecordEntry.put(taskKey, "Partially");
+ }
}
/**
*
*/
private synchronized void writeBadRecordsToFile(StringBuilder
logStrings) {
- String filePath = this.storePath + File.separator + this.fileName
- + CarbonCommonConstants.FILE_INPROGRESS_STATUS;
+ String filePath =
--- End diff --
This line should be moved down under `if` condition
---
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 [email protected] or file a JIRA ticket
with INFRA.
---