You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/07/24 21:18:15 UTC

[GitHub] [hbase] tedyu commented on a change in pull request #2138: HBASE-20717 Implement CCSMap - a better concurrent map with compacted data structure

tedyu commented on a change in pull request #2138:
URL: https://github.com/apache/hbase/pull/2138#discussion_r460289092



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/ccsmap/TestCompactedConcurrentSkipList.java
##########
@@ -0,0 +1,1842 @@
+/*
+ * 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.hadoop.hbase.ccsmap;
+
+import java.security.InvalidParameterException;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.hadoop.hbase.ccsmap.TestCompactedConcurrentSkipList.BehaviorCollections.RandomBehavior;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SmallTests.class)
+public class TestCompactedConcurrentSkipList {
+  static int BIG_KV_THRESHOLD = 1024;
+  static int DATA_PAGE_SIZE = 16 * 1024;
+  static int DEFAULT_MIN_GROUP = 5;
+  static int DEFAULT_MAX_GROUP = 10;
+
+  static class TypeHelper implements CompactedTypeHelper<Integer, String> {
+
+    @Override
+    public int getCompactedSize(Integer key, String value) {
+      return 4 + value.length();
+    }
+
+    private void copyIntToArray(int val, byte[] data, int offset) {
+      for (int pos = offset; pos < offset + 4; ++pos) {
+        data[pos] = (byte) (val & BYTE);
+        val = val >> 8;
+      }
+    }
+
+    static int BYTE = 0xFF;
+
+    private int getIntFromArray(byte[] data, int offset) {
+      int ret = 0;
+      for (int pos = offset + 3; pos >= offset; pos--) {
+        int b = data[pos];
+        ret = (ret << 8) | (b & BYTE);
+      }
+      return ret;
+    }
+
+    @Override
+    public void compact(Integer key, String value, byte[] data, int offset,
+      int len) {
+      Assert.assertEquals(4 + value.length(), len);
+      copyIntToArray(key, data, offset);
+      byte[] src = value.getBytes();
+      Assert.assertEquals(value.length(), src.length);
+      System.arraycopy(src, 0, data, offset + 4, src.length);
+    }
+
+    @Override
+    public KVPair<Integer, String> decomposite(byte[] data, int offset, int len) {

Review comment:
       Looking up the meaning of decomposite, I don't think it reflects the action here.
   Was the author intended to say 'decompose' or deserialize ?

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/ccsmap/TestCompactedConcurrentSkipList.java
##########
@@ -0,0 +1,1842 @@
+/*
+ * 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.hadoop.hbase.ccsmap;
+
+import java.security.InvalidParameterException;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.hadoop.hbase.ccsmap.TestCompactedConcurrentSkipList.BehaviorCollections.RandomBehavior;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SmallTests.class)
+public class TestCompactedConcurrentSkipList {
+  static int BIG_KV_THRESHOLD = 1024;
+  static int DATA_PAGE_SIZE = 16 * 1024;
+  static int DEFAULT_MIN_GROUP = 5;
+  static int DEFAULT_MAX_GROUP = 10;
+
+  static class TypeHelper implements CompactedTypeHelper<Integer, String> {
+
+    @Override
+    public int getCompactedSize(Integer key, String value) {
+      return 4 + value.length();
+    }
+
+    private void copyIntToArray(int val, byte[] data, int offset) {
+      for (int pos = offset; pos < offset + 4; ++pos) {
+        data[pos] = (byte) (val & BYTE);
+        val = val >> 8;
+      }
+    }
+
+    static int BYTE = 0xFF;
+
+    private int getIntFromArray(byte[] data, int offset) {
+      int ret = 0;
+      for (int pos = offset + 3; pos >= offset; pos--) {
+        int b = data[pos];
+        ret = (ret << 8) | (b & BYTE);
+      }
+      return ret;
+    }
+
+    @Override
+    public void compact(Integer key, String value, byte[] data, int offset,
+      int len) {
+      Assert.assertEquals(4 + value.length(), len);
+      copyIntToArray(key, data, offset);
+      byte[] src = value.getBytes();
+      Assert.assertEquals(value.length(), src.length);
+      System.arraycopy(src, 0, data, offset + 4, src.length);

Review comment:
       There is no more assertion in this sub-test.
   Is the arraycopy needed ?

##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/ccsmap/SpaceNotEnoughExcpetion.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.hadoop.hbase.ccsmap;
+
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+
+@InterfaceAudience.Private
+public class SpaceNotEnoughExcpetion extends RuntimeException {

Review comment:
       I don't see any exception class in hbase codebase extending RuntimeException.
   
   Should this extend HBaseException ?
   Also, Excpetion is misspelled.
   I think NotEnoughSpaceException would be better.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org