Merge remote-tracking branch 'upstream/branch0101' into branch0101

This commit is contained in:
Qu 2023-12-20 15:05:22 +08:00
commit 0b65ec83c4
424 changed files with 30014 additions and 12457 deletions

View File

@ -23,6 +23,14 @@
<artifactId>builder-core</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-local-runner</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-cloudext-warehouse</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.server</groupId>
<artifactId>api-http-client</artifactId>
@ -35,10 +43,6 @@
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-graph-store-tugraph</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-table-store</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-search-engine</artifactId>
@ -47,13 +51,6 @@
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-search-engine-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.kg.reasoner</groupId>
<artifactId>local</artifactId>
<version>${kgreasoner-version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/../../server/lib/spgreasoner-local-0.0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.server</groupId>
<artifactId>core-schema-model</artifactId>

View File

@ -9,7 +9,7 @@ import com.antgroup.openspg.builder.model.pipeline.config.RelationMappingNodeCon
import com.antgroup.openspg.builder.model.record.BaseRecord;
import com.antgroup.openspg.builder.model.record.BuilderRecord;
import com.antgroup.openspg.builder.model.record.RelationRecord;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
import com.antgroup.openspg.common.util.StringUtils;
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
import com.antgroup.openspg.core.schema.model.predicate.Relation;

View File

@ -22,7 +22,7 @@ import com.antgroup.openspg.builder.model.pipeline.config.SPGTypeMappingNodeConf
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.BaseRecord;
import com.antgroup.openspg.builder.model.record.BuilderRecord;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
import com.antgroup.openspg.common.util.StringUtils;
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
import com.antgroup.openspg.core.schema.model.type.BaseSPGType;

View File

@ -1,10 +1,5 @@
package com.antgroup.openspg.builder.core.reason;
import com.antgroup.kg.reasoner.catalog.impl.OpenKgCatalog;
import com.antgroup.kg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.kg.reasoner.graphstate.GraphState;
import com.antgroup.kg.reasoner.graphstate.impl.CloudExtGraphState;
import com.antgroup.kg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.builder.core.physical.process.BaseProcessor;
import com.antgroup.openspg.builder.core.reason.impl.CausalConceptReasoner;
import com.antgroup.openspg.builder.core.reason.impl.InductiveConceptReasoner;
@ -16,6 +11,11 @@ import com.antgroup.openspg.builder.model.record.BaseSPGRecord;
import com.antgroup.openspg.core.schema.model.semantic.DynamicTaxonomySemantic;
import com.antgroup.openspg.core.schema.model.semantic.LogicalCausationSemantic;
import com.antgroup.openspg.core.schema.model.type.ConceptList;
import com.antgroup.openspg.reasoner.catalog.impl.OpenSPGCatalog;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.openspg.reasoner.graphstate.GraphState;
import com.antgroup.openspg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.reasoner.warehouse.cloudext.CloudExtGraphState;
import com.antgroup.openspg.server.common.model.datasource.connection.GraphStoreConnectionInfo;
import com.google.common.collect.Lists;
import java.util.*;
@ -85,8 +85,8 @@ public class ReasonProcessor extends BaseProcessor<ReasonProcessor.ReasonerNodeC
}
private Catalog buildCatalog() {
OpenKgCatalog catalog =
new OpenKgCatalog(context.getProjectId(), null, context.getCatalog().getProjectSchema());
Catalog catalog =
new OpenSPGCatalog(context.getProjectId(), null, context.getCatalog().getProjectSchema());
catalog.init();
return catalog;
}

View File

@ -13,19 +13,14 @@
package com.antgroup.openspg.builder.core.reason;
import com.antgroup.kg.reasoner.common.graph.edge.IEdge;
import com.antgroup.kg.reasoner.common.graph.property.IProperty;
import com.antgroup.kg.reasoner.common.graph.vertex.IVertex;
import com.antgroup.kg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.kg.reasoner.local.model.LocalReasonerResult;
import com.antgroup.openspg.builder.core.runtime.BuilderCatalog;
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.BaseSPGRecord;
import com.antgroup.openspg.builder.model.record.RelationRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyValue;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
import com.antgroup.openspg.common.util.CollectionsUtils;
import com.antgroup.openspg.core.schema.model.identifier.RelationIdentifier;
import com.antgroup.openspg.core.schema.model.identifier.SPGTypeIdentifier;
@ -35,6 +30,11 @@ import com.antgroup.openspg.core.schema.model.semantic.SystemPredicateEnum;
import com.antgroup.openspg.core.schema.model.type.BaseSPGType;
import com.antgroup.openspg.core.schema.model.type.ConceptList;
import com.antgroup.openspg.core.schema.model.type.SPGTypeRef;
import com.antgroup.openspg.reasoner.common.graph.edge.IEdge;
import com.antgroup.openspg.reasoner.common.graph.property.IProperty;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertex;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.openspg.reasoner.runner.local.model.LocalReasonerResult;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

View File

