Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cockroachdb #34

Merged
merged 5 commits into from
Mar 24, 2019
Merged

add cockroachdb #34

merged 5 commits into from
Mar 24, 2019

Conversation

gangliao
Copy link
Collaborator

fix #8

@gangliao
Copy link
Collaborator Author

cockroach doesn't support recursive keyword: cockroachdb/cockroach#7029

@gangliao
Copy link
Collaborator Author

  public static void removeChild(final long childId) {
    try {
      Connection conn = DatabaseConnection.getInstance().getConnection();
      // delete file/directory recusively
      String sql =
          "DELETE FROM inodes WHERE id IN ("
              + "   WITH RECURSIVE cte AS ("
              + "       SELECT id, parent FROM inodes d WHERE id = ?"
              + "   UNION ALL"
              + "       SELECT d.id, d.parent FROM cte"
              + "       JOIN inodes d ON cte.id = d.parent"
              + "   )"
              + "   SELECT id FROM cte"
              + ");";

@gangliao
Copy link
Collaborator Author

Cockroach works now except delete operation!!!

docker@:26257/docker> select * from inodes;
   id   | parent |         name          |  accesstime   | modificationtime |     header      |  permission    
+-------+--------+-----------------------+---------------+------------------+-----------------+---------------+
  16385 |      0 | NULL                  |             0 |    1553355310910 |               0 | 1099511693805  
  16386 |  16385 | nnThroughputBenchmark |             0 |    1553355311046 |               0 | 1099511693805  
  16387 |  16386 | create                |             0 |    1553355311161 |               0 | 1099511693805  
  16388 |  16387 | ThroughputBenchDir0   |             0 |    1553355311698 |               0 | 1099511693805  
  16389 |  16388 | ThroughputBench0      | 1553355311268 |    1553355311268 | 281474976710672 | 1099511693823  
  16390 |  16388 | ThroughputBench1      | 1553355311698 |    1553355311698 | 281474976710672 | 1099511693823  
(6 rows)

Time: 3.9479ms

docker@:26257/docker> select * from datablocks;
  blockid | numbytes | generationstamp | replication | ecpolicyid  
+---------+----------+-----------------+-------------+------------+
        0 |        0 |               0 |        NULL |         -1  
(1 row)

Time: 3.1214ms

docker@:26257/docker> select * from inode2block;
  blockid | id | idx  
+---------+----+-----+
(0 rows)

Time: 28.9029ms

@gangliao gangliao merged commit c7cc67f into calvin Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring metadata layer for postgre, cockroach and tidb
1 participant