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

Question about hbase script hbase-create.hbase #7325

Open
1 task done
tankilo opened this issue Oct 16, 2020 · 0 comments
Open
1 task done

Question about hbase script hbase-create.hbase #7325

tankilo opened this issue Oct 16, 2020 · 0 comments

Comments

@tankilo
Copy link
Contributor

tankilo commented Oct 16, 2020

Prerequisites

Please check the FAQ, and search existing issues for similar questions before creating a new issue.YOU MAY DELETE THIS PREREQUISITES SECTION.

  • I have checked the FAQ, and issues and found no answer.

In hbase-create.hbase , table ApplicationMapStatisticsCaller_Ver2’s presplit region number is 16.

create 'ApplicationMapStatisticsCaller_Ver2', { NAME => 'C', TTL => 5184000, VERSIONS => 1, DATA_BLOCK_ENCODING => 'PREFIX' }, {SPLITS=>["\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]}

In applicationContext-collector-hbase.xml, RangeOneByteSimpleHash mod value is 32.

    <bean id="statisticsCalleeRowKeyDistributor" class="com.sematext.hbase.wd.RowKeyDistributorByHashPrefix">
        <constructor-arg ref="statisticsCalleeHasher"/>
    </bean>

    <bean id="statisticsCalleeHasher" class="com.navercorp.pinpoint.common.hbase.distributor.RangeOneByteSimpleHash">
        <constructor-arg type="int" value="0"/>
        <constructor-arg type="int" value="36"/>
        <constructor-arg type="int" value="32"/>
    </bean>

If i add the following code to class RangeOneByteSimpleHash

    public static void main(String[] args) {
        RangeOneByteSimpleHash rangeOneByteSimpleHash = new RangeOneByteSimpleHash(0,36,32);
        rangeOneByteSimpleHash.printCreateTable();
    }

    public void printCreateTable() {
        if (mod == 256) {
            System.out.println("{NUMREGIONS => 256, SPLITALGO => 'UniformSplit'}");
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append("{SPLITS=>[\"");
            byte[][] bytes = getAllPossiblePrefixes();
            for (int i = 0; i < bytes.length; i++) {
                if (i == 0) {
                    continue;
                }
                sb.append(Bytes.toStringBinary(bytes[i]));
                if (i != bytes.length - 1) {
                    sb.append(",");
                }
            }
            sb.append("\"]}");
            System.out.println(sb);
        }
    }

The output would be

{SPLITS=>["\x01,\x02,\x03,\x04,\x05,\x06,\x07,\x08,\x09,\x0A,\x0B,\x0C,\x0D,\x0E,\x0F,\x10,\x11,\x12,\x13,\x14,\x15,\x16,\x17,\x18,\x19,\x1A,\x1B,\x1C,\x1D,\x1E,\x1F"]}

I understand that you combine the adjacent two presplit regions, so it‘s still correct.
["\x01,\x02,\x03,\x04,\x05,\x06,\x07,\x08,\x09,\x0A,\x0B,\x0C,\x0D,\x0E,\x0F,\x10,\x11,\x12,\x13,\x14,\x15,\x16,\x17,\x18,\x19,\x1A,\x1B,\x1C,\x1D,\x1E,\x1F"]}

So my two quesions are:

  1. Why the presplit region number in hbase-create.hbase is different from statisticsCallerHasher's RangeOneByteSimpleHash mod? Why not make them exactly same?

  2. I want to use com.navercorp.pinpoint.common.hbase.distributor.RangeOneByteSimpleHash#getAllPossiblePrefixes to generate hbase script from code.
    If i remove these \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00, are these two scripts equivalent?

{SPLITS=>["\x02","\x04","\x06","\x08","\x0a","\x0c","\x0e","\x10","\x12","\x14","\x16","\x18","\x1a","\x1c","\x1e"]}
{SPLITS=>["\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]}
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

No branches or pull requests

1 participant