@ -1,11 +1,5 @@
package com.antgroup.openspg.builder.core.reason.impl;
import com.antgroup.kg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.kg.reasoner.graphstate.GraphState;
import com.antgroup.kg.reasoner.local.KGReasonerLocalRunner;
import com.antgroup.kg.reasoner.local.model.LocalReasonerResult;
import com.antgroup.kg.reasoner.local.model.LocalReasonerTask;
import com.antgroup.kg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.builder.core.reason.ConceptReasoner;
import com.antgroup.openspg.builder.core.reason.ReasonerProcessorUtils;
import com.antgroup.openspg.builder.core.runtime.BuilderCatalog;
@ -17,6 +11,12 @@ import com.antgroup.openspg.core.schema.model.semantic.DynamicTaxonomySemantic;
import com.antgroup.openspg.core.schema.model.semantic.LogicalCausationSemantic;
import com.antgroup.openspg.core.schema.model.semantic.SystemPredicateEnum;
import com.antgroup.openspg.core.schema.model.type.ConceptList;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.openspg.reasoner.graphstate.GraphState;
import com.antgroup.openspg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.reasoner.runner.local.KGReasonerLocalRunner;
import com.antgroup.openspg.reasoner.runner.local.model.LocalReasonerResult;
import com.antgroup.openspg.reasoner.runner.local.model.LocalReasonerTask;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,17 +1,17 @@
package com.antgroup.openspg.builder.core.reason.impl;
import com.antgroup.kg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.kg.reasoner.graphstate.GraphState;
import com.antgroup.kg.reasoner.local.KGReasonerLocalRunner;
import com.antgroup.kg.reasoner.local.model.LocalReasonerResult;
import com.antgroup.kg.reasoner.local.model.LocalReasonerTask;
import com.antgroup.kg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.builder.core.reason.ConceptReasoner;
import com.antgroup.openspg.builder.core.reason.ReasonerProcessorUtils;
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.BaseRecord;
import com.antgroup.openspg.builder.model.record.BaseSPGRecord;
import com.antgroup.openspg.core.schema.model.semantic.DynamicTaxonomySemantic;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.openspg.reasoner.graphstate.GraphState;
import com.antgroup.openspg.reasoner.lube.catalog.Catalog;
import com.antgroup.openspg.reasoner.runner.local.KGReasonerLocalRunner;
import com.antgroup.openspg.reasoner.runner.local.model.LocalReasonerResult;
import com.antgroup.openspg.reasoner.runner.local.model.LocalReasonerTask;
import com.google.common.collect.Lists;
import java.util.List;
import lombok.Setter;

View File

@ -9,22 +9,4 @@ import spock.lang.Specification
class DefaultBuilderExecutorTest extends Specification {
def eval1() {
given:
Pipeline pipeline1 = genPipeline1()
BuilderExecutor builderExecutor = new DefaultBuilderExecutor()
when:
def logicalPlan = LogicalPlan.parse(pipeline1)
def physicalPlan = PhysicalPlan.plan(logicalPlan)
then:
builderExecutor.eval()
}
private def genPipeline1() {
def node1 = new Node()
def node2 = new Node()
def node3 = new Node()
}
}

View File

@ -19,9 +19,11 @@ import java.util.List;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@Accessors(chain = true)
@SuppressWarnings({"unchecked", "rawtypes"})
public class SPGPropertyValue extends BaseValObj {

View File

@ -59,6 +59,6 @@ class PipelineTest extends Specification {
Pipeline pipeline = new Pipeline([node1, node2, node3], [edge1, edge2]);
expect:
BuilderJsonUtils.serialize(pipeline) == '''{"nodes":[{"id":"1","name":"csv","nodeConfig":{"@type":"CSV_SOURCE","startRow":2,"url":"./data/App.csv","columns":["id","riskMark","useCert"],"type":"CSV_SOURCE"}},{"id":"2","name":"mapping","nodeConfig":{"@type":"SPG_TYPE_MAPPING","spgType":"RiskMining.App","mappingFilters":[],"mappingConfigs":[{"source":"id","target":"id"},{"source":"id","target":"name"},{"source":"riskMark","target":"riskMark"},{"source":"useCert","target":"userCert","normalizerConfig":{"@type":"OPERATOR","operatorConfig":{"filePath":"examples/riskmining/builder/operator/cert_link_operator.py","modulePath":"cert_link_operator","className":"CertLinkerOperator","method":"handle","uniqueKey":{}},"normalizerType":"OPERATOR"}}],"type":"SPG_TYPE_MAPPING"}},{"id":"3","name":"sink","nodeConfig":{"@type":"GRAPH_SINK","type":"GRAPH_SINK"}}],"edges":[{"from":"1","to":"2"},{"from":"2","to":"3"}]}'''
BuilderJsonUtils.serialize(pipeline) == '''{"nodes":[{"id":"1","name":"csv","nodeConfig":{"@type":"CSV_SOURCE","startRow":2,"url":"./data/App.csv","columns":["id","riskMark","useCert"],"type":"CSV_SOURCE"}},{"id":"2","name":"mapping","nodeConfig":{"@type":"SPG_TYPE_MAPPING","spgType":"RiskMining.App","mappingFilters":[],"mappingConfigs":[{"source":"id","target":"id"},{"source":"id","target":"name"},{"source":"riskMark","target":"riskMark"},{"source":"useCert","target":"userCert","normalizerConfig":{"@type":"OPERATOR","operatorConfig":{"filePath":"examples/riskmining/builder/operator/cert_link_operator.py","modulePath":"cert_link_operator","className":"CertLinkerOperator","method":"handle"},"normalizerType":"OPERATOR"}}],"type":"SPG_TYPE_MAPPING"}},{"id":"3","name":"sink","nodeConfig":{"@type":"GRAPH_SINK","type":"GRAPH_SINK"}}],"edges":[{"from":"1","to":"2"},{"from":"2","to":"3"}]}'''
}
}

