use of com.alibaba.maxgraph.dataload.databuild.ColumnMappingInfo 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);
}
use of com.alibaba.maxgraph.dataload.databuild.ColumnMappingInfo in project GraphScope by alibaba.
the class DataCommand method initialize.
private void initialize() throws IOException {
FileSystem fs = new Path(this.dataPath).getFileSystem(new Configuration());
try (FSDataInputStream inputStream = fs.open(new Path(this.dataPath, "META"))) {
String metaString = inputStream.readUTF();
ObjectMapper objectMapper = new ObjectMapper();
Map<String, String> metaMap = objectMapper.readValue(metaString, new TypeReference<Map<String, String>>() {
});
this.graphEndpoint = metaMap.get("endpoint");
this.schema = GraphSchemaMapper.parseFromJson(metaMap.get("schema")).toGraphSchema();
this.columnMappingInfos = objectMapper.readValue(metaMap.get("mappings"), new TypeReference<Map<String, ColumnMappingInfo>>() {
});
}
}
Aggregations