Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sql save error when contains many columns #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class Data {
List<Long> dimension;

@Type(type = "json")
@Column(name = "columns")
@Column(name = "columns", length = 10000)
List<com.baidu.highflip.core.entity.runtime.basic.Column> columns = new LinkedList<>();

@Column(name = "binding_id")
Expand Down
4 changes: 4 additions & 0 deletions highflip-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import com.baidu.highflip.core.engine.HighFlipAdaptor;
import com.baidu.highflip.core.engine.InstanceRegister;
import lombok.extern.slf4j.Slf4j;

import org.springframework.boot.loader.LaunchedURLClassLoader;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;


@Slf4j
@Component
public class AdaptorLoader {
Expand All @@ -24,7 +26,23 @@ public class AdaptorLoader {

public void loadJar(URL url) throws IOException {

loader = new URLClassLoader(new URL[]{url});
if (Thread.currentThread()
.getContextClassLoader() instanceof LaunchedURLClassLoader) {
loader = (LaunchedURLClassLoader) Thread.currentThread()
.getContextClassLoader();
try {
Method addURL =
LaunchedURLClassLoader.class.getSuperclass()
.getDeclaredMethod("addURL",
new Class[] {URL.class});
addURL.setAccessible(true);
addURL.invoke(loader, new Object[] {url});
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
loader = new URLClassLoader(new URL[] {url});
}

try (InputStream stream = loader
.getResourceAsStream(AdaptorPropsList.HIGHFLIP_PROPERTIES_FILE)) {
Expand Down
2 changes: 1 addition & 1 deletion highflip-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#########################################################
# highflip adaptor
# highflip adaptor (file:/absolute/path/to/jar)
#########################################################
highflip.server.adaptor.path=
#########################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.webank.ai.fate.adaptor;

import static com.webank.ai.fate.common.FateConstants.DATA_ID_SEPARATOR;

import com.baidu.highflip.core.entity.runtime.Data;
import com.baidu.highflip.core.entity.runtime.basic.DataCategory;
import com.baidu.highflip.core.entity.runtime.basic.KeyPair;
Expand All @@ -14,14 +12,17 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -82,9 +83,17 @@ public Iterator<List<Object>> readDataDense(Data data) {
try (Response response = getContext().getClient()
.downloadComponentResultData(jobId, componentName,
role, partyId)) {
String content = DecompressUtils.decompressTarGzToStringMap(
response.body().asInputStream(),
s -> s.contains("csv")).get("data.csv");
final Map<String, String> res =
DecompressUtils.decompressTarGzToStringMap(
response.body().asInputStream(),
s -> s.contains("csv"));
if (res == null) {
return new ArrayList<List<Object>>().iterator();
}
String content = res.get("data.csv");
if (StringUtils.isEmpty(content)) {
return new ArrayList<List<Object>>().iterator();
}
return Arrays.stream(content.split("\n"))
.map(s -> Arrays.stream(s.split(DEFAULT_DELIMITER))
.map(d -> (Object) d)
Expand Down