Skip to content

Instantly share code, notes, and snippets.

@keith-turner
Last active September 22, 2023 01:17
Show Gist options
  • Save keith-turner/08cb06d84d3040fb60b2bc058b9e9a5d to your computer and use it in GitHub Desktop.
Save keith-turner/08cb06d84d3040fb60b2bc058b9e9a5d to your computer and use it in GitHub Desktop.
3761 Experiments

Experiments with the changes from #3761

Below is Accumulo shell output

root@uno> createtable foo
root@uno foo> insert 1 f q 1
root@uno foo> insert 2 f q 2
root@uno foo> insert 3 f q 3
root@uno foo> insert 4 f q 4
root@uno foo> insert 5 f q 5
root@uno foo> insert 6 f q 6
root@uno foo> insert 7 f q 7
root@uno foo> insert 8 f q 8
root@uno foo> insert 9 f q 9
root@uno foo> scan
1 f:q []	1
2 f:q []	2
3 f:q []	3
4 f:q []	4
5 f:q []	5
6 f:q []	6
7 f:q []	7
8 f:q []	8
9 f:q []	9
root@uno foo> deleterows -b 3 -e 5
root@uno foo> deleterows -b 7 -e 8
root@uno foo> scan
1 f:q []	1
2 f:q []	2
3 f:q []	3
6 f:q []	6
7 f:q []	7
9 f:q []	9
root@uno foo> scan -t accumulo.metadata  -c file
3< file:{"path":"hdfs://10.173.114.210:8020/accumulo/tables/3/default_tablet/F000003p.rf","startRow":"","endRow":"AjMA"} []	141,5
3< file:{"path":"hdfs://10.173.114.210:8020/accumulo/tables/3/default_tablet/F000003p.rf","startRow":"AjUA","endRow":"AjcA"} []	71,2
3< file:{"path":"hdfs://10.173.114.210:8020/accumulo/tables/3/default_tablet/F000003p.rf","startRow":"AjgA","endRow":""} []	70,2

The ranges when scanning the metadata table above are not human readable, so wrote the following code to run in jshell. Pasted it into a jshell session.

    public void printFiles(AccumuloClient client, String tableName) throws Exception {
        var ctx = (org.apache.accumulo.core.clientImpl.ClientContext)client;

        try(var tablets = ctx.getAmple().readTablets().forTable(ctx.getTableId(tableName)).build()){
            for(var tablet : tablets) {
                for(var file : tablet.getFiles()) {
                    var range = file.getRange();
                    String rangeStr;
                    if(range.isInfiniteStartKey()) {
                        rangeStr = "(-inf,";
                    } else {
                        var row = range.getStartKey().getRowData();
                        row = row.subSequence(0, row.length()-1);
                        rangeStr = "("+row+",";
                    }

                    if(range.isInfiniteStopKey()) {
                        rangeStr += "+inf]";
                    } else {
                        rangeStr += range.getEndKey().getRowData()+"]";
                    }

                    System.out.println(tablet.getExtent().toMetaRow()+" "+file.getFileName()+"\t"+rangeStr);
                }
            }
        }
    }

Below shows the per file ranges when running the above code from jshell.

jshell> printFiles(client, "foo")
2< F000003e.rf	(-inf,3]
2< F000003e.rf	(5,7]
2< F000003e.rf	(8,+inf]

Below is Accumulo shell output

root@uno foo> addsplits -t foo 6
root@uno foo> scan
1 f:q []	1
2 f:q []	2
3 f:q []	3
6 f:q []	6
7 f:q []	7
9 f:q []	9

The following was run in jshell after doing the split above.

jshell> printFiles(client, "foo")
2;6 F000003e.rf	(-inf,3]
2;6 F000003e.rf	(5,7]
2< F000003e.rf	(5,7]
2< F000003e.rf	(8,+inf]

Below is Accumulo shell output

root@uno foo> merge -t foo
 Warning!!! Are you REALLY sure you want to merge the entire table { foo } into one tablet?!?!?! (yes|no)? yes

The following was run in jshell after running the merge above.

jshell> printFiles(client, "foo")
2< F000003e.rf	(-inf,3]
2< F000003e.rf	(5,6]
2< F000003e.rf	(6,7]
2< F000003e.rf	(8,+inf]

Below is Accumulo shell output

root@uno foo> deleterows -b 55 -e 66
root@uno foo> scan
1 f:q []	1
2 f:q []	2
3 f:q []	3
7 f:q []	7
9 f:q []	9

Printing the files after the above delete row

jshell> printFiles(client, "foo")
3< F000003p.rf	(-inf,3]
3< F000003p.rf	(5,55]
3< F000003p.rf	(66,7]
3< F000003p.rf	(8,+inf]

If you got this far, then you know the drill

root@uno foo> deleterows -f -b 2
root@uno foo> scan
1 f:q []	1
2 f:q []	2
jshell> printFiles(client, "foo")
3< F000003p.rf	(-inf,2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment