Yizhou-Yang commented on code in PR #6541:
URL: https://github.com/apache/inlong/pull/6541#discussion_r1024880532


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -198,15 +320,92 @@ private boolean checkFlushException(String 
tableIdentifier) {
     @Override
     public synchronized void writeRecord(T row) throws IOException {
         addBatch(row);
+        if (isSingle) {
+            size = batch.size();
+        }
         boolean valid = (executionOptions.getBatchSize() > 0 && size >= 
executionOptions.getBatchSize())
                 || batchBytes >= executionOptions.getMaxBatchBytes();
         if (valid && !flushing) {
             flush();
         }
     }
 
+    public void addSingle(T row) {
+        if (row instanceof RowData) {
+            RowData rowData = (RowData) row;
+            Map<String, String> valueMap = new HashMap<>();
+            StringJoiner value = new StringJoiner(this.fieldDelimiter);
+            for (int i = 0; i < rowData.getArity() && i < fieldGetters.length; 
++i) {
+                Object field = fieldGetters[i].getFieldOrNull(rowData);
+                if (jsonFormat) {
+                    String data = field != null ? field.toString() : null;
+                    valueMap.put(this.fieldNames[i], data);
+                    batchBytes += 
this.fieldNames[i].getBytes(StandardCharsets.UTF_8).length;
+                    if (data != null) {
+                        batchBytes += 
data.getBytes(StandardCharsets.UTF_8).length;
+                    }
+                } else {
+                    String data = field != null ? field.toString() : 
NULL_VALUE;
+                    value.add(data);
+                    batchBytes += data.getBytes(StandardCharsets.UTF_8).length;
+                }
+            }
+            // add doris delete sign
+            if (enableBatchDelete()) {
+                if (jsonFormat) {
+                    valueMap.put(DORIS_DELETE_SIGN, 
parseDeleteSign(rowData.getRowKind()));
+                } else {
+                    value.add(parseDeleteSign(rowData.getRowKind()));
+                }
+            }
+            Object data = jsonFormat ? valueMap : value.toString();
+            LOG.info("appending data object {} with jsonformat {}", data, 
jsonFormat);
+            LOG.info("parsed data {}", parsetoMap(data));
+            //appending data object 12345 0
+            //should be {"id":"12345","__DORIS_DELETE_SIGN__":"0"}
+            List<Map<String, String>> mapData = 
batchMap.getOrDefault(tableIdentifier, new ArrayList<String>());
+            mapData.add(parsetoMap(data));
+            batchMap.putIfAbsent(tableIdentifier, mapData);
+        } else if (row instanceof String) {
+            batchBytes += ((String) 
row).getBytes(StandardCharsets.UTF_8).length;
+            LOG.info("appending row {}", row);

Review Comment:
   removed most logs



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to