Commit 1eebb5d0 authored by liaozan's avatar liaozan 🏀

Refine struct

parent 5102d7e6
package com.schbrain.framework.autoconfigure.starrocks.operation; package com.schbrain.framework.autoconfigure.starrocks.operation;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* @author liaozan * @author liaozan
...@@ -17,7 +16,7 @@ public interface StarrocksService<T> { ...@@ -17,7 +16,7 @@ public interface StarrocksService<T> {
/** /**
* 批量保存/更新 * 批量保存/更新
*/ */
void upsertBatch(List<T> entityList); void upsertBatch(Collection<T> entityList);
/** /**
* 单个保存/更新,传入 columns 只会处理相应的 columns * 单个保存/更新,传入 columns 只会处理相应的 columns
...@@ -27,7 +26,7 @@ public interface StarrocksService<T> { ...@@ -27,7 +26,7 @@ public interface StarrocksService<T> {
/** /**
* 批量保存/更新,传入 columns 只会处理相应的 columns * 批量保存/更新,传入 columns 只会处理相应的 columns
*/ */
void upsertBatch(List<T> entityList, List<String> columns); void upsertBatch(Collection<T> entityList, List<String> columns);
/** /**
* 删除 * 删除
...@@ -37,7 +36,7 @@ public interface StarrocksService<T> { ...@@ -37,7 +36,7 @@ public interface StarrocksService<T> {
/** /**
* 批量删除 * 批量删除
*/ */
void deleteBatch(List<T> entityList); void deleteBatch(Collection<T> entityList);
/** /**
* 根据 sql 查询 * 根据 sql 查询
......
...@@ -44,7 +44,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin ...@@ -44,7 +44,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin
} }
@Override @Override
public void upsertBatch(List<T> entityList) { public void upsertBatch(Collection<T> entityList) {
upsertBatch(entityList, Collections.emptyList()); upsertBatch(entityList, Collections.emptyList());
} }
...@@ -54,7 +54,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin ...@@ -54,7 +54,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin
} }
@Override @Override
public void upsertBatch(List<T> entityList, List<String> columns) { public void upsertBatch(Collection<T> entityList, List<String> columns) {
handler.upsertBatch(ValidateUtils.notEmpty(entityList, "entityList不能为空"), columns); handler.upsertBatch(ValidateUtils.notEmpty(entityList, "entityList不能为空"), columns);
} }
...@@ -64,7 +64,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin ...@@ -64,7 +64,7 @@ public class StarrocksServiceImpl<T> implements StarrocksService<T>, Initializin
} }
@Override @Override
public void deleteBatch(List<T> entityList) { public void deleteBatch(Collection<T> entityList) {
handler.deleteBatch(ValidateUtils.notNull(entityList, "entityList不能为空")); handler.deleteBatch(ValidateUtils.notNull(entityList, "entityList不能为空"));
} }
......
...@@ -7,8 +7,7 @@ import com.schbrain.common.util.JacksonUtils; ...@@ -7,8 +7,7 @@ import com.schbrain.common.util.JacksonUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import java.util.List; import java.util.*;
import java.util.Optional;
/** /**
* @author liaozan * @author liaozan
...@@ -27,8 +26,8 @@ public class StarrocksStreamLoadHandler { ...@@ -27,8 +26,8 @@ public class StarrocksStreamLoadHandler {
this.password = password; this.password = password;
} }
public <T> void upsertBatch(List<T> entityList, List<String> columns) { public <T> void upsertBatch(Collection<T> entityList, List<String> columns) {
log.info("Starrocks upsert, dataSize: {}, sample data: {}", entityList.size(), entityList.get(0)); log.info("Starrocks upsert, dataSize: {}, sample data: {}", entityList.size(), entityList.iterator().next());
String content = JacksonUtils.toJsonString(entityList); String content = JacksonUtils.toJsonString(entityList);
String upsertResult = createUpsertRequest(content, columns).execute().body(); String upsertResult = createUpsertRequest(content, columns).execute().body();
...@@ -40,8 +39,8 @@ public class StarrocksStreamLoadHandler { ...@@ -40,8 +39,8 @@ public class StarrocksStreamLoadHandler {
checkResponse(upsertResult); checkResponse(upsertResult);
} }
public <T> void deleteBatch(List<T> entityList) { public <T> void deleteBatch(Collection<T> entityList) {
log.info("Starrocks delete, dataSize: {}, sample data: {}", entityList.size(), entityList.get(0)); log.info("Starrocks delete, dataSize: {}, sample data: {}", entityList.size(), entityList.iterator().next());
String content = JacksonUtils.toJsonString(entityList); String content = JacksonUtils.toJsonString(entityList);
String deleteResult = createCommonRequest(content).header("columns", "__op='delete'").execute().body(); String deleteResult = createCommonRequest(content).header("columns", "__op='delete'").execute().body();
......
package com.schbrain.framework.autoconfigure.starrocks.helper; package com.schbrain.framework.autoconfigure.starrocks.util;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.PropertyNamingStrategies;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment