Skip to content

Commit

Permalink
translate remaining files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pengzna committed Aug 4, 2024
1 parent 5edad37 commit ad5f6fb
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@Slf4j
public class HgThread2DB {

/*正在进行和在排队的任务的总数*/
/* The total number of tasks in line and queuing*/
private static final AtomicInteger taskTotal = new AtomicInteger(0);
private static final AtomicInteger queryTaskTotal = new AtomicInteger(0);
private static final AtomicLong insertDataCount = new AtomicLong();
Expand Down Expand Up @@ -378,8 +378,8 @@ public void autoMultiprocessInsert() throws IOException {
}

public String getLong() {
//如果需要更长 或者更大冗余空间, 只需要 time * 10^n 即可
//当前可保证1毫秒 生成 10000条不重复
// If you need to be longer or more redundant space, you only need time * 10^n
// Currently guarantee that 1 millisecond generates 100,000 pieces without repeating
return String.format("%019x", longId.getAndIncrement());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
public final class HgNodePartition {

private final Long nodeId;
//当前key的hashcode
// The current key's hashcode
private final Integer keyCode;

//分区的开始结束范围
// The end of the start of the partition
private final Integer startKey;
private final Integer endKey;
private int hash = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean hasNext() {
try {
// The queue has data, and there is an active query device, and the task is not allocated
if (queue.size() != 0 || scanners.size() > 0 || !taskSplitter.isFinished()) {
current = queue.poll(1, TimeUnit.SECONDS); //定期检查client是否被关闭了
current = queue.poll(1, TimeUnit.SECONDS); // Check whether the client is closed regularly
} else {
break;
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public boolean hasNext() {
try {
int waitTime = 0;
Supplier<HgKvIterator<HgKvEntry>> current;
current = queue.poll(1, TimeUnit.SECONDS); //定期检查client是否被关闭了
current = queue.poll(1, TimeUnit.SECONDS); // Check whether the client is closed regularly
if (current == null) {
if (++waitTime > maxWaitCount) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class HeartbeatService implements Lifecycle<HgStoreEngineOptions>, PartitionStateListener {

private static final int MAX_HEARTBEAT_RETRY_COUNT = 5; // Heartbeat trial number
private static final int REGISTER_RETRY_INTERVAL = 1; //注册重试时间间隔,单位秒
private static final int REGISTER_RETRY_INTERVAL = 1; // Register the time interval between retry, the unit seconds
private final HgStoreEngine storeEngine;
private final List<HgStoreStateListener> stateListeners;
private final Object partitionThreadLock = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void deletePartition(Integer groupId, String graphName) {
ptEngine.removePartition(graphName);
// delete data
businessHandler.deletePartition(graphName, groupId);
//通知PD删除分区数据
// Inform PD to delete partition data
if (ptEngine.isLeader()) {
synchronized (this) {
partitionManager.deletePartition(graphName, groupId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public LogStorage createLogStorage(final String uri, final RaftOptions raftOptio

// Check whether the Peers returned by the PD is consistent with the local area. If it is not consistent, reset the peerlist
if (this.raftNode != null) {
//TODO 检查peer列表,如果peer发生改变,进行重置
// Todo check the peer list, if the peer changes, the reset
started = true;
}

Expand Down Expand Up @@ -630,7 +630,7 @@ public void onStartFollowing(final PeerId newLeaderId, final long newTerm) {
public void onConfigurationCommitted(Configuration conf) {

try {
//更新shardlist
// Update Shardlist
log.info("Raft {} onConfigurationCommitted, conf is {}", getGroupId(), conf.toString());
// Find Storeid according to RAFT ENDPOINT
List<Long> peerIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hugegraph.store;

import java.util.List;

import org.apache.hugegraph.pd.grpc.Metapb;
import org.apache.hugegraph.store.meta.Partition;
import org.apache.hugegraph.store.meta.PartitionRole;

public interface PartitionStateListener {

// The partition role changes
void partitionRoleChanged(Partition partition, PartitionRole newRole);

// The partition changes
void partitionShardChanged(Partition partition, List<Metapb.Shard> oldShards,
List<Metapb.Shard> newShards);
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ void loadSnapshot(String snapshotPath, String graph, int partId, long version) t
void ingestSstFile(String graph, int partId, Map<byte[], List<String>> sstFiles) throws
HgStoreException;

//提交分区分裂,删除旧数据
// Submit the division of division and delete the old data
// Delete partition data
boolean deletePartition(String graph, int partId);

//清理分区,删除多余的数据
// Clean up the partition and delete excess data
boolean cleanPartition(String graph, int partId);

boolean cleanPartition(String graph, int partId, long startKey, long endKey,
CleanType cleanType);

//所有指定分区图的所有 table
// All the table names of all specified partition maps
List<String> getTableNames(String graph, int partId);

TxBuilder txBuilder(String graph, int partId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public RocksDBSession getSession(int partId) throws HgStoreException {
"failed to create a new graph db: {}", dbName);
}
}
dbSession.setDisableWAL(true); //raft 模式,关闭 rocksdb 日志
dbSession.setDisableWAL(true); // RAFT mode, turn off the Rocksdb log
return dbSession;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class InnerKeyFilter<T extends BackendColumn> implements ScanIterator {

final int codeFrom;
final int codeTo;
//是否进行code过滤,启动该选项,返回key的尾部包含code
// Whether Code filtering, start the option, and return the tail of the key to contain CODE
final boolean codeFilter;
ScanIterator iterator;
T current = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public Partition getPartitionFromPD(String graph, int partId) {
if (partitions.containsKey(graph)) {
Partition local = partitions.get(graph).get(partId);
if (local != null) {
//更新本地的key范围,保证pd和本地分区信息的一致性
// Update the local key range to ensure the consistency of PD and local partition information
local.setStartKey(partition.getStartKey());
local.setEndKey(partition.getEndKey());
savePartition(local, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Store {
private int dataVersion;
private int partitionCount;
private int startTime;
private int usedSize; //rocksdb存储大小
private int usedSize; // Rocksdb storage size
private int pdHeartbeatInterval;
private Metapb.StoreState state;
private Map<String, String> labels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HgStoreException extends RuntimeException {

public final static int EC_NOEXCEPT = 0;
public final static int EC_FAIL = 1000;
//存储的数据格式不支持
// The stored data format does not support
public final static int EC_DATAFMT_NOT_SUPPORTED = 1001;
public final static int EC_RKDB_CREATE_FAIL = 1201;
public final static int EC_RKDB_DOPUT_FAIL = 1202;
Expand Down
4 changes: 2 additions & 2 deletions hugegraph-store/hg-store-grpc/src/main/proto/graphpb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ message Property{
message Vertex{
int64 label = 1; // point type
Variant id = 2; // point ID
repeated Property properties = 3; //点属性
repeated Property properties = 3; // point attributes
}

message Edge{
Expand All @@ -86,7 +86,7 @@ message Edge{
Variant source_id = 4; // source point ID
Variant target_id = 5; // sink point ID

repeated Property properties = 6; //边属性
repeated Property properties = 6; // border attribute
}

message Variant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public class AppConfig {
@Value("${server.port}")
private int restPort;

//内置pd模式,用于单机部署
// Built in PD mode, for single -machine deployment
@Value("${app.data-path: store}")
private String dataPath;

@Value("${app.raft-path:}")
private String raftPath;

//内置pd模式,用于单机部署
// Built in PD mode, for single -machine deployment
@Value("${app.fake-pd: false}")
private boolean fakePd;
@Autowired
Expand Down Expand Up @@ -209,7 +209,7 @@ public class FakePdConfig {
@Value("${fake-pd.store-list:''}")
private String storeList;
@Value("${fake-pd.peers-list:''}")
private String peersList; //fakePd模式下,raft集群初始配置
private String peersList; // Fakepd mode, the initial configuration of the Ra
@Value("${fake-pd.partition-count:3}")
private int partitionCount;
@Value("${fake-pd.shard-count:3}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void run() {
doSomethingForShutdown();

try {
mainThread.join(); //当收到停止信号时,等待mainThread的执行完成
mainThread.join(); // When receiving a stop signal, wait for the execution of Mainthread to complete
} catch (InterruptedException ignored) {
}
System.out.println("Shut down complete.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public boolean hasNext() {
while (current == null && tryTimes < waitDataMaxTryTimes) {
try {
if (queue.size() != 0 || !finished) {
current = queue.poll(100, TimeUnit.MILLISECONDS); //定期检查client是否被关闭了
current = queue.poll(100, TimeUnit.MILLISECONDS); // Check whether the client is closed regularly
if (current == null && !finished) {
wakeUpScanner();
}
Expand Down Expand Up @@ -343,7 +343,7 @@ public void scanKV() {
if ((entriesSize >= batchSize || bodySize >= maxBodySize) ||
(orderEdge && bodySize >= maxBodySize / 2)) {
if (orderEdge) {
//边排序,保证一个点的所有边连续,阻止其他点插入
// Sort the side to ensure that all the edges of a point are continuous, prevent other points from inserting
canNext = putData(dataList, iterator != null && iterator.hasNext());
} else {
canNext = putData(dataList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ScanBatchResponse implements StreamObserver<ScanStreamBatchReq> {
static ByteBufferAllocator alloc =
new ByteBufferAllocator(ParallelScanIterator.maxBodySize * 3 / 2, 1000);
private final int maxInFlightCount = PropertyUtil.getInt("app.scan.stream.inflight", 16);
private final int activeTimeout = PropertyUtil.getInt("app.scan.stream.timeout", 60); //单位秒
private final int activeTimeout = PropertyUtil.getInt("app.scan.stream.timeout", 60); // Unit seconds
private final StreamObserver<KvStream> sender;
private final HgStoreWrapperEx wrapper;
private final ThreadPoolExecutor executor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void destroyGraphDB(String dbName) {
log.info("destroy {} 's rocksdb.", dbName);
RocksDBSession dbSession = dbSessionMap.get(dbName);
releaseGraphDB(dbName);
//增加删除标记
// Add deletion tags
if (dbSession != null) {
destroyGraphDBs.add(new DBSessionWatcher(dbSession));
rocksdbChangedListeners.forEach(listener -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public ScanIterator scan(String tableName, byte[] keyFrom, byte[] keyTo, int sca
*/
@Override
public ScanIterator scanRaw(byte[] keyFrom, byte[] keyTo, long startSeqNum) {
int kNumInternalBytes = 8; //internal key 增加的8个字节后缀
int kNumInternalBytes = 8; // 8 byte suffixes added by Internet key
Snapshot snapshot = rocksdb().getSnapshot();
Iterator<String> cfIterator = session.getTables().keySet().iterator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void batchGet() {

// @Test
//CAUTION: ONLY FOR LONG!
//注意:目前只可以对long类型value进行Merge操作。
// Note: At present, you can only perform Merge operations on the LONG type Value.
public void merge() {
System.out.println("--- test merge (1+1=2)---");
HgStoreSession session = getStoreSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void batchGet() {

// @Test
//CAUTION: ONLY FOR LONG!
//注意:目前只可以对long类型value进行Merge操作。
// Note: At present, you can only perform Merge operations on the LONG type Value.
public void merge() {
System.out.println("--- test merge (1+1=2)---");
HgStoreSession session = getStoreSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void testBatchPutMultiGraph() throws IOException {

// @Test
//CAUTION: ONLY FOR LONG!
//注意:目前只可以对long类型value进行Merge操作。
// Note: At present, you can only perform Merge operations on the LONG type Value.
public void merge() {
System.out.println("--- test merge (1+1=2)---");
HgStoreSession session = getStoreSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void batchPrefix() {

@Test
//CAUTION: ONLY FOR LONG!
//注意:目前只可以对 long 类型 value 进行 Merge 操作。
// Note: At present, you can only perform Merge operations on the LONG type Value.
public void merge() {
System.out.println("--- test merge (1+1=2)---");
HgStoreSession session = getStoreSession();
Expand Down

0 comments on commit ad5f6fb

Please sign in to comment.