Skip to content

Commit e1183dd

Browse files
committed
fix format issue and add vector option to properties
1 parent a6cca33 commit e1183dd

File tree

9 files changed

+61
-21
lines changed

9 files changed

+61
-21
lines changed

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedGraphTransaction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ public final class CachedGraphTransaction extends GraphTransaction {
6767
private EventListener cacheEventListener;
6868

6969
public CachedGraphTransaction(HugeGraphParams graph, BackendStore store) {
70-
super(graph, store);
70+
this(graph, store, null);
71+
}
72+
73+
public CachedGraphTransaction(HugeGraphParams graph, BackendStore store,
74+
BackendStore vectorStore) {
75+
super(graph, store, vectorStore);
7176

7277
HugeConfig conf = graph.configuration();
7378

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/VectorBackendEntry.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
*/
3434
public class VectorBackendEntry implements BackendEntry {
3535

36-
// 基础字段(实现BackendEntry接口)
36+
// Basic fields (implementing BackendEntry interface)
3737
private final HugeType type; // VECTOR_INDEX
38-
private final Id id; // 索引ID
39-
private final Id subId; // 顶点ID
38+
private final Id id; // index ID
39+
private final Id subId; // vertex ID
4040

41-
// 向量核心字段
42-
private final String vectorId; // 向量唯一标识
43-
private final float[] vector; // 向量数据
44-
private final String metricType; // 度量类型 (L2, COSINE, DOT)
45-
private final Integer dimension; // 向量维度
41+
// Vector core fields
42+
private final String vectorId; // vector id
43+
private final float[] vector; // vector data
44+
private final String metricType; // metric type (L2, COSINE, DOT)
45+
private final Integer dimension; // vector dimension
4646

4747
public VectorBackendEntry(HugeType type, Id id, Id subId,
4848
String vectorId, float[] vector,
@@ -56,7 +56,7 @@ public VectorBackendEntry(HugeType type, Id id, Id subId,
5656
this.dimension = dimension;
5757
}
5858

59-
// 实现BackendEntry接口
59+
// BackendEntry interface implementation
6060
@Override
6161
public HugeType type() {
6262
return this.type;
@@ -79,15 +79,15 @@ public Id subId() {
7979

8080
@Override
8181
public long ttl() {
82-
return 0L; // 向量索引不过期
82+
return 0L; // Vector index doesn't expire
8383
}
8484

8585
@Override
8686
public boolean olap() {
87-
return false; // 向量索引不是OLAP数据
87+
return false; // Vector index is not OLAP data
8888
}
8989

90-
// 向量特有方法
90+
// Vector-specific methods
9191
public String vectorId() {
9292
return this.vectorId;
9393
}
@@ -104,7 +104,7 @@ public Integer dimension() {
104104
return this.dimension;
105105
}
106106

107-
// 为了兼容BackendEntry接口,提供columns方法
107+
// For BackendEntry interface compatibility, provide columns method
108108
@Override
109109
public Collection<BackendColumn> columns() {
110110
List<BackendColumn> cols = new ArrayList<>();
@@ -128,7 +128,7 @@ public int columnsSize() {
128128

129129
@Override
130130
public void columns(Collection<BackendColumn> columns) {
131-
// 向量索引不支持动态添加列
131+
// Vector index doesn't support dynamic column addition
132132
throw new UnsupportedOperationException("VectorBackendEntry doesn't support dynamic columns");
133133
}
134134

@@ -144,7 +144,7 @@ public void merge(BackendEntry other) {
144144

145145
@Override
146146
public boolean mergeable(BackendEntry other) {
147-
return false; // 向量索引不支持合并
147+
return false; // Vector index doesn't support merging
148148
}
149149

150150
@Override
@@ -154,7 +154,7 @@ public void clear() {
154154

155155
@Override
156156
public boolean belongToMe(BackendColumn column) {
157-
// 向量索引的列都属于自己
157+
// All columns of vector index belong to itself
158158
return true;
159159
}
160160

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/AbstractTransaction.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,26 @@ public abstract class AbstractTransaction implements Transaction {
6262

6363
private final HugeGraphParams graph;
6464
private final BackendStore store;
65+
private final BackendStore vectorStore;
6566

6667
private BackendMutation mutation;
6768

6869
protected final AbstractSerializer serializer;
6970

70-
public AbstractTransaction(HugeGraphParams graph, BackendStore store) {
71+
public AbstractTransaction(HugeGraphParams graph, BackendStore store){
72+
this(graph, store, null);
73+
}
74+
75+
public AbstractTransaction(HugeGraphParams graph, BackendStore store,
76+
BackendStore vectorStore) {
7177
E.checkNotNull(graph, "graph");
7278
E.checkNotNull(store, "store");
7379

7480
this.graph = graph;
7581
this.serializer = this.graph.serializer();
7682

7783
this.store = store;
84+
this.vectorStore = vectorStore;
7885
this.reset();
7986

8087
store.open(this.graph.configuration());

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ public class GraphTransaction extends IndexableTransaction {
146146
new ConcurrentHashMap<>();
147147

148148
public GraphTransaction(HugeGraphParams graph, BackendStore store) {
149-
super(graph, store);
149+
this(graph, store, null);
150+
}
151+
152+
public GraphTransaction(HugeGraphParams graph, BackendStore store, BackendStore vectorStore) {
153+
super(graph, store, vectorStore);
150154

151155
this.indexTx = new GraphIndexTransaction(graph, store);
152156
assert !this.indexTx.autoCommit();

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/IndexableTransaction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public IndexableTransaction(HugeGraphParams graph, BackendStore store) {
2828
super(graph, store);
2929
}
3030

31+
public IndexableTransaction(HugeGraphParams graph, BackendStore store,
32+
BackendStore vectorStore) {
33+
super(graph, store, vectorStore);
34+
}
35+
3136
@Override
3237
public boolean hasUpdate() {
3338
AbstractTransaction indexTx = this.indexTransaction();

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,4 +710,18 @@ public static synchronized CoreOptions instance() {
710710
nonNegativeInt(),
711711
8L
712712
);
713+
714+
public static final ConfigOption<Boolean> VECTOR_ENABLED = new ConfigOption<>(
715+
"vector.enabled",
716+
"Whether to enable vector index",
717+
disallowEmpty(),
718+
false
719+
);
720+
721+
public static final ConfigOption<String> VECTOR_BACKEND = new ConfigOption<>(
722+
"vector.backend",
723+
"vector index backend",
724+
disallowEmpty(),
725+
"jvector"
726+
);
713727
}

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/IndexLabelBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ private void checkFields(Set<Id> propertyIds) {
533533
}
534534

535535
// Vector index must build on float list
536-
if(this.indexType.isVector()){
536+
if (this.indexType.isVector()) {
537537
E.checkArgument(fields.size() == 1,
538538
"vector index can only build on " +
539539
"one field, but got %s fields: '%s'",

hugegraph-server/hugegraph-dist/src/assembly/static/conf/graphs/hugegraph.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ search.text_analyzer_mode=INDEX
4343
#rocksdb.data_path=/path/to/disk
4444
#rocksdb.wal_path=/path/to/disk
4545

46+
#vector backend config
47+
#vector.enabled=false
48+
#vector.backend=jvector
49+
#vector.data_path=/path/to/disk
50+
#vector.wal_path=/path/to/disk
51+
4652
# hbase backend config
4753
#hbase.hosts=localhost
4854
#hbase.port=2181

hugegraph-server/hugegraph-vector/src/main/java/org/apache/hugegraph/backend/store/jvector/VectorFeatures.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public boolean supportsScanToken() {
3434
return false;
3535
}
3636

37-
3837
public boolean supportsDistributed() {
3938
return false;
4039
}

0 commit comments

Comments
 (0)