use of com.alibaba.graphscope.groot.sdk.MaxGraphClient in project GraphScope by alibaba.
the class IngestDataCommand method run.
public void run() {
MaxGraphClient client = MaxGraphClient.newBuilder().setHosts(graphEndpoint).build();
client.ingestData(dataPath);
}
use of com.alibaba.graphscope.groot.sdk.MaxGraphClient in project GraphScope by alibaba.
the class LdbcLoader method main.
public static void main(String[] args) throws IOException, ParseException {
String dataDir = args[0];
String host = args[1];
int port = Integer.valueOf(args[2]);
int batchSize = Integer.valueOf(args[3]);
logger.info("dataDir [" + dataDir + "] host [" + host + "] port [" + port + "] batch [" + batchSize + "]");
MaxGraphClient client = MaxGraphClient.newBuilder().addHost(host, port).build();
int processed = 0;
int ignored = 0;
for (Path path : Files.list(Paths.get(dataDir)).collect(Collectors.toList())) {
logger.info("process file [" + path.getFileName() + "]");
String fileName = path.getFileName().toString();
if (!fileName.endsWith("_0_0.csv") || fileName.startsWith(".") || fileName.startsWith("person_speaks_language") || fileName.startsWith("person_email_emailaddress")) {
logger.info("ignore [" + fileName + "]");
ignored++;
continue;
}
String name = fileName.substring(0, fileName.length() - 8);
String[] items = name.split("_");
if (items.length == 1) {
String label = firstUpperCase(items[0]);
logger.info("vertex table: [" + label + "]");
processVertex(client, label, path, batchSize);
} else {
String srcLabel = firstUpperCase(items[0]);
String label = items[1];
String dstLabel = firstUpperCase(items[2]);
logger.info("edge table: [" + srcLabel + "-" + label + "->" + dstLabel + "]");
processEdge(client, label, srcLabel, dstLabel, path, batchSize);
}
processed++;
}
logger.info("Total [" + (processed + ignored) + "]. processed [" + processed + "], ignored [" + ignored + "]");
}
use of com.alibaba.graphscope.groot.sdk.MaxGraphClient in project GraphScope by alibaba.
the class LoadLdbc method main.
public static void main(String[] args) throws IOException, ParseException {
String dataDir = args[0];
String host = args[1];
int port = Integer.valueOf(args[2]);
int batchSize = Integer.valueOf(args[3]);
logger.info("dataDir [" + dataDir + "] host [" + host + "] port [" + port + "] batch [" + batchSize + "]");
MaxGraphClient client = MaxGraphClient.newBuilder().addHost(host, port).build();
int processed = 0;
int ignored = 0;
for (Path path : Files.list(Paths.get(dataDir)).collect(Collectors.toList())) {
logger.info("process file [" + path.getFileName() + "]");
String fileName = path.getFileName().toString();
if (!fileName.endsWith("_0_0.csv") || fileName.startsWith(".") || fileName.startsWith("person_speaks_language") || fileName.startsWith("person_email_emailaddress")) {
logger.info("ignore [" + fileName + "]");
ignored++;
continue;
}
String name = fileName.substring(0, fileName.length() - 8);
String[] items = name.split("_");
if (items.length == 1) {
String label = firstUpperCase(items[0]);
logger.info("vertex table: [" + label + "]");
processVertex(client, label, path, batchSize);
} else {
String srcLabel = firstUpperCase(items[0]);
String label = items[1];
String dstLabel = firstUpperCase(items[2]);
logger.info("edge table: [" + srcLabel + "-" + label + "->" + dstLabel + "]");
processEdge(client, label, srcLabel, dstLabel, path, batchSize);
}
processed++;
}
logger.info("Total [" + (processed + ignored) + "]. processed [" + processed + "], ignored [" + ignored + "]");
}
use of com.alibaba.graphscope.groot.sdk.MaxGraphClient in project GraphScope by alibaba.
the class IngestFile method main.
public static void main(String[] args) throws IOException {
String inputFile = args[0];
String host = args[1];
int port = Integer.valueOf(args[2]);
int batchSize = Integer.valueOf(args[3]);
MaxGraphClient client = MaxGraphClient.newBuilder().addHost(host, port).build();
File file = new File(inputFile);
String fileName = file.getName();
String label = fileName.split("_")[0];
logger.info("file [" + inputFile + "] host [" + host + "] port [" + port + "] label [" + label + "]");
List<String> propertyNames = new ArrayList<>();
int count = 0;
long snapshotId = 0;
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
while ((line = br.readLine()) != null) {
if (propertyNames.size() == 0) {
// First line
for (String item : line.split("\\|")) {
propertyNames.add(item);
}
} else {
Map<String, String> properties = new HashMap<>();
String[] items = line.split("\\|");
for (int i = 0; i < items.length; i++) {
properties.put(propertyNames.get(i), items[i]);
}
client.addVertex(label, properties);
count++;
if (count == batchSize) {
snapshotId = client.commit();
count = 0;
}
}
}
}
long maybeSnapshotId = client.commit();
long flushSnapshotId = maybeSnapshotId == 0 ? snapshotId : maybeSnapshotId;
logger.info("flush snapshotId [" + flushSnapshotId + "]");
client.remoteFlush(flushSnapshotId);
logger.info("done");
}
use of com.alibaba.graphscope.groot.sdk.MaxGraphClient in project GraphScope by alibaba.
the class CommitDataCommand method run.
public void run() {
MaxGraphClient client = MaxGraphClient.newBuilder().setHosts(graphEndpoint).build();
Map<Long, DataLoadTarget> tableToTarget = new HashMap<>();
for (ColumnMappingInfo columnMappingInfo : columnMappingInfos.values()) {
long tableId = columnMappingInfo.getTableId();
int labelId = columnMappingInfo.getLabelId();
GraphElement graphElement = schema.getElement(labelId);
String label = graphElement.getLabel();
DataLoadTarget.Builder builder = DataLoadTarget.newBuilder();
builder.setLabel(label);
if (graphElement instanceof GraphEdge) {
builder.setSrcLabel(schema.getElement(columnMappingInfo.getSrcLabelId()).getLabel());
builder.setDstLabel(schema.getElement(columnMappingInfo.getDstLabelId()).getLabel());
}
tableToTarget.put(tableId, builder.build());
}
client.commitDataLoad(tableToTarget);
}
Aggregations