View File

@ -38,6 +38,7 @@
<module>core</module>
<module>model</module>
<module>runner/local</module>
<module>testdata</module>
</modules>
<properties/>

23
builder/testdata/pom.xml vendored Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.antgroup.openspg.builder</groupId>
<artifactId>builder-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>builder-testdata</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg.builder</groupId>
<artifactId>builder-model</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.server</groupId>
<artifactId>testdata</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,39 @@
package com.antgroup.openspg.builder.test;
import com.antgroup.openspg.builder.model.record.EntityRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyValue;
import com.antgroup.openspg.server.testdata.RiskMiningSchema;
import com.google.common.collect.Lists;
public class RiskMiningRecord {
public static final EntityRecord PERSON_RECORD1 =
new EntityRecord(
RiskMiningSchema.PERSON,
"0",
Lists.newArrayList(
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("name"),
new SPGPropertyValue("裘**")),
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("age"), new SPGPropertyValue("58")),
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("hasPhone"),
new SPGPropertyValue("154****7458"))));
public static final EntityRecord PERSON_RECORD1_NORMALIZED =
new EntityRecord(
RiskMiningSchema.PERSON,
"0",
Lists.newArrayList(
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("name"),
new SPGPropertyValue("裘**").setStds(Lists.newArrayList("裘**"))),
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("age"),
new SPGPropertyValue("58").setStds(Lists.newArrayList(58L))),
new SPGPropertyRecord(
RiskMiningSchema.PERSON.getPropertyMap().get("hasPhone"),
new SPGPropertyValue("154****7458").setStds(Lists.newArrayList("154****7458")))));
}

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Ant Group CO., Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>cloudext-impl-object-store-local</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-object-store</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,48 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.impl.objectstore.local;
import com.antgroup.openspg.cloudext.interfaces.objectstore.ObjectStoreClient;
import com.antgroup.openspg.cloudext.interfaces.objectstore.cmd.ObjectStoreSaveCmd;
import com.antgroup.openspg.cloudext.interfaces.objectstore.model.ObjectStorePath;
import com.antgroup.openspg.server.common.model.datasource.connection.ObjectStoreConnectionInfo;
import java.io.File;
import java.io.IOException;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
public class LocalObjectStoreClient implements ObjectStoreClient {
@Getter private final ObjectStoreConnectionInfo connInfo;
private final String localRootDir;
public LocalObjectStoreClient(ObjectStoreConnectionInfo connInfo) {
this.connInfo = connInfo;
this.localRootDir = (String) connInfo.getNotNullParam("localDir");
}
@Override
public ObjectStorePath save(ObjectStoreSaveCmd cmd) {
ObjectStorePath path = cmd.getPath();
File file = new File("./" + localRootDir + "/" + path.getRelativePath());
try {
FileUtils.copyInputStreamToFile(cmd.getInputStream(), file);
} catch (IOException e) {
throw new RuntimeException(e);
}
path.setAbsolutePath(file.getAbsolutePath());
return path;
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.impl.objectstore.local;
import com.antgroup.openspg.cloudext.interfaces.objectstore.ObjectStoreClient;
import com.antgroup.openspg.cloudext.interfaces.objectstore.ObjectStoreClientDriver;
import com.antgroup.openspg.cloudext.interfaces.objectstore.ObjectStoreClientDriverManager;
import com.antgroup.openspg.server.common.model.datasource.connection.ObjectStoreConnectionInfo;
public class LocalObjectStoreClientDriver implements ObjectStoreClientDriver {
static {
ObjectStoreClientDriverManager.registerDriver(new LocalObjectStoreClientDriver());
}
@Override
public String driverScheme() {
return "local";
}
@Override
public ObjectStoreClient connect(ObjectStoreConnectionInfo connInfo) {
return new LocalObjectStoreClient(connInfo);
}
}

View File

@ -32,7 +32,7 @@ import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query
import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query.QueryGroup;
import com.antgroup.openspg.cloudext.interfaces.searchengine.model.request.query.TermQuery;
import com.antgroup.openspg.common.util.StringUtils;
import com.antgroup.openspg.server.api.facade.JSON;
import com.antgroup.openspg.server.api.facade.SchemaJsonUtils;
import com.dtflys.forest.http.ForestResponse;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
@ -93,7 +93,8 @@ public class ElasticSearchRecordUtils {
throw new RuntimeException("mGetIdxRecords error, errorMsg=" + response.getContent());
}
EsDocs esDocs = JSON.deserialize(response.getContent(), new TypeToken<EsDocs>() {}.getType());
EsDocs esDocs =
SchemaJsonUtils.deserialize(response.getContent(), new TypeToken<EsDocs>() {}.getType());
return esDocs.toIdxRecord();
}
@ -119,7 +120,7 @@ public class ElasticSearchRecordUtils {
if (StringUtils.isBlank(hits)) {
return Collections.emptyList();
}
EsHits esHits = JSON.deserialize(hits, new TypeToken<EsHits>() {}.getType());
EsHits esHits = SchemaJsonUtils.deserialize(hits, new TypeToken<EsHits>() {}.getType());
return esHits.toIdxRecord();
}

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Ant Group CO., Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>cloudext-impl-table-store-local</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-table-store</artifactId>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,75 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.impl.tablestore.local;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableFileHandler;
import com.antgroup.openspg.cloudext.interfaces.tablestore.model.TableRecord;
import com.opencsv.CSVWriter;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
public class LocalTableFileHandler implements TableFileHandler {
private final CSVWriter csvWriter;
private final String tableName;
private static final int DEFAULT_BUFFER_SIZE = 1000;
private final Queue<String[]> buffer;
public LocalTableFileHandler(CSVWriter csvWriter, String tableName) {
this.csvWriter = csvWriter;
this.tableName = tableName;
buffer = new ArrayBlockingQueue<>(DEFAULT_BUFFER_SIZE);
}
@Override
public String getTableName() {
return tableName;
}
@Override
public int write(TableRecord record) {
if (record.getValues() != null && record.getValues().length > 0) {
buffer.add(Arrays.stream(record.getValues()).map(Object::toString).toArray(String[]::new));
if (buffer.size() == DEFAULT_BUFFER_SIZE) {
flushBuffer();
}
return 1;
}
return 0;
}
@Override
public int batchWrite(List<TableRecord> records) {
for (TableRecord record : records) {
write(record);
}
return records.size();
}
private synchronized void flushBuffer() {
while (!buffer.isEmpty()) {
csvWriter.writeNext(buffer.poll());
}
}
@Override
public void close() throws Exception {
if (csvWriter != null) {
flushBuffer();
csvWriter.close();
}
}
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.impl.tablestore.local;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableFileHandler;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableStoreClient;
import com.antgroup.openspg.cloudext.interfaces.tablestore.cmd.TableFileCreateCmd;
import com.antgroup.openspg.cloudext.interfaces.tablestore.model.ColumnMeta;
import com.antgroup.openspg.common.util.tuple.Tuple2;
import com.antgroup.openspg.server.common.model.datasource.connection.TableStoreConnectionInfo;
import com.opencsv.CSVWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import lombok.Getter;
public class LocalTableStoreClient implements TableStoreClient {
@Getter private final TableStoreConnectionInfo connInfo;
private final String localRootDir;
public LocalTableStoreClient(TableStoreConnectionInfo connInfo) {
this.connInfo = connInfo;
this.localRootDir = (String) connInfo.getNotNullParam("localDir");
new File("./" + localRootDir).mkdirs();
}
@Override
public TableFileHandler create(TableFileCreateCmd cmd) {
try {
Tuple2<CSVWriter, String> tuple2 = buildCsvWriter(cmd);
return new LocalTableFileHandler(tuple2.first, tuple2.second);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
private Tuple2<CSVWriter, String> buildCsvWriter(TableFileCreateCmd cmd) throws IOException {
String filePath = "./" + localRootDir + "/" + cmd.getName() + ".csv";
CSVWriter csvWriter = new CSVWriter(new FileWriter(filePath));
String[] columns =
Arrays.stream(cmd.getColumns()).map(ColumnMeta::getName).toArray(String[]::new);
csvWriter.writeNext(columns);
return Tuple2.of(csvWriter, filePath);
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.impl.tablestore.local;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableStoreClient;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableStoreClientDriver;
import com.antgroup.openspg.cloudext.interfaces.tablestore.TableStoreClientDriverManager;
import com.antgroup.openspg.server.common.model.datasource.connection.TableStoreConnectionInfo;
public class LocalTableStoreClientDriver implements TableStoreClientDriver {
static {
TableStoreClientDriverManager.registerDriver(new LocalTableStoreClientDriver());
}
@Override
public String driverScheme() {
return "local";
}
@Override
public TableStoreClient connect(TableStoreConnectionInfo connInfo) {
return new LocalTableStoreClient(connInfo);
}
}

View File

@ -32,5 +32,9 @@
<groupId>com.antgroup.openspg.builder</groupId>
<artifactId>builder-model</artifactId>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.builder</groupId>
<artifactId>builder-testdata</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -18,8 +18,8 @@ import com.antgroup.openspg.builder.model.record.RecordAlterOperationEnum;
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
import com.antgroup.openspg.cloudext.interfaces.graphstore.BaseLPGGraphStoreClient;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.OneHopLPGRecordQuery;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.Direction;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;

View File

@ -15,7 +15,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.
import com.antgroup.openspg.builder.model.record.RelationRecord;
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.EdgeRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
import com.google.common.collect.Lists;
import java.util.List;

View File

@ -15,7 +15,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.SPGRecordAlterItem;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util.VertexRecordConvertor;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGRecordAlterItem;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord;
import java.util.List;

View File

@ -11,7 +11,7 @@
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.RelationRecord;
@ -19,7 +19,6 @@ import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.EdgeRecord;
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName;
import com.antgroup.openspg.core.schema.model.predicate.Relation;
import com.antgroup.openspg.core.schema.model.type.SPGTypeRef;
import com.antgroup.openspg.server.common.model.exception.GraphStoreException;
import java.util.Collections;
import java.util.List;
@ -29,6 +28,7 @@ import java.util.stream.Collectors;
/** Convertor for {@link EdgeRecord} and {@link RelationRecord}. */
public class EdgeRecordConvertor {
/** Convert the SPG record to an LPG record. */
public static EdgeRecord toEdgeRecord(RelationRecord relationRecord) {
Relation relationType = relationRecord.getRelationType();
return new EdgeRecord(
@ -42,19 +42,9 @@ public class EdgeRecordConvertor {
}
/**
* Convert {@link SPGPropertyRecord} in {@link BaseAdvancedRecord} into edge records.
* Specifically, {@link BaseAdvancedRecord#getName()}, {@link BaseAdvancedRecord#getId()}, {@link
* SPGPropertyRecord#getName()}, {@link SPGTypeRef#getName()} from {@link SPGPropertyRecord}, and
* be assigned to start vertex's type name, start vertex's ID, edge label, and end vertex's type
* name of {@link EdgeRecord}s. And end vertex's IDs of {@link EdgeRecord}s will be split from
* {@link SPGPropertyRecord#getValue()}
*
* @param advancedRecord advanced record, such as {@link
* com.antgroup.openspg.builder.model.record.EventRecord EventRecord}, {@link
* com.antgroup.openspg.builder.model.record.EntityRecord EntityRecord} and {@link
* com.antgroup.openspg.builder.model.record.ConceptRecord ConceptRecord}.
* @param spgPropertyRecord record of <tt>SPG</tt> property.
* @return a list of {@link EdgeRecord}s
* For an advanced SPG record, when one of its property types is also an advanced type, an edge
* will be created between the current instance and the instance corresponding to that property
* value.
*/
public static List<EdgeRecord> toEdgeRecords(
BaseAdvancedRecord advancedRecord, SPGPropertyRecord spgPropertyRecord) {
@ -77,6 +67,10 @@ public class EdgeRecordConvertor {
.collect(Collectors.toList());
}
/**
* Convert the LPG record to an SPG record, mainly used in the mapping or reasoning process of
* knowledge builder.
*/
public static RelationRecord toRelationRecord(
Relation relationType, String srcId, String dstId, Map<String, String> properties) {
return new RelationRecord(

View File

@ -11,7 +11,7 @@
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
import com.antgroup.openspg.builder.model.record.property.BasePropertyRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
@ -29,6 +29,7 @@ import org.apache.commons.collections4.MapUtils;
/** Convertor for {@link LPGPropertyRecord} and {@link SPGPropertyRecord}. */
public class PropertyRecordConvertor {
/** Convert the SPG record to an LPG record. */
public static List<LPGPropertyRecord> toLPGProperties(
List<? extends BasePropertyRecord> propertyRecords) {
List<LPGPropertyRecord> resultProperties = new ArrayList<>(propertyRecords.size());
@ -45,6 +46,7 @@ public class PropertyRecordConvertor {
return resultProperties;
}
/** Convert the LPG record to an SPG record. */
public static List<SPGPropertyRecord> toSPGProperties(
Map<String, String> properties, BaseSPGType spgType) {
if (MapUtils.isEmpty(properties)) {
@ -64,6 +66,7 @@ public class PropertyRecordConvertor {
return spgPropertyRecords;
}
/** Convert the LPG record to an SPG record. */
public static List<SPGSubPropertyRecord> toSPGProperties(
Map<String, String> properties, Property spgProperty) {
if (!spgProperty.hasSubProperty()) {

View File

@ -11,7 +11,7 @@
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.record.impl.convertor;
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util;
import com.antgroup.openspg.builder.model.record.BaseAdvancedRecord;
import com.antgroup.openspg.builder.model.record.ConceptRecord;
@ -39,6 +39,7 @@ import java.util.stream.Collectors;
*/
public class VertexRecordConvertor {
/** Convert the SPG record to an LPG record. */
public static VertexRecord toVertexRecord(BaseAdvancedRecord advancedRecord) {
return new VertexRecord(
advancedRecord.getId(),
@ -46,6 +47,10 @@ public class VertexRecordConvertor {
PropertyRecordConvertor.toLPGProperties(advancedRecord.getProperties()));
}
/**
* Convert the SPG property record to an LPG record, which is currently used only for standard
* types, as a standard type will automatically generate an LPG record based on the property.
*/
public static List<VertexRecord> toVertexRecords(SPGPropertyRecord propertyRecord) {
if (propertyRecord.isBasicType()) {
throw GraphStoreException.unexpectedSPGPropertyRecordType(propertyRecord);
@ -57,6 +62,10 @@ public class VertexRecordConvertor {
.collect(Collectors.toList());
}
/**
* Convert the LPG record to an SPG record, mainly used in the mapping or reasoning process of
* knowledge builder.
*/
public static BaseAdvancedRecord toAdvancedRecord(
BaseSPGType baseSpgType, String bizId, Map<String, String> properties) {
BaseAdvancedRecord advancedRecord = null;

View File

@ -18,6 +18,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
@ -32,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils;
* </ul>
*/
@Getter
@EqualsAndHashCode(callSuper = false)
public abstract class BaseLPGRecord extends BaseValObj {
private final LPGRecordTypeEnum recordType;

View File

@ -15,6 +15,7 @@ package com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record;
import com.antgroup.openspg.core.schema.model.type.BasicTypeEnum;
import com.antgroup.openspg.server.common.model.base.BaseValObj;
import lombok.EqualsAndHashCode;
import lombok.Getter;
/**
@ -34,6 +35,7 @@ import lombok.Getter;
* </ul>
*/
@Getter
@EqualsAndHashCode(callSuper = false)
public class LPGPropertyRecord extends BaseValObj {
/** The property name */

View File

@ -18,6 +18,8 @@ import com.antgroup.openspg.server.api.facade.ApiConstants;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@ -26,6 +28,7 @@ import lombok.Setter;
* VertexType} in <tt>LPG</tt>, identified by vertex id <tt>(id)</tt>.
*/
@Getter
@EqualsAndHashCode(callSuper = true)
public class VertexRecord extends BaseLPGRecord {
@Setter private String vertexType;
@ -45,13 +48,13 @@ public class VertexRecord extends BaseLPGRecord {
return otherProperties;
}
public Map<String, Map<Long, Object>> toPropertyMapWithIdAndVersion() {
public Map<String, TreeMap<Long, Object>> toPropertyMapWithIdAndVersion() {
Map<String, Object> otherProperties = toPropertyMapWithId();
Map<String, Map<Long, Object>> results = new HashMap<>(otherProperties.size());
Map<String, TreeMap<Long, Object>> results = new HashMap<>(otherProperties.size());
otherProperties.forEach(
(key, value) -> {
Map<Long, Object> propertyVersion = new HashMap<>(1);
TreeMap<Long, Object> propertyVersion = new TreeMap<>();
propertyVersion.put(ApiConstants.DEFAULT_VERSION, value);
results.put(key, propertyVersion);
});

View File

@ -0,0 +1,19 @@
package com.antgroup.openspg.cloudext.interfaces.graphstore
import com.antgroup.openspg.builder.test.RiskMiningRecord
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.LPGPropertyRecord
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord
import spock.lang.Specification
class RiskMiningLPGRecord extends Specification {
public final static VertexRecord PERSON_RECORD1 = new VertexRecord(
RiskMiningRecord.PERSON_RECORD1.id,
RiskMiningRecord.PERSON_RECORD1.getName(),
[
new LPGPropertyRecord("name", "裘**"),
new LPGPropertyRecord("age", 58L),
new LPGPropertyRecord("hasPhone", "154****7458"),
]
);
}

View File

@ -0,0 +1,17 @@
package com.antgroup.openspg.cloudext.interfaces.graphstore.adapter.util
import com.antgroup.openspg.builder.test.RiskMiningRecord
import com.antgroup.openspg.cloudext.interfaces.graphstore.RiskMiningLPGRecord
import spock.lang.Specification
class VertexRecordConvertorTest extends Specification {
def testToVertexRecord() {
expect:
outputRecord == VertexRecordConvertor.toVertexRecord(inputRecord)
where:
inputRecord || outputRecord
RiskMiningRecord.PERSON_RECORD1_NORMALIZED || RiskMiningLPGRecord.PERSON_RECORD1
}
}

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Ant Group CO., Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>cloudext-interface-object-store</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg</groupId>
<artifactId>common-util</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,20 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.objectstore;
import com.antgroup.openspg.common.util.cloudext.CloudExtClientDriver;
import com.antgroup.openspg.server.common.model.datasource.connection.ObjectStoreConnectionInfo;
public interface ObjectStoreClientDriver
extends CloudExtClientDriver<ObjectStoreClient, ObjectStoreConnectionInfo> {}

View File

@ -1,52 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.objectstore;
import com.antgroup.openspg.common.util.DriverManagerUtils;
import com.antgroup.openspg.server.common.model.datasource.connection.ObjectStoreConnectionInfo;
import com.antgroup.openspg.server.common.model.exception.CloudExtException;
import java.util.concurrent.CopyOnWriteArrayList;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ObjectStoreClientDriverManager {
private static final CopyOnWriteArrayList<ObjectStoreClientDriver> registeredDrivers =
new CopyOnWriteArrayList<>();
private ObjectStoreClientDriverManager() {}
static {
DriverManagerUtils.loadDrivers("cloudext.objectstore.drivers", ObjectStoreClientDriver.class);
log.info("object-store DriverManager initialized");
}
public static synchronized void registerDriver(ObjectStoreClientDriver driver) {
if (driver != null) {
registeredDrivers.addIfAbsent(driver);
} else {
throw new NullPointerException();
}
log.info("registerDriver: {}", driver);
}
public static ObjectStoreClient getClient(ObjectStoreConnectionInfo config) {
for (ObjectStoreClientDriver driver : registeredDrivers) {
if (driver.acceptsConfig(config)) {
return driver.connect(config);
}
}
throw CloudExtException.driverNotExist(config);
}
}

View File

@ -1,29 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.objectstore.cmd;
import com.antgroup.openspg.cloudext.interfaces.objectstore.model.ObjectStorePath;
import com.antgroup.openspg.server.common.model.base.BaseCmd;
import java.io.InputStream;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class ObjectStoreSaveCmd extends BaseCmd {
private final ObjectStorePath path;
private final InputStream inputStream;
}

View File

@ -1 +0,0 @@
com.antgroup.openspg.cloudext.impl.objectstore.local.LocalObjectStoreClientDriver

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 Ant Group CO., Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>cloudext-interface-table-store</artifactId>
<dependencies>
<dependency>
<groupId>com.antgroup.openspg</groupId>
<artifactId>common-util</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,20 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.tablestore;
import com.antgroup.openspg.common.util.cloudext.CloudExtClientDriver;
import com.antgroup.openspg.server.common.model.datasource.connection.TableStoreConnectionInfo;
public interface TableStoreClientDriver
extends CloudExtClientDriver<TableStoreClient, TableStoreConnectionInfo> {}

View File

@ -1,52 +0,0 @@
/*
* Copyright 2023 Ant Group CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*/
package com.antgroup.openspg.cloudext.interfaces.tablestore;
import com.antgroup.openspg.common.util.DriverManagerUtils;
import com.antgroup.openspg.server.common.model.datasource.connection.TableStoreConnectionInfo;
import com.antgroup.openspg.server.common.model.exception.CloudExtException;
import java.util.concurrent.CopyOnWriteArrayList;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TableStoreClientDriverManager {
private static final CopyOnWriteArrayList<TableStoreClientDriver> registeredDrivers =
new CopyOnWriteArrayList<>();
private TableStoreClientDriverManager() {}
static {
DriverManagerUtils.loadDrivers("cloudext.tablestore.drivers", TableStoreClientDriver.class);
log.info("table-store DriverManager initialized");
}
public static synchronized void registerDriver(TableStoreClientDriver driver) {
if (driver != null) {
registeredDrivers.addIfAbsent(driver);
} else {
throw new NullPointerException();
}
log.info("registerDriver: {}", driver);
}
public static TableStoreClient getClient(TableStoreConnectionInfo config) {
for (TableStoreClientDriver driver : registeredDrivers) {
if (driver.acceptsConfig(config)) {
return driver.connect(config);
}
}
throw CloudExtException.driverNotExist(config);
}
}

View File

@ -1 +0,0 @@
com.antgroup.openspg.cloudext.impl.tablestore.local.LocalTableStoreClientDriver

View File

@ -36,12 +36,8 @@
<modules>
<module>interface/graph-store</module>
<module>interface/object-store</module>
<module>interface/table-store</module>
<module>interface/search-engine</module>
<module>impl/graph-store/tugraph</module>
<module>impl/object-store/local</module>
<module>impl/table-store/local</module>
<module>impl/search-engine/elasticsearch</module>
</modules>

View File

@ -13,7 +13,7 @@
package com.antgroup.openspg.common.util;
import com.antgroup.openspg.server.api.facade.JSON;
import com.antgroup.openspg.server.api.facade.SchemaJsonUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ -22,7 +22,7 @@ public class JsonUtils {
public static String toJsonString(Object object) {
String result = null;
try {
result = JSON.serialize(object);
result = SchemaJsonUtils.serialize(object);
} catch (Exception e) {
log.error("toJsonString error, object={}", object, e);
result = StringUtils.toString(object);

View File

@ -1,46 +0,0 @@
version: "3.7"
services:
openspg:
restart: always
image: baifuyu/openspg:latest
container_name: release-openspg
ports:
- "8887:8887"
depends_on:
- mysql
- tugraph
command: [
'--cloudext.repository.impl.jdbc.host=mysql',
'--builder.operator.python.exec=/usr/bin/python3.8',
'--builder.operator.python.paths=/usr/lib/python3.8/site-packages;/usr/local/lib/python3.8/dist-packages;'
]
environment:
- PYTHONPATH=/usr/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages
mysql:
restart: always
image: baifuyu/openspg-mysql:latest
container_name: release-openspg-mysql
environment:
TZ: Asia/Shanghai
LANG: C.UTF-8
ports:
- "3306:3306"
command: [
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_general_ci'
]
tugraph:
image: tugraph/tugraph-runtime-centos7:4.0.1
container_name: release-openspg-tugraph
# default username is admin and default password is 73@TuGraph
ports:
- "7070:7070"
- "9090:9090"
command: lgraph_server

View File

@ -1,19 +1,44 @@
version: "3.7"
services:
openspg:
extends:
file: docker-compose-no-es.yml
service: openspg
restart: always
image: baifuyu/openspg:latest
container_name: release-openspg
ports:
- "8887:8887"
depends_on:
- mysql
- tugraph
command: [
'--cloudext.repository.impl.jdbc.host=mysql',
'--builder.operator.python.exec=/usr/bin/python3.8',
'--builder.operator.python.paths=/usr/lib/python3.8/site-packages;/usr/local/lib/python3.8/dist-packages;'
]
environment:
- PYTHONPATH=/usr/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages
mysql:
extends:
file: docker-compose-no-es.yml
service: mysql
restart: always
image: baifuyu/openspg-mysql:latest
container_name: release-openspg-mysql
environment:
TZ: Asia/Shanghai
LANG: C.UTF-8
ports:
- "3306:3306"
command: [
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_general_ci'
]
tugraph:
extends:
file: docker-compose-no-es.yml
service: tugraph
image: tugraph/tugraph-runtime-centos7:4.0.1
container_name: release-openspg-tugraph
# default username is admin and default password is 73@TuGraph
ports:
- "7070:7070"
- "9090:9090"
command: lgraph_server
elasticsearch:
image: elasticsearch:8.5.3

View File

@ -1,32 +0,0 @@
version: "3.7"
services:
mysql:
restart: always
image: mariadb:10.5.8
container_name: test-openspg-mysql
environment:
MYSQL_ROOT_PASSWORD: openspg
MYSQL_DATABASE: openspg
TZ: Asia/Shanghai
LANG: C.UTF-8
volumes:
- "./mysql/sqlscript:/docker-entrypoint-initdb.d"
ports:
- "3306:3306"
command: [
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_general_ci'
]
tugraph:
image: tugraph/tugraph-runtime-centos7:4.0.1
container_name: test-openspg-tugraph
# default username is admin and default password is 73@TuGraph
ports:
- "7070:7070"
- "9090:9090"
command: lgraph_server

View File

@ -1,14 +1,32 @@
version: "3.7"
services:
mysql:
extends:
file: docker-compose-no-es.yml
service: mysql
restart: always
image: mariadb:10.5.8
container_name: test-openspg-mysql
environment:
MYSQL_ROOT_PASSWORD: openspg
MYSQL_DATABASE: openspg
TZ: Asia/Shanghai
LANG: C.UTF-8
volumes:
- "./mysql/sqlscript:/docker-entrypoint-initdb.d"
ports:
- "3306:3306"
command: [
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_general_ci'
]
tugraph:
extends:
file: docker-compose-no-es.yml
service: tugraph
image: tugraph/tugraph-runtime-centos7:4.0.1
container_name: test-openspg-tugraph
# default username is admin and default password is 73@TuGraph
ports:
- "7070:7070"
- "9090:9090"
command: lgraph_server
elasticsearch:
image: elasticsearch:8.5.3

40
pom.xml
View File

@ -59,6 +59,26 @@
<dependencyManagement>
<dependencies>
<!-- openspg start -->
<dependency>
<groupId>com.antgroup.openspg.builder</groupId>
<artifactId>builder-testdata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.server</groupId>
<artifactId>testdata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-local-runner</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-cloudext-warehouse</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.server</groupId>
<artifactId>common-model</artifactId>
@ -99,31 +119,11 @@
<artifactId>cloudext-interface-search-engine</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-object-store</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-interface-table-store</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-graph-store-tugraph</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-object-store-local</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-table-store-local</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.cloudext</groupId>
<artifactId>cloudext-impl-search-engine-elasticsearch</artifactId>

View File

@ -1,7 +1,7 @@
[local]
project_name = Medical1
description = Medical1
project_id = 3
project_id = 2
namespace = Medical1
project_dir = medical1
schema_dir = schema

View File

@ -17,8 +17,8 @@ class Medical1:
description = "description"
id = "id"
name = "name"
alias = "alias"
stdId = "stdId"
alias = "alias"
def __init__(self):
pass
@ -28,11 +28,11 @@ class Medical1:
description = "description"
id = "id"
name = "name"
complication = "complication"
department = "department"
applicableDrug = "applicableDrug"
diseaseSite = "diseaseSite"
complication = "complication"
applicableDrug = "applicableDrug"
commonSymptom = "commonSymptom"
department = "department"
def __init__(self):
pass
@ -51,8 +51,8 @@ class Medical1:
description = "description"
id = "id"
name = "name"
stdId = "stdId"
alias = "alias"
stdId = "stdId"
def __init__(self):
pass

View File

@ -35,6 +35,9 @@ public interface IVertexId extends Serializable, Comparable<IVertexId> {
/** get kgstate internal id */
long getInternalId();
/** get biz id */
String getBizId();
/** get vertex type id */
long getTypeId();

View File

@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
import java.util.Comparator;
import lombok.Getter;
public class VertexId implements IVertexId {
/**
@ -33,6 +34,8 @@ public class VertexId implements IVertexId {
*/
private final byte[] vertexIdBytes;
@Getter private String bizId;
/** create vertex id */
public VertexId(long internalId, String type) {
this.vertexIdBytes = generateIdBytes(internalId, type);
@ -40,6 +43,7 @@ public class VertexId implements IVertexId {
public VertexId(String bizId, String type) {
this.vertexIdBytes = generateIdBytes(generateInternalId(bizId, type), type);
this.bizId = bizId;
}
public VertexId(byte[] bytes) {

Some files were not shown because too many files have changed in this diff Show More