phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] swaroopak commented on a change in pull request #494: PHOENIX-5262 Wrong Result on Salted table with Varbinary PK
Date Sun, 28 Apr 2019 04:38:25 GMT
swaroopak commented on a change in pull request #494: PHOENIX-5262 Wrong Result on Salted table
with Varbinary PK
URL: https://github.com/apache/phoenix/pull/494#discussion_r279177161
 
 

 ##########
 File path: phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
 ##########
 @@ -45,291 +48,305 @@
 /**
  * Test the SetKey method in ScanUtil.
  */
-@RunWith(Parameterized.class)
+@RunWith(Enclosed.class)
 public class ScanUtilTest {
 
-    private final List<List<KeyRange>> slots;
-    private final byte[] expectedKey;
-    private final RowKeySchema schema;
-    private final Bound bound;
-
-    public ScanUtilTest(List<List<KeyRange>> slots, int[] widths, byte[] expectedKey,
Bound bound) throws Exception {
-        RowKeySchemaBuilder builder = new RowKeySchemaBuilder(widths.length);
-        for (final int width : widths) {
-            if (width > 0) {
-                builder.addField(new PDatum() {
-                    @Override
-                    public boolean isNullable() {
-                        return false;
-                    }
-                    @Override
-                    public PDataType getDataType() {
-                        return PChar.INSTANCE;
-                    }
-                    @Override
-                    public Integer getMaxLength() {
-                        return width;
-                    }
-                    @Override
-                    public Integer getScale() {
-                        return null;
-                    }
-                    @Override
-                    public SortOrder getSortOrder() {
-                        return SortOrder.getDefault();
-                    }
-                }, false, SortOrder.getDefault());
-            } else {
-                builder.addField(new PDatum() {
-                    @Override
-                    public boolean isNullable() {
-                        return false;
-                    }
-                    @Override
-                    public PDataType getDataType() {
-                        return PVarchar.INSTANCE;
-                    }
-                    @Override
-                    public Integer getMaxLength() {
-                        return null;
-                    }
-                    @Override
-                    public Integer getScale() {
-                        return null;
-                    }
-                    @Override
-                    public SortOrder getSortOrder() {
-                        return SortOrder.getDefault();
-                    }
-                }, false, SortOrder.getDefault());
+    @RunWith(Parameterized.class)
+    public static class ParameterizedScanUtilTest {
+
+
+        private final List<List<KeyRange>> slots;
+        private final byte[] expectedKey;
+        private final RowKeySchema schema;
+        private final Bound bound;
+
+        public ParameterizedScanUtilTest(List<List<KeyRange>> slots, int[] widths,
byte[] expectedKey, Bound bound)
+                throws Exception {
+            RowKeySchemaBuilder builder = new RowKeySchemaBuilder(widths.length);
+            for (final int width : widths) {
+                if (width > 0) {
+                    builder.addField(new PDatum() {
+                        @Override public boolean isNullable() {
+                            return false;
+                        }
+
+                        @Override public PDataType getDataType() {
+                            return PChar.INSTANCE;
+                        }
+
+                        @Override public Integer getMaxLength() {
+                            return width;
+                        }
+
+                        @Override public Integer getScale() {
+                            return null;
+                        }
+
+                        @Override public SortOrder getSortOrder() {
+                            return SortOrder.getDefault();
+                        }
+                    }, false, SortOrder.getDefault());
+                } else {
+                    builder.addField(new PDatum() {
+                        @Override public boolean isNullable() {
+                            return false;
+                        }
+
+                        @Override public PDataType getDataType() {
+                            return PVarchar.INSTANCE;
+                        }
+
+                        @Override public Integer getMaxLength() {
+                            return null;
+                        }
+
+                        @Override public Integer getScale() {
+                            return null;
+                        }
+
+                        @Override public SortOrder getSortOrder() {
+                            return SortOrder.getDefault();
+                        }
+                    }, false, SortOrder.getDefault());
+                }
             }
+            this.schema = builder.build();
+            this.slots = slots;
+            this.expectedKey = expectedKey;
+            this.bound = bound;
         }
-        this.schema = builder.build();
-        this.slots = slots;
-        this.expectedKey = expectedKey;
-        this.bound = bound;
-    }
 
-    @Test
-    public void test() {
-        byte[] key = new byte[1024];
-        int[] position = new int[slots.size()];
-        int offset = ScanUtil.setKey(schema, slots, ScanUtil.getDefaultSlotSpans(slots.size()),
position, bound, key, 0, 0, slots.size());
-        byte[] actualKey = new byte[offset];
-        System.arraycopy(key, 0, actualKey, 0, offset);
-        assertArrayEquals(expectedKey, actualKey);
-    }
+        @Test public void test() {
 
 Review comment:
   nit: On a different line. 

----------------------------------------------------------------
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


With regards,
Apache Git Services

Mime
View raw message