forked from hugegraph/hugegraph-sync
fix: mismatch table name when parsing BatchEntry
fix https://github.com/hugegraph/store/pull/4 When the server uses hstore as the backend, taking writing a vertex as an example. The server will construct an `HgStoreSession` using graphspace and graph, like `DEFAULT/hugegraph/g`. Then it calls the `put` method of `HgStoreSession`, passing the corresponding table (here it is `g+v`), key, and value. ```java @Override public void put(String table, byte[] ownerKey, byte[] key, byte[] value) { prepare(); this.graph.put(table, HgOwnerKey.of(ownerKey, key), value); } ``` The store client will encapsulate this write operation as an RPC request in the following format: ```protobuf message BatchEntry { OpType op_type = 1; int32 table = 2; // NOTE HERE Key start_key = 3; Key end_key = 4; bytes value = 5; } ``` https://github.com/hugegraph/store/pull/4 actually fixes the logic that maps `g+v` to the corresponding code. However, after receiving `BatchEntry`, the store still needs to parse the corresponding table name based on the code. ```java default void doBatch(String graph, int partId, List<BatchEntry> entryList) { BusinessHandler.TxBuilder builder = txBuilder(graph, partId); try { for (BatchEntry b : entryList) { Key start = b.getStartKey(); String table = tables[b.getTable()]; // NOTE HERE ``` This step was ignored in https://github.com/hugegraph/store/pull/4, resulting in the actual table being written into the store as `vertex` (the old table name).
This commit is contained in:
parent
61a8bedd70
commit
84d8beb7e0
|
|
@ -53,12 +53,12 @@ public interface BusinessHandler extends DBSessionBuilder {
|
|||
|
||||
Logger log = LoggerFactory.getLogger(HgStoreStateMachine.class);
|
||||
String tableUnknown = "unknown";
|
||||
String tableVertex = "vertex";
|
||||
String tableOutEdge = "out_edge";
|
||||
String tableInEdge = "in_edge";
|
||||
String tableIndex = "index";
|
||||
String tableTask = "task";
|
||||
String tableOlap = "olap";
|
||||
String tableVertex = "g+v";
|
||||
String tableOutEdge = "g+oe";
|
||||
String tableInEdge = "g+ie";
|
||||
String tableIndex = "g+index";
|
||||
String tableTask = "g+task";
|
||||
String tableOlap = "g+olap";
|
||||
|
||||
String[] tables = new String[]{tableUnknown, tableVertex, tableOutEdge, tableInEdge, tableIndex,
|
||||
tableTask, tableOlap};
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ public class BusinessHandlerImpl implements BusinessHandler {
|
|||
private static final int batchSize = 10000;
|
||||
private static final RocksDBFactory factory = RocksDBFactory.getInstance();
|
||||
private static final HashMap<ScanType, String> tableMapping = new HashMap<>() {{
|
||||
put(ScanType.SCAN_VERTEX, "vertex");
|
||||
put(ScanType.SCAN_EDGE, "out_edge");
|
||||
put(ScanType.SCAN_VERTEX, tableVertex);
|
||||
put(ScanType.SCAN_EDGE, tableOutEdge);
|
||||
}};
|
||||
private static final Map<Integer, String> dbNames = new ConcurrentHashMap<>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue