File size: 227,852 Bytes
7ee5489 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by Cassandra.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code KijiResult}.\\n * @throws IOException On error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMatContents() throws Exception {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder().addColumns(ColumnsDef.create()\r\n .withMaxVersions(10)\r\n .add(PRIMITIVE_STRING, null)\r\n .add(STRING_MAP_1, null));\r\n KijiDataRequest request = builder.build();\r\n final EntityId eid = mTable.getEntityId(ROW);\r\n KijiResult<Object> view = mReader.getResult(eid, request);\r\n SortedMap<KijiColumnName, List<KijiCell<Object>>> map =\r\n KijiResult.Helpers.getMaterializedContents(view);\r\n for (KijiColumnName col: map.keySet()) {\r\n KijiResult<Object> newResult = view.narrowView(col);\r\n Iterator<KijiCell<Object>> it = newResult.iterator();\r\n for (KijiCell<Object> cell: map.get(col)) {\r\n assertEquals(cell, it.next());\r\n }\r\n assertTrue(!it.hasNext());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Check if the given annotation key is valid.\\\\\\\\n *\\\\\\\\n * @param key the annotation key to check.\\\\\\\\n * @return whether the key is valid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Check if the given annotation key is valid.\\n *\\n * @param key the annotation key to check.\\n * @return whether the key is valid.\\n */'public static boolean isValidAnnotationKey(\r\n final String key\r\n ) {\r\n return key.matches(ALLOWED_ANNOTATION_KEY_PATTERN);\r\n }", "test_case": "@Test\r\n public void testRegex() {\r\n final String valid = \"abcABC012_\";\r\n assertTrue(CassandraKijiTableAnnotator.isValidAnnotationKey(valid));\r\n\r\n final List<String> invalidStrings =\r\n Lists.newArrayList(\"abc?\", \"abc.\", \"a$\", \"a!\", \"a#\", \"a-\", \"\");\r\n for (String invalid : invalidStrings) {\r\n assertFalse(CassandraKijiTableAnnotator.isValidAnnotationKey(invalid));\r\n }\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testKijiURIBuilderWithInstance() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/instance1/table\").build();\r\n assertEquals(\"instance1\", uri.getInstance());\r\n final KijiURI modified =\r\n KijiURI.newBuilder(uri).withInstanceName(\"instance2\").build();\r\n assertEquals(\"instance2\", modified.getInstance());\r\n assertEquals(\"instance1\", uri.getInstance());\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSetColumn() {\r\n KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost/instance/table/\").build();\r\n assertTrue(uri.getColumns().isEmpty());\r\n uri =\r\n KijiURI.newBuilder(uri).withColumnNames(Arrays.asList(\"testcol1\", \"testcol2\"))\r\n .build();\r\n assertEquals(2, uri.getColumns().size());\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSetZookeeperQuorum() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost/instance/table/col\").build();\r\n final KijiURI modified = KijiURI.newBuilder(uri)\r\n .withZookeeperQuorum(new String[] {\"zkhost1\", \"zkhost2\"}).build();\r\n assertEquals(2, modified.getZookeeperQuorum().size());\r\n assertEquals(\"zkhost1\", modified.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", modified.getZookeeperQuorum().get(1));\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testTrailingUnset() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost/.unset/table/.unset\").build();\r\n KijiURI result = KijiURI.newBuilder(uri).withTableName(\".unset\").build();\r\n assertEquals(\"kiji-hbase://zkhost:2181/\", result.toString());\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testEscapedMapColumnQualifier() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost/instance/table/map:one%20two\").build();\r\n assertEquals(\"map:one two\", uri.getColumns().get(0).getName());\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testConstructedUriIsEscaped() {\r\n // SCHEMA-6. Column qualifier must be URL-encoded in KijiURI.\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost/instance/table/\")\r\n .addColumnName(KijiColumnName.create(\"map:one two\")).build();\r\n assertEquals(\"kiji-hbase://zkhost:2181/instance/table/map:one%20two/\", uri.toString());\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Constructs an HBase Scan that describes the data requested in the KijiDataRequest.\\\\\\\\n *\\\\\\\\n * @param tableLayout The layout of the Kiji table to read from. This is required for\\\\\\\\n * determining the mapping between Kiji columns and HBase columns.\\\\\\\\n * @return An HBase Scan descriptor.\\\\\\\\n * @throws IOException If there is an error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Constructs an HBase Scan that describes the data requested in the KijiDataRequest.\\n *\\n * @param tableLayout The layout of the Kiji table to read from. This is required for\\n * determining the mapping between Kiji columns and HBase columns.\\n * @return An HBase Scan descriptor.\\n * @throws IOException If there is an error.\\n */'public Scan toScan(final KijiTableLayout tableLayout) throws IOException {\r\n return toScan(tableLayout, new HBaseScanOptions());\r\n }", "test_case": "@Test\r\n public void testDataRequestToScanEmpty() throws IOException {\r\n KijiDataRequest request = KijiDataRequest.builder().build();\r\n HBaseDataRequestAdapter hbaseDataRequest =\r\n new HBaseDataRequestAdapter(request, mColumnNameTranslator);\r\n assertFalse(hbaseDataRequest.toScan(mTableLayout).hasFamilies());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// No state, so all FirstKeyOnlyFilters are the same\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int hashCode() {\r\n // No state, so all FirstKeyOnlyFilters are the same\r\n return new HashCodeBuilder().toHashCode();\r\n }", "test_case": "@Test\r\n public void testHashCodeAndEquals() {\r\n KijiFirstKeyOnlyColumnFilter filter1 = new KijiFirstKeyOnlyColumnFilter();\r\n KijiFirstKeyOnlyColumnFilter filter2 = new KijiFirstKeyOnlyColumnFilter();\r\n\r\n assertEquals(filter1.hashCode(), filter2.hashCode());\r\n assertEquals(filter1, filter2);\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Constructs an HBase Get that describes the data requested in the KijiDataRequest for\\\\\\\\n * a particular entity/row.\\\\\\\\n *\\\\\\\\n * @param entityId The row to build an HBase Get request for.\\\\\\\\n * @param tableLayout The layout of the Kiji table to read from. This is required for\\\\\\\\n * determining the mapping between Kiji columns and HBase columns.\\\\\\\\n * @return An HBase Get descriptor.\\\\\\\\n * @throws IOException If there is an error.\\\\\\\\n */', '')\", \"('', '// Context to translate user Kiji filters into HBase filters:\\\\n')\", \"('', '// Get request we are building and returning:\\\\n')\", \"('', '// Filters for each requested column: OR(<filter-for-column-1>, <filter-for-column2>, ...)\\\\n')\", '(\\'\\', \"// There\\'s a shortcoming in the HBase API that doesn\\'t allow us to specify per-column\\\\n\")', \"('', '// filters for timestamp ranges and max versions. We need to generate a request that\\\\n')\", \"('', '// will include all versions that we need, and add filters for the individual columns.\\\\n')\", \"('', '// As of HBase 0.94, the ColumnPaginationFilter, which we had been using to permit per-column\\\\n')\", \"('', '// maxVersions settings, no longer pages over multiple versions for the same column. We can\\\\n')\", \"('', '// still use it, however, to limit fully-qualified columns with maxVersions = 1 to return only\\\\n')\", '(\\'\\', \"// the most recent version in the request\\'s time range. All other columns will use the largest\\\\n\")', \"('', '// maxVersions seen on any column request.\\\\n')\", \"('', '// Fortunately, although we may retrieve more versions per column than we need from HBase, we\\\\n')\", '(\\'\\', \"// can still honor the user\\'s requested maxVersions when returning the versions in\\\\n\")', \"('', '// HBaseKijiRowData.\\\\n')\", \"('', '// Largest of the max-versions from all the requested columns.\\\\n')\", \"('', '// Columns with paging are excluded (max-versions does not make sense when paging):\\\\n')\", \"('', '// If every column is paged, we should add a keyonly filter to a single column, so we can have\\\\n')\", \"('', '// access to entityIds in our KijiRowData that is constructed.\\\\n')\", \"('', '// Do not include max-versions from columns with paging enabled:\\\\n')\", \"('', '// Requests a fully-qualified column.\\\\n')\", \"('', '// Adds this column to the Get request, and also as a filter.\\\\n')\", \"('', '//\\\\n')\", \"('', '// Filters are required here because we might end up requesting all cells from the\\\\n')\", \"('', '// HBase family (ie. from the Kiji locality group), if a map-type family from that\\\\n')\", \"('', '// locality group is also requested.\\\\n')\", \"('', '// Requests all columns in a Kiji group-type family.\\\\n')\", \"('', '// Expand the family request into individual column requests:\\\\n')\", \"('', '// Requests all columns in a Kiji map-type family.\\\\n')\", \"('', '// We need to request all columns in the HBase family (ie. in the Kiji locality group)\\\\n')\", \"('', '// and add a column prefix-filter to select only the columns from that Kiji family:\\\\n')\", \"('', '// All requested columns have paging enabled.\\\\n')\", \"('', '// We just need to know whether a row has data in at least one of the requested columns.\\\\n')\", \"('', '// Stop at the first valid key using AND(columnFilters, FirstKeyOnlyFilter):\\\\n')\"]", "focal_method": "b'/**\\n * Constructs an HBase Get that describes the data requested in the KijiDataRequest for\\n * a particular entity/row.\\n *\\n * @param entityId The row to build an HBase Get request for.\\n * @param tableLayout The layout of the Kiji table to read from. This is required for\\n * determining the mapping between Kiji columns and HBase columns.\\n * @return An HBase Get descriptor.\\n * @throws IOException If there is an error.\\n */'public Get toGet(\r\n final EntityId entityId,\r\n final KijiTableLayout tableLayout\r\n ) throws IOException {\r\n\r\n // Context to translate user Kiji filters into HBase filters:\r\n final KijiColumnFilter.Context filterContext =\r\n new NameTranslatingFilterContext(mColumnNameTranslator);\r\n\r\n // Get request we are building and returning:\r\n final Get get = new Get(entityId.getHBaseRowKey());\r\n\r\n // Filters for each requested column: OR(<filter-for-column-1>, <filter-for-column2>, ...)\r\n final FilterList columnFilters = new FilterList(FilterList.Operator.MUST_PASS_ONE);\r\n\r\n // There's a shortcoming in the HBase API that doesn't allow us to specify per-column\r\n // filters for timestamp ranges and max versions. We need to generate a request that\r\n // will include all versions that we need, and add filters for the individual columns.\r\n\r\n // As of HBase 0.94, the ColumnPaginationFilter, which we had been using to permit per-column\r\n // maxVersions settings, no longer pages over multiple versions for the same column. We can\r\n // still use it, however, to limit fully-qualified columns with maxVersions = 1 to return only\r\n // the most recent version in the request's time range. All other columns will use the largest\r\n // maxVersions seen on any column request.\r\n\r\n // Fortunately, although we may retrieve more versions per column than we need from HBase, we\r\n // can still honor the user's requested maxVersions when returning the versions in\r\n // HBaseKijiRowData.\r\n\r\n // Largest of the max-versions from all the requested columns.\r\n // Columns with paging are excluded (max-versions does not make sense when paging):\r\n int largestMaxVersions = 1;\r\n\r\n // If every column is paged, we should add a keyonly filter to a single column, so we can have\r\n // access to entityIds in our KijiRowData that is constructed.\r\n boolean completelyPaged = mKijiDataRequest.isPagingEnabled() ? true : false;\r\n\r\n for (KijiDataRequest.Column columnRequest : mKijiDataRequest.getColumns()) {\r\n final KijiColumnName kijiColumnName = columnRequest.getColumnName();\r\n final HBaseColumnName hbaseColumnName =\r\n mColumnNameTranslator.toHBaseColumnName(kijiColumnName);\r\n\r\n if (!columnRequest.isPagingEnabled()) {\r\n completelyPaged = false;\r\n\r\n // Do not include max-versions from columns with paging enabled:\r\n largestMaxVersions = Math.max(largestMaxVersions, columnRequest.getMaxVersions());\r\n }\r\n\r\n if (kijiColumnName.isFullyQualified()) {\r\n // Requests a fully-qualified column.\r\n // Adds this column to the Get request, and also as a filter.\r\n //\r\n // Filters are required here because we might end up requesting all cells from the\r\n // HBase family (ie. from the Kiji locality group), if a map-type family from that\r\n // locality group is also requested.\r\n addColumn(get, hbaseColumnName);\r\n columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext));\r\n\r\n } else {\r\n final FamilyLayout fLayout = tableLayout.getFamilyMap().get(kijiColumnName.getFamily());\r\n if (fLayout.isGroupType()) {\r\n // Requests all columns in a Kiji group-type family.\r\n // Expand the family request into individual column requests:\r\n for (String qualifier : fLayout.getColumnMap().keySet()) {\r\n final KijiColumnName fqKijiColumnName =\r\n KijiColumnName.create(kijiColumnName.getFamily(), qualifier);\r\n final HBaseColumnName fqHBaseColumnName =\r\n mColumnNameTranslator.toHBaseColumnName(fqKijiColumnName);\r\n addColumn(get, fqHBaseColumnName);\r\n columnFilters.addFilter(toFilter(columnRequest, fqHBaseColumnName, filterContext));\r\n }\r\n\r\n } else if (fLayout.isMapType()) {\r\n // Requests all columns in a Kiji map-type family.\r\n // We need to request all columns in the HBase family (ie. in the Kiji locality group)\r\n // and add a column prefix-filter to select only the columns from that Kiji family:\r\n get.addFamily(hbaseColumnName.getFamily());\r\n columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext));\r\n\r\n } else {\r\n throw new InternalKijiError(\"Family is neither group-type nor map-type\");\r\n }\r\n }\r\n }\r\n\r\n if (completelyPaged) {\r\n // All requested columns have paging enabled.\r\n Preconditions.checkState(largestMaxVersions == 1);\r\n\r\n // We just need to know whether a row has data in at least one of the requested columns.\r\n // Stop at the first valid key using AND(columnFilters, FirstKeyOnlyFilter):\r\n get.setFilter(new FilterList(\r\n FilterList.Operator.MUST_PASS_ALL, columnFilters, new FirstKeyOnlyFilter()));\r\n } else {\r\n get.setFilter(columnFilters);\r\n }\r\n\r\n return get\r\n .setTimeRange(mKijiDataRequest.getMinTimestamp(), mKijiDataRequest.getMaxTimestamp())\r\n .setMaxVersions(largestMaxVersions);\r\n }", "test_case": "@Test\r\n public void testDataRequestToGetEmpty() throws IOException {\r\n KijiDataRequest request = KijiDataRequest.builder().build();\r\n HBaseDataRequestAdapter hbaseDataRequest =\r\n new HBaseDataRequestAdapter(request, mColumnNameTranslator);\r\n assertFalse(\r\n hbaseDataRequest.toGet(mEntityIdFactory.getEntityId(\"entity\"), mTableLayout).hasFamilies());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiTable openTable(String tableName) throws IOException {\r\n final State state = mState.get();\r\n Preconditions.checkState(state == State.OPEN,\r\n \"Cannot open table in Kiji instance %s in state %s.\", this, state);\r\n\r\n if (!getTableNames().contains(tableName)) {\r\n throw new KijiTableNotFoundException(\r\n KijiURI.newBuilder(mURI).withTableName(tableName).build());\r\n }\r\n\r\n return new HBaseKijiTable(\r\n this,\r\n tableName,\r\n mConf,\r\n mHTableFactory,\r\n mInstanceMonitor.getTableLayoutMonitor(tableName));\r\n }", "test_case": "@Test\r\n public void testOpenUnknownTable() throws Exception {\r\n final Kiji kiji = getKiji();\r\n\r\n try {\r\n final KijiTable table = kiji.openTable(\"unknown\");\r\n Assert.fail(\"Should not be able to open a table that does not exist!\");\r\n } catch (KijiTableNotFoundException ktnfe) {\r\n // Expected!\r\n LOG.debug(\"Expected error: {}\", ktnfe);\r\n Assert.assertEquals(\"unknown\", ktnfe.getTableURI().getTable());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetFullyQualifiedColumn() throws Exception {\r\n for (KijiColumnName column : ImmutableList.of(PRIMITIVE_STRING, STRING_MAP_1)) {\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .build();\r\n\r\n testViewGet(request, Iterables.limit(ROW_DATA.get(column).entrySet(), 1));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.limit(ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet(), 1));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n ROW_DATA.get(column).entrySet());\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet());\r\n }\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMultipleFullyQualifiedColumns() throws Exception {\r\n final KijiColumnName column1 = PRIMITIVE_STRING;\r\n final KijiColumnName column2 = STRING_MAP_1;\r\n\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Mixed versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier()))\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(1)\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Mixed versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(1)\r\n .add(column1.getFamily(), column1.getQualifier()))\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetFamilyColumn() throws Exception {\r\n final Map<String, ? extends List<KijiColumnName>> families =\r\n ImmutableMap.of(\r\n PRIMITIVE_FAMILY, ImmutableList.of(PRIMITIVE_DOUBLE, PRIMITIVE_STRING),\r\n STRING_MAP_FAMILY, ImmutableList.of(STRING_MAP_1, STRING_MAP_2));\r\n\r\n for (Entry<String, ? extends List<KijiColumnName>> family : families.entrySet()) {\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n final KijiColumnName familyColumn = KijiColumnName.create(family.getKey(), null);\r\n final KijiColumnName column1 = family.getValue().get(0);\r\n final KijiColumnName column2 = family.getValue().get(1);\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef\r\n .create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(familyColumn))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef\r\n .create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(familyColumn))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMultipleFamilyColumns() throws Exception {\r\n final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);\r\n final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);\r\n\r\n final KijiColumnName column1 = PRIMITIVE_DOUBLE;\r\n final KijiColumnName column2 = PRIMITIVE_STRING;\r\n final KijiColumnName column3 = STRING_MAP_1;\r\n final KijiColumnName column4 = STRING_MAP_2;\r\n\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().add(familyColumn1))\r\n .addColumns(ColumnsDef.create().add(familyColumn2))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn1))\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column4Entries = ROW_DATA.get(column4).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column3Entries =\r\n ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column4Entries =\r\n ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Mixed versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(2).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 2);\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 2);\r\n final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column4Entries = ROW_DATA.get(column4).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(1).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable<? extends Entry<Long, ?>> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable<? extends Entry<Long, ?>> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testNarrowView() throws Exception {\r\n final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);\r\n final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);\r\n\r\n final KijiColumnName column1 = PRIMITIVE_DOUBLE;\r\n final KijiColumnName column2 = PRIMITIVE_STRING;\r\n final KijiColumnName column3 = STRING_MAP_1;\r\n final KijiColumnName column4 = STRING_MAP_2;\r\n\r\n for (int pageSize : ImmutableList.of(0)) {\r\n\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(column3))\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(column4))\r\n .withTimeRange(2, 10)\r\n .build();\r\n\r\n final KijiResult<Object> view = mReader.getResult(mTable.getEntityId(ROW), request);\r\n try {\r\n testViewGet(view.narrowView(PRIMITIVE_LONG), ImmutableList.<Entry<Long, ?>>of());\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries =\r\n ROW_DATA.get(column1).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column1), column1Entries);\r\n\r\n final Iterable<? extends Entry<Long, ?>> column2Entries =\r\n ROW_DATA.get(column2).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column2), column2Entries);\r\n\r\n testViewGet(view.narrowView(familyColumn1),\r\n Iterables.concat(column1Entries, column2Entries));\r\n\r\n final Iterable<? extends Entry<Long, ?>> column3Entries =\r\n ROW_DATA.get(column3).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column3), column3Entries);\r\n\r\n final Iterable<? extends Entry<Long, ?>> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(10L, false, 2L, true).entrySet(), 1);\r\n testViewGet(view.narrowView(column4), column4Entries);\r\n\r\n testViewGet(view.narrowView(familyColumn2),\r\n Iterables.concat(column3Entries, column4Entries));\r\n } finally {\r\n view.close();\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetWithFilters() throws Exception {\r\n final KijiColumnName column1 = PRIMITIVE_STRING;\r\n final KijiColumnName column2 = STRING_MAP_1;\r\n\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n { // single column | CRF\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withFilter(\r\n new KijiColumnRangeFilter(\r\n STRING_MAP_1.getQualifier(), true,\r\n STRING_MAP_2.getQualifier(), false))\r\n .withMaxVersions(10)\r\n .add(column2.getFamily(), null))\r\n .build();\r\n\r\n final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, column1Entries);\r\n }\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by HBase.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param unpagedRawResult The unpaged results from the row.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code HBaseKijiResult}.\\\\\\\\n * @throws IOException if error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by HBase.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param unpagedRawResult The unpaged results from the row.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param <T> The type of value in the {@code KijiCell} of this view.\\n * @return an {@code HBaseKijiResult}.\\n * @throws IOException if error while decoding cells.\\n */'public static <T> KijiResult<T> create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final Result unpagedRawResult,\r\n final HBaseKijiTable table,\r\n final KijiTableLayout layout,\r\n final HBaseColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final Collection<Column> columnRequests = dataRequest.getColumns();\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (Column columnRequest : columnRequests) {\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult<T>(entityId, dataRequest);\r\n }\r\n\r\n final HBaseMaterializedKijiResult<T> materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n HBaseMaterializedKijiResult.create(\r\n entityId,\r\n unpagedRequest,\r\n unpagedRawResult,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final HBasePagedKijiResult<T> pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new HBasePagedKijiResult<T>(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMatContents() throws Exception {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder().addColumns(ColumnsDef.create()\r\n .withMaxVersions(10)\r\n .add(PRIMITIVE_STRING, null)\r\n .add(STRING_MAP_1, null));\r\n KijiDataRequest request = builder.build();\r\n final EntityId eid = mTable.getEntityId(ROW);\r\n KijiResult<Object> view = mReader.getResult(eid, request);\r\n SortedMap<KijiColumnName, List<KijiCell<Object>>> map =\r\n KijiResult.Helpers.getMaterializedContents(view);\r\n for (KijiColumnName col: map.keySet()) {\r\n KijiResult<Object> newResult = view.narrowView(col);\r\n Iterator<KijiCell<Object>> it = newResult.iterator();\r\n for (KijiCell<Object> cell: map.get(col)) {\r\n assertEquals(cell, it.next());\r\n }\r\n assertTrue(!it.hasNext());\r\n }\r\n\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Check if the given annotation key is valid.\\\\\\\\n *\\\\\\\\n * @param key the annotation key to check.\\\\\\\\n * @return whether the key is valid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Check if the given annotation key is valid.\\n *\\n * @param key the annotation key to check.\\n * @return whether the key is valid.\\n */'public static boolean isValidAnnotationKey(\r\n final String key\r\n ) {\r\n return key.matches(ALLOWED_ANNOTATION_KEY_PATTERN);\r\n }", "test_case": "@Test\r\n public void testRegex() {\r\n final String valid = \"abcABC012_\";\r\n assertTrue(HBaseKijiTableAnnotator.isValidAnnotationKey(valid));\r\n\r\n final List<String> invalidStrings =\r\n Lists.newArrayList(\"abc?\", \"abc.\", \"a$\", \"a!\", \"a#\", \"a-\", \"\");\r\n for (String invalid : invalidStrings) {\r\n assertFalse(HBaseKijiTableAnnotator.isValidAnnotationKey(invalid));\r\n }\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int hashCode() {\r\n return new HashCodeBuilder()\r\n .append(this.mChance)\r\n .toHashCode();\r\n }", "test_case": "@Test\r\n public void testHashCodeAndEquals() {\r\n KijiRowFilter rowFilter1 = getBaseKijiRowFilter();\r\n KijiRowFilter rowFilter2 = getBaseKijiRowFilter();\r\n\r\n assertEquals(rowFilter1.hashCode(), rowFilter2.hashCode());\r\n assertEquals(rowFilter1, rowFilter2);\r\n }"}
{"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public synchronized void setDataVersion(ProtocolVersion version) throws IOException {\r\n final State state = mState.get();\r\n Preconditions.checkState(state == State.OPEN,\r\n \"Cannot set data version in SystemTable instance in state %s.\", state);\r\n putValue(KEY_DATA_VERSION, Bytes.toBytes(version.toString()));\r\n }", "test_case": "@Test\r\n public void testSetDataVersion() throws IOException {\r\n final Configuration conf = HBaseConfiguration.create();\r\n final HTableDescriptor desc = new HTableDescriptor();\r\n final FakeHTable table = new FakeHTable(\"system\", desc, conf, false, 0, true, true, null);\r\n\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji://test/instance\").build();\r\n final HBaseSystemTable systemTable = new HBaseSystemTable(uri, table);\r\n systemTable.setDataVersion(ProtocolVersion.parse(\"kiji-100\"));\r\n assertEquals(ProtocolVersion.parse(\"kiji-100\"), systemTable.getDataVersion());\r\n systemTable.close();\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public byte[] encode(final DecodedCell<?> cell) throws IOException {\r\n return encode(cell.getData());\r\n }", "test_case": "@Test\r\n public void testWriterSchemaNotInferrable() throws IOException {\r\n final Kiji kiji = getKiji();\r\n final CellSpec cellSpec = CellSpec.create()\r\n .setCellSchema(CellSchema.newBuilder()\r\n .setType(SchemaType.AVRO)\r\n .setAvroValidationPolicy(AvroValidationPolicy.DEVELOPER)\r\n .build())\r\n .setSchemaTable(kiji.getSchemaTable());\r\n final AvroCellEncoder encoder = new AvroCellEncoder(cellSpec);\r\n try {\r\n encoder.encode(new Object());\r\n Assert.fail(\"AvroCellEncoder.encode() should throw a KijiEncodingException.\");\r\n } catch (KijiEncodingException kee) {\r\n LOG.info(\"Expected error: '{}'\", kee.getMessage());\r\n Assert.assertTrue(kee.getMessage().contains(\"Unable to infer Avro writer schema for value\"));\r\n }\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String toString() {\r\n return Objects.toStringHelper(KijiPaginationFilter.class)\r\n .add(\"max-qualifiers\", mMaxQualifiers)\r\n .add(\"offset\", mOffset)\r\n .add(\"filter\", mInputFilter)\r\n .toString();\r\n }", "test_case": "@Test\r\n public void testGroupTypeColumnPaging() throws IOException {\r\n EntityId id = mTable.getEntityId(\"me\");\r\n final KijiTableWriter writer = mTable.openTableWriter();\r\n writer.put(id, \"info\", \"name\", 1L, \"me\");\r\n writer.put(id, \"info\", \"name\", 2L, \"me-too\");\r\n writer.put(id, \"info\", \"name\", 3L, \"me-three\");\r\n writer.put(id, \"info\", \"name\", 4L, \"me-four\");\r\n writer.put(id, \"info\", \"name\", 5L, \"me-five\");\r\n ResourceUtils.closeOrLog(writer);\r\n final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);\r\n final KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).add(\"info\", \"name\");\r\n final KijiDataRequest dataRequest = builder.build();\r\n EntityId meId = mTable.getEntityId(Bytes.toBytes(\"me\"));\r\n KijiRowData myRowData = mReader.get(meId, dataRequest);\r\n final NavigableMap<Long, CharSequence> resultMap = myRowData.getValues(\"info\", \"name\");\r\n assertEquals(\"The number of returned values is incorrect:\", 1, resultMap.size());\r\n assertTrue(null != resultMap.get(5L));\r\n assertEquals(\"me-five\", resultMap.get(5L).toString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String toString() {\r\n return Objects.toStringHelper(KijiPaginationFilter.class)\r\n .add(\"max-qualifiers\", mMaxQualifiers)\r\n .add(\"offset\", mOffset)\r\n .add(\"filter\", mInputFilter)\r\n .toString();\r\n }", "test_case": "@Test\r\n public void testGroupTypeColumnPaging2() throws IOException {\r\n EntityId id = mTable.getEntityId(\"me\");\r\n final KijiTableWriter writer = mTable.openTableWriter();\r\n writer.put(id, \"info\", \"name\", 1L, \"me\");\r\n writer.put(id, \"info\", \"name\", 2L, \"me-too\");\r\n writer.put(id, \"info\", \"name\", 3L, \"me-three\");\r\n writer.put(id, \"info\", \"name\", 4L, \"me-four\");\r\n writer.put(id, \"info\", \"name\", 5L, \"me-five\");\r\n ResourceUtils.closeOrLog(writer);\r\n final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);\r\n final KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).add(\"info\", \"name\");\r\n final KijiDataRequest dataRequest = builder.build();\r\n EntityId meId = mTable.getEntityId(\"me\");\r\n KijiRowData myRowData = mReader.get(meId, dataRequest);\r\n final NavigableMap<Long, CharSequence> resultMap = myRowData.getValues(\"info\", \"name\");\r\n assertEquals(\"The number of returned values is incorrect:\", 1, resultMap.size());\r\n assertTrue(null != resultMap.get(5L));\r\n assertEquals(\"me-five\", resultMap.get(5L).toString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String toString() {\r\n return Objects.toStringHelper(KijiPaginationFilter.class)\r\n .add(\"max-qualifiers\", mMaxQualifiers)\r\n .add(\"offset\", mOffset)\r\n .add(\"filter\", mInputFilter)\r\n .toString();\r\n }", "test_case": "@Test\r\n public void testMapTypeColumnPaging() throws IOException {\r\n final KijiTableWriter writer = mTable.openTableWriter();\r\n EntityId id = mTable.getEntityId(\"me\");\r\n writer.put(id, \"jobs\", \"e\", 1L, \"always coming in 5th\");\r\n writer.put(id, \"jobs\", \"d\", 2L, \"always coming in 4th\");\r\n writer.put(id, \"jobs\", \"c\", 3L, \"always coming in 3rd\");\r\n writer.put(id, \"jobs\", \"b\", 4L, \"always coming in 2nd\");\r\n writer.put(id, \"jobs\", \"a\", 5L, \"always coming in 1st\");\r\n ResourceUtils.closeOrLog(writer);\r\n final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);\r\n final KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).addFamily(\"jobs\");\r\n final KijiDataRequest dataRequest = builder.build();\r\n EntityId meId = mTable.getEntityId(Bytes.toBytes(\"me\"));\r\n KijiRowData myRowData = mReader.get(meId, dataRequest);\r\n final NavigableMap<String, NavigableMap<Long, CharSequence>> resultMap\r\n = myRowData.<CharSequence>getValues(\"jobs\");\r\n assertEquals(\"The number of returned values is incorrect:\", 1, resultMap.size());\r\n assertTrue(null != resultMap.get(\"a\"));\r\n assertEquals(\"always coming in 1st\", resultMap.get(\"a\").get(5L).toString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String toString() {\r\n return Objects.toStringHelper(KijiPaginationFilter.class)\r\n .add(\"max-qualifiers\", mMaxQualifiers)\r\n .add(\"offset\", mOffset)\r\n .add(\"filter\", mInputFilter)\r\n .toString();\r\n }", "test_case": "@Test\r\n public void testFilterMergeColumnPaging() throws IOException {\r\n final KijiTableWriter writer = mTable.openTableWriter();\r\n EntityId id = mTable.getEntityId(\"me\");\r\n writer.put(id, \"jobs\", \"b\", 1L, \"always coming in 5th\");\r\n writer.put(id, \"jobs\", \"b\", 2L, \"always coming in 4th\");\r\n writer.put(id, \"jobs\", \"b\", 3L, \"always coming in 3rd\");\r\n writer.put(id, \"jobs\", \"a\", 4L, \"always coming in 2nd\");\r\n writer.put(id, \"jobs\", \"a\", 5L, \"always coming in 1st\");\r\n ResourceUtils.closeOrLog(writer);\r\n final KijiColumnFilter columnFilter =\r\n new KijiPaginationFilter(new RegexQualifierColumnFilter(\"b\"), 1);\r\n final KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).addFamily(\"jobs\");\r\n final KijiDataRequest dataRequest = builder.build();\r\n EntityId meId = mTable.getEntityId(Bytes.toBytes(\"me\"));\r\n KijiRowData myRowData = mReader.get(meId, dataRequest);\r\n final NavigableMap<String, NavigableMap<Long, CharSequence>> resultMap\r\n = myRowData.<CharSequence>getValues(\"jobs\");\r\n assertEquals(\"The number of returned values is incorrect: \", 1, resultMap.get(\"b\").size());\r\n assertEquals(\"Incorrect first value of first page:\", \"always coming in 3rd\",\r\n resultMap.get(\"b\").get(3L).toString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Validate that the family exists\\\\n')\", \"('', '// Validate that the qualifier exists within the layout\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public HBaseColumnName toHBaseColumnName(KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n // Validate that the family exists\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\"No family %s in table %s.\",\r\n familyName, mLayout.getName()));\r\n }\r\n\r\n // Validate that the qualifier exists within the layout\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n\r\n return new HBaseColumnName(\r\n Bytes.toBytes(kijiColumnName.getFamily()),\r\n Bytes.toBytes(kijiColumnName.getQualifier()));\r\n }", "test_case": "@Test\r\n public void testTranslateFromKijiToHBase() throws Exception {\r\n HBaseColumnName infoName = mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:name\"));\r\n assertEquals(\"info\", infoName.getFamilyAsString());\r\n assertEquals(\"name\", infoName.getQualifierAsString());\r\n\r\n HBaseColumnName infoEmail = mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:email\"));\r\n assertEquals(\"info\", infoEmail.getFamilyAsString());\r\n assertEquals(\"email\", infoEmail.getQualifierAsString());\r\n\r\n HBaseColumnName recommendationsProduct = mTranslator.toHBaseColumnName(\r\n KijiColumnName.create(\"recommendations:product\"));\r\n assertEquals(\"recommendations\", recommendationsProduct.getFamilyAsString());\r\n assertEquals(\"product\", recommendationsProduct.getQualifierAsString());\r\n\r\n HBaseColumnName purchases = mTranslator.toHBaseColumnName(\r\n KijiColumnName.create(\"recommendations:product\"));\r\n assertEquals(\"recommendations\", purchases.getFamilyAsString());\r\n assertEquals(\"product\", purchases.getQualifierAsString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Validate that the family exists\\\\n')\", \"('', '// Validate that the qualifier exists\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name.\", hbaseColumnName);\r\n\r\n final String familyName = Bytes.toString(hbaseColumnName.getFamily());\r\n final String qualifierName = Bytes.toString(hbaseColumnName.getQualifier());\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n\r\n // Validate that the family exists\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\"No family %s in layout for table %s.\",\r\n familyName, mLayout.getName()));\r\n }\r\n\r\n // Validate that the qualifier exists\r\n final ColumnLayout qualifier = family.getColumnMap().get(qualifierName);\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n\r\n LOG.debug(\"Translated to Kiji column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiLocalityGroup() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"fakeFamily\", \"fakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Validate that the family exists\\\\n')\", \"('', '// Validate that the qualifier exists\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name.\", hbaseColumnName);\r\n\r\n final String familyName = Bytes.toString(hbaseColumnName.getFamily());\r\n final String qualifierName = Bytes.toString(hbaseColumnName.getQualifier());\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n\r\n // Validate that the family exists\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\"No family %s in layout for table %s.\",\r\n familyName, mLayout.getName()));\r\n }\r\n\r\n // Validate that the qualifier exists\r\n final ColumnLayout qualifier = family.getColumnMap().get(qualifierName);\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n\r\n LOG.debug(\"Translated to Kiji column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiColumn() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"recommendations\", \"fakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Validate that the family exists\\\\n')\", \"('', '// Validate that the qualifier exists within the layout\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public HBaseColumnName toHBaseColumnName(KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n // Validate that the family exists\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\"No family %s in table %s.\",\r\n familyName, mLayout.getName()));\r\n }\r\n\r\n // Validate that the qualifier exists within the layout\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n\r\n return new HBaseColumnName(\r\n Bytes.toBytes(kijiColumnName.getFamily()),\r\n Bytes.toBytes(kijiColumnName.getQualifier()));\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchHBaseColumn() throws Exception {\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"doesnt:exist\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int hashCode() {\r\n return HASH_CODE;\r\n }", "test_case": "@Test\r\n public void testEqualsAndHashCode() {\r\n final StripValueRowFilter filter1 = new StripValueRowFilter();\r\n final StripValueRowFilter filter2 = new StripValueRowFilter();\r\n assertEquals(filter1, filter2);\r\n assertEquals(filter1.hashCode(), filter2.hashCode());\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Validate the Kiji family\\\\n')\", \"('', '// Validate the Kiji qualifier\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public HBaseColumnName toHBaseColumnName(KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n // Validate the Kiji family\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n // Validate the Kiji qualifier\r\n if (family.isGroupType() && !family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n final byte[] localityGroupBytes = Bytes.toBytes(family.getLocalityGroup().getName());\r\n final byte[] familyBytes = Bytes.toBytes(familyName);\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierName);\r\n\r\n final byte[] hbaseQualifierBytes =\r\n ShortColumnNameTranslator.concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes);\r\n\r\n return new HBaseColumnName(localityGroupBytes, hbaseQualifierBytes);\r\n }", "test_case": "@Test\r\n public void testTranslateFromKijiToHBase() throws Exception {\r\n HBaseColumnName infoName = mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:name\"));\r\n assertEquals(\"default\", infoName.getFamilyAsString());\r\n assertEquals(\"info:name\", infoName.getQualifierAsString());\r\n\r\n HBaseColumnName infoEmail =\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:email\"));\r\n assertEquals(\"default\", infoEmail.getFamilyAsString());\r\n assertEquals(\"info:email\", infoEmail.getQualifierAsString());\r\n\r\n HBaseColumnName recommendationsProduct = mTranslator.toHBaseColumnName(\r\n KijiColumnName.create(\"recommendations:product\"));\r\n assertEquals(\"inMemory\", recommendationsProduct.getFamilyAsString());\r\n assertEquals(\"recommendations:product\", recommendationsProduct.getQualifierAsString());\r\n\r\n HBaseColumnName purchases =\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"purchases:foo\"));\r\n assertEquals(\"inMemory\", purchases.getFamilyAsString());\r\n assertEquals(\"purchases:foo\", purchases.getQualifierAsString());\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name {} to Kiji column name.\", hbaseColumnName);\r\n\r\n final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());\r\n\r\n final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group %s in table %s.\",\r\n localityGroupName, mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final String familyName = Bytes.toString(hbaseQualifier, 0, index);\r\n final String qualifierName =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family %s in locality group %s of table %s.\",\r\n familyName, localityGroupName, mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji group type column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji map type column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiLocalityGroup() throws Exception {\r\n mTranslator\r\n .toKijiColumnName(getHBaseColumnName(\"fakeLocalityGroup\", \"fakeFamily:fakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name {} to Kiji column name.\", hbaseColumnName);\r\n\r\n final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());\r\n\r\n final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group %s in table %s.\",\r\n localityGroupName, mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final String familyName = Bytes.toString(hbaseQualifier, 0, index);\r\n final String qualifierName =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family %s in locality group %s of table %s.\",\r\n familyName, localityGroupName, mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji group type column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji map type column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiFamily() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"inMemory\", \"fakeFamily:fakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name {} to Kiji column name.\", hbaseColumnName);\r\n\r\n final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());\r\n\r\n final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group %s in table %s.\",\r\n localityGroupName, mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final String familyName = Bytes.toString(hbaseQualifier, 0, index);\r\n final String qualifierName =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family %s in locality group %s of table %s.\",\r\n familyName, localityGroupName, mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji group type column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji map type column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiColumn() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"inMemory\", \"recommendations:fakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name {} to Kiji column name.\", hbaseColumnName);\r\n\r\n final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());\r\n\r\n final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group %s in table %s.\",\r\n localityGroupName, mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final String familyName = Bytes.toString(hbaseQualifier, 0, index);\r\n final String qualifierName =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family %s in locality group %s of table %s.\",\r\n familyName, localityGroupName, mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji group type column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji map type column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testCorruptQualifier() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"inMemory\", \"fakeFamilyfakeQualifier\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name {} to Kiji column name.\", hbaseColumnName);\r\n\r\n final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());\r\n\r\n final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group %s in table %s.\",\r\n localityGroupName, mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final String familyName = Bytes.toString(hbaseQualifier, 0, index);\r\n final String qualifierName =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family %s in locality group %s of table %s.\",\r\n familyName, localityGroupName, mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n if (!family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No qualifier %s in family %s of table %s.\",\r\n qualifierName, familyName, mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji group type column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);\r\n LOG.debug(\"Translated to Kiji map type column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test\r\n public void testMultipleSeparators() throws Exception {\r\n KijiColumnName kijiColumnName =\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"inMemory\", \"purchases:left:right\"));\r\n assertEquals(\"purchases\", kijiColumnName.getFamily());\r\n assertEquals(\"left:right\", kijiColumnName.getQualifier());\r\n }"}
{"description": "[\"('/** {@inheritDoc}*/', '')\", \"('', '// Validate the Kiji family\\\\n')\", \"('', '// Validate the Kiji qualifier\\\\n')\"]", "focal_method": "b'/** {@inheritDoc}*/'@Override\r\n public HBaseColumnName toHBaseColumnName(KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n // Validate the Kiji family\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n // Validate the Kiji qualifier\r\n if (family.isGroupType() && !family.getColumnMap().containsKey(qualifierName)) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n final byte[] localityGroupBytes = Bytes.toBytes(family.getLocalityGroup().getName());\r\n final byte[] familyBytes = Bytes.toBytes(familyName);\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierName);\r\n\r\n final byte[] hbaseQualifierBytes =\r\n ShortColumnNameTranslator.concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes);\r\n\r\n return new HBaseColumnName(localityGroupBytes, hbaseQualifierBytes);\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchHBaseColumn() throws Exception {\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"doesnt:exist\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Unqualified column\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public HBaseColumnName toHBaseColumnName(final KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n final ColumnId localityGroupID = family.getLocalityGroup().getId();\r\n final ColumnId familyID = family.getId();\r\n\r\n final byte[] localityGroupBytes = Bytes.toBytes(localityGroupID.toString());\r\n final byte[] familyBytes = Bytes.toBytes(familyID.toString());\r\n\r\n if (qualifierName == null) {\r\n // Unqualified column\r\n return new HBaseColumnName(localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, new byte[]{}));\r\n } else if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = family.getColumnIdNameMap().inverse().get(qualifierName);\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierID.toString());\r\n\r\n return new HBaseColumnName(localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierName);\r\n\r\n return new HBaseColumnName(\r\n localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));\r\n }\r\n }", "test_case": "@Test\r\n public void testTranslateFromKijiToHBase() throws Exception {\r\n HBaseColumnName infoName = mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:name\"));\r\n assertEquals(\"B\", infoName.getFamilyAsString());\r\n assertEquals(\"B:B\", infoName.getQualifierAsString());\r\n\r\n HBaseColumnName infoEmail = mTranslator.toHBaseColumnName(KijiColumnName.create(\"info:email\"));\r\n assertEquals(\"B\", infoEmail.getFamilyAsString());\r\n assertEquals(\"B:C\", infoEmail.getQualifierAsString());\r\n\r\n HBaseColumnName recommendationsProduct = mTranslator.toHBaseColumnName(\r\n KijiColumnName.create(\"recommendations:product\"));\r\n assertEquals(\"C\", recommendationsProduct.getFamilyAsString());\r\n assertEquals(\"B:B\", recommendationsProduct.getQualifierAsString());\r\n\r\n HBaseColumnName purchases =\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"purchases:foo\"));\r\n assertEquals(\"C\", purchases.getFamilyAsString());\r\n assertEquals(\"C:foo\", purchases.getQualifierAsString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name...\", hbaseColumnName);\r\n final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());\r\n final LocalityGroupLayout localityGroup =\r\n mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group with ID %s in table %s.\",\r\n localityGroupID.getId(), mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));\r\n final String rawQualifier =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family =\r\n localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family with ID %s in locality group %s of table %s.\",\r\n familyID.getId(), localityGroup.getName(), mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = ColumnId.fromString(rawQualifier);\r\n final ColumnLayout qualifier =\r\n family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No column with ID %s in family %s of table %s.\",\r\n qualifierID.getId(), family.getName(), mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName =\r\n new KijiColumnName(family.getName(), qualifier.getName());\r\n LOG.debug(\"Translated to Kiji group column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(family.getName(), rawQualifier);\r\n LOG.debug(\"Translated to Kiji map column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiLocalityGroup() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"D\", \"E:E\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name...\", hbaseColumnName);\r\n final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());\r\n final LocalityGroupLayout localityGroup =\r\n mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group with ID %s in table %s.\",\r\n localityGroupID.getId(), mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));\r\n final String rawQualifier =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family =\r\n localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family with ID %s in locality group %s of table %s.\",\r\n familyID.getId(), localityGroup.getName(), mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = ColumnId.fromString(rawQualifier);\r\n final ColumnLayout qualifier =\r\n family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No column with ID %s in family %s of table %s.\",\r\n qualifierID.getId(), family.getName(), mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName =\r\n new KijiColumnName(family.getName(), qualifier.getName());\r\n LOG.debug(\"Translated to Kiji group column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(family.getName(), rawQualifier);\r\n LOG.debug(\"Translated to Kiji map column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiFamily() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"C\", \"E:E\"));\r\n }"}
{"description": "Creates a new @code HBaseColumnName instance @param family HBase column family not null @param qualifier HBase column qualifier not null", "focal_method": "b'/**\\n * Creates a new {@code HBaseColumnName} instance.\\n *\\n * @param family HBase column family, not null.\\n * @param qualifier HBase column qualifier, not null.\\n */'public HBaseColumnName(byte[] family, byte[] qualifier) {\r\n mFamily = family;\r\n mQualifier = qualifier;\r\n }", "test_case": "@Test\r\n public void testHBaseColumnName() {\r\n HBaseColumnName column = new HBaseColumnName(Bytes.toBytes(\"foo\"), Bytes.toBytes(\"bar\"));\r\n assertArrayEquals(Bytes.toBytes(\"foo\"), column.getFamily());\r\n assertEquals(\"foo\", column.getFamilyAsString());\r\n assertArrayEquals(Bytes.toBytes(\"bar\"), column.getQualifier());\r\n assertEquals(\"bar\", column.getQualifierAsString());\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name...\", hbaseColumnName);\r\n final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());\r\n final LocalityGroupLayout localityGroup =\r\n mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group with ID %s in table %s.\",\r\n localityGroupID.getId(), mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));\r\n final String rawQualifier =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family =\r\n localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family with ID %s in locality group %s of table %s.\",\r\n familyID.getId(), localityGroup.getName(), mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = ColumnId.fromString(rawQualifier);\r\n final ColumnLayout qualifier =\r\n family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No column with ID %s in family %s of table %s.\",\r\n qualifierID.getId(), family.getName(), mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName =\r\n new KijiColumnName(family.getName(), qualifier.getName());\r\n LOG.debug(\"Translated to Kiji group column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(family.getName(), rawQualifier);\r\n LOG.debug(\"Translated to Kiji map column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchKijiColumn() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"C\", \"B:E\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Parse the HBase qualifier as a byte[] in order to save a String instantiation\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)\r\n throws NoSuchColumnException {\r\n LOG.debug(\"Translating HBase column name '{}' to Kiji column name...\", hbaseColumnName);\r\n final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());\r\n final LocalityGroupLayout localityGroup =\r\n mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));\r\n if (localityGroup == null) {\r\n throw new NoSuchColumnException(String.format(\"No locality group with ID %s in table %s.\",\r\n localityGroupID.getId(), mLayout.getName()));\r\n }\r\n\r\n // Parse the HBase qualifier as a byte[] in order to save a String instantiation\r\n final byte[] hbaseQualifier = hbaseColumnName.getQualifier();\r\n final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);\r\n if (index == -1) {\r\n throw new NoSuchColumnException(String.format(\r\n \"Missing separator in HBase column %s.\", hbaseColumnName));\r\n }\r\n final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));\r\n final String rawQualifier =\r\n Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);\r\n\r\n final FamilyLayout family =\r\n localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));\r\n if (family == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No family with ID %s in locality group %s of table %s.\",\r\n familyID.getId(), localityGroup.getName(), mLayout.getName()));\r\n }\r\n\r\n if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = ColumnId.fromString(rawQualifier);\r\n final ColumnLayout qualifier =\r\n family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));\r\n if (qualifier == null) {\r\n throw new NoSuchColumnException(String.format(\r\n \"No column with ID %s in family %s of table %s.\",\r\n qualifierID.getId(), family.getName(), mLayout.getName()));\r\n }\r\n final KijiColumnName kijiColumnName =\r\n new KijiColumnName(family.getName(), qualifier.getName());\r\n LOG.debug(\"Translated to Kiji group column {}.\", kijiColumnName);\r\n return kijiColumnName;\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final KijiColumnName kijiColumnName = new KijiColumnName(family.getName(), rawQualifier);\r\n LOG.debug(\"Translated to Kiji map column '{}'.\", kijiColumnName);\r\n return kijiColumnName;\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testCorruptQualifier() throws Exception {\r\n mTranslator.toKijiColumnName(getHBaseColumnName(\"C\", \"BE\"));\r\n }"}
{"description": "[\"('/** {@inheritDoc} */', '')\", \"('', '// Unqualified column\\\\n')\", \"('', '// Group type family.\\\\n')\", \"('', '// Map type family.\\\\n')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public HBaseColumnName toHBaseColumnName(final KijiColumnName kijiColumnName)\r\n throws NoSuchColumnException {\r\n final String familyName = kijiColumnName.getFamily();\r\n final String qualifierName = kijiColumnName.getQualifier();\r\n\r\n final FamilyLayout family = mLayout.getFamilyMap().get(familyName);\r\n if (family == null) {\r\n throw new NoSuchColumnException(kijiColumnName.toString());\r\n }\r\n\r\n final ColumnId localityGroupID = family.getLocalityGroup().getId();\r\n final ColumnId familyID = family.getId();\r\n\r\n final byte[] localityGroupBytes = Bytes.toBytes(localityGroupID.toString());\r\n final byte[] familyBytes = Bytes.toBytes(familyID.toString());\r\n\r\n if (qualifierName == null) {\r\n // Unqualified column\r\n return new HBaseColumnName(localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, new byte[]{}));\r\n } else if (family.isGroupType()) {\r\n // Group type family.\r\n final ColumnId qualifierID = family.getColumnIdNameMap().inverse().get(qualifierName);\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierID.toString());\r\n\r\n return new HBaseColumnName(localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));\r\n } else {\r\n // Map type family.\r\n assert family.isMapType();\r\n final byte[] qualifierBytes = Bytes.toBytes(qualifierName);\r\n\r\n return new HBaseColumnName(\r\n localityGroupBytes,\r\n concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));\r\n }\r\n }", "test_case": "@Test(expected = NoSuchColumnException.class)\r\n public void testNoSuchHBaseColumn() throws Exception {\r\n mTranslator.toHBaseColumnName(KijiColumnName.create(\"doesnt:exist\"));\r\n }"}
{"description": "['(\"/**\\\\\\\\n * Get a table layout monitor for the provided table. The returned table layout monitor should\\\\\\\\n * be closed when no longer needed.\\\\\\\\n *\\\\\\\\n * @param tableName of table\\'s monitor to retrieve.\\\\\\\\n * @return a table layout monitor for the table.\\\\\\\\n */\", \\'\\')']", "focal_method": "b\"/**\\n * Get a table layout monitor for the provided table. The returned table layout monitor should\\n * be closed when no longer needed.\\n *\\n * @param tableName of table's monitor to retrieve.\\n * @return a table layout monitor for the table.\\n */\"public TableLayoutMonitor getTableLayoutMonitor(String tableName) {\r\n Preconditions.checkState(mState.get() == State.OPEN, \"InstanceMonitor is closed.\");\r\n LOG.debug(\"Retrieving TableLayoutMonitor for table {} with userID {}.\",\r\n KijiURI.newBuilder(mInstanceURI).withTableName(tableName).build(), mUserID);\r\n return new ReferencedTableLayoutMonitor(tableName, mTableLayoutMonitors);\r\n }", "test_case": "@Test\r\n public void testCanRetrieveTableMonitor() throws Exception {\r\n TableLayoutMonitor monitor = mInstanceMonitor.getTableLayoutMonitor(mTableURI.getTable());\r\n Assert.assertEquals(\"layout-1.0\", monitor.getLayout().getDesc().getVersion());\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Validates a new table layout against a reference layout for mutual compatibility.\\\\\\\\n *\\\\\\\\n * @param reference the reference layout against which to validate.\\\\\\\\n * @param layout the new layout to validate.\\\\\\\\n * @throws IOException in case of an IO Error reading from the schema table.\\\\\\\\n * Throws InvalidLayoutException if the layouts are incompatible.\\\\\\\\n */', '')\", \"('', '// Layout versions older than layout-1.3.0 do not require validation\\\\n')\", \"('', '// Accumulator for error messages which will be used to create an exception if errors occur.\\\\n')\", \"('', '// Iterate through all families/columns in the new layout,\\\\n')\", \"('', '// find a potential matching reference family/column,\\\\n')\", \"('', '// and validate the reader/writer schema sets.\\\\n')\", \"('', '// If no matching family/column exists in the reference layout the newly create column is valid.\\\\n')\", \"('', '// If there is a reference layout, check for a locality group matching the ID of the LG for\\\\n')\", \"('', '// this family. Locality Group IDs should not change between layouts.\\\\n')\", \"('', '// If there is a matching reference LG get its layout by name.\\\\n')\", \"('', '// The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\\\\n')\", \"('', '// this family in the reference layout if present.\\\\n')\", \"('', '// If the family is map-type, get the CellSchema for all values in the family.\\\\n')\", \"('', '// If there is a matching reference LG, check for the existence of this family.\\\\n')\", \"('', '// If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\\\\n')\", \"('', '// If the FamilyLayout changed from group-type to map-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// Check for a matching family from the reference layout.\\\\n')\", \"('', '// If there is a matching reference family and it is the same family type, iterate\\\\n')\", \"('', '// through the columns checking schema compatibility. Only checks columns from the new\\\\n')\", \"('', '// layout because removed columns are inherently valid.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// layout.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// CellSchema.\\\\n')\", \"('', '// If there is no matching column, refCellSchema will be null and this will only test\\\\n')\", \"('', '// that the new reader and writer schemas are internally compatible.\\\\n')\", \"('', '// If the FamilyLayout changed from map-type to group-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// If there were any incompatibility errors, throw an exception.\\\\n')\"]", "focal_method": "b'/**\\n * Validates a new table layout against a reference layout for mutual compatibility.\\n *\\n * @param reference the reference layout against which to validate.\\n * @param layout the new layout to validate.\\n * @throws IOException in case of an IO Error reading from the schema table.\\n * Throws InvalidLayoutException if the layouts are incompatible.\\n */'public void validate(KijiTableLayout reference, KijiTableLayout layout) throws IOException {\r\n\r\n final ProtocolVersion layoutVersion = ProtocolVersion.parse(layout.getDesc().getVersion());\r\n\r\n if (layoutVersion.compareTo(Versions.LAYOUT_VALIDATION_VERSION) < 0) {\r\n // Layout versions older than layout-1.3.0 do not require validation\r\n return;\r\n }\r\n\r\n // Accumulator for error messages which will be used to create an exception if errors occur.\r\n final List<String> incompatabilityMessages = Lists.newArrayList();\r\n\r\n // Iterate through all families/columns in the new layout,\r\n // find a potential matching reference family/column,\r\n // and validate the reader/writer schema sets.\r\n // If no matching family/column exists in the reference layout the newly create column is valid.\r\n for (FamilyLayout flayout : layout.getFamilies()) {\r\n final ColumnId lgid = flayout.getLocalityGroup().getId();\r\n\r\n LocalityGroupLayout refLGLayout = null;\r\n if (reference != null) {\r\n // If there is a reference layout, check for a locality group matching the ID of the LG for\r\n // this family. Locality Group IDs should not change between layouts.\r\n final String refLGName = reference.getLocalityGroupIdNameMap().get(lgid);\r\n if (refLGName != null) {\r\n // If there is a matching reference LG get its layout by name.\r\n refLGLayout = reference.getLocalityGroupMap().get(refLGName);\r\n }\r\n }\r\n\r\n // The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\r\n // this family in the reference layout if present.\r\n final ColumnId familyId = flayout.getId();\r\n\r\n if (flayout.isMapType()) {\r\n // If the family is map-type, get the CellSchema for all values in the family.\r\n final CellSchema cellSchema = flayout.getDesc().getMapSchema();\r\n\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n // If there is a matching reference LG, check for the existence of this family.\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\r\n final CellSchema refCellSchema = refFamilyLayout.getDesc().getMapSchema();\r\n\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(refCellSchema, cellSchema)));\r\n } else if (refFamilyLayout.isGroupType()) {\r\n // If the FamilyLayout changed from group-type to map-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from group-type to map-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(null, cellSchema)));\r\n }\r\n } else if (flayout.isGroupType()) {\r\n // Check for a matching family from the reference layout.\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isGroupType()) {\r\n // If there is a matching reference family and it is the same family type, iterate\r\n // through the columns checking schema compatibility. Only checks columns from the new\r\n // layout because removed columns are inherently valid.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n\r\n final String refColumnName =\r\n refFamilyLayout.getColumnIdNameMap().get(columnLayout.getId());\r\n ColumnLayout refColumnLayout = null;\r\n if (refColumnName != null) {\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // layout.\r\n refColumnLayout = refFamilyLayout.getColumnMap().get(refColumnName);\r\n }\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // CellSchema.\r\n final CellSchema refCellSchema =\r\n (refColumnLayout == null) ? null : refColumnLayout.getDesc().getColumnSchema();\r\n\r\n // If there is no matching column, refCellSchema will be null and this will only test\r\n // that the new reader and writer schemas are internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(),\r\n columnLayout.getName(),\r\n validateCellSchema(refCellSchema, cellSchema)));\r\n }\r\n } else if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout changed from map-type to group-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from map-type to group-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), columnLayout.getName(), validateCellSchema(null, cellSchema)));\r\n }\r\n }\r\n\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", flayout.getName()));\r\n }\r\n }\r\n\r\n // If there were any incompatibility errors, throw an exception.\r\n if (incompatabilityMessages.size() != 0) {\r\n throw new InvalidLayoutSchemaException(incompatabilityMessages);\r\n }\r\n }", "test_case": "@Test\r\n public void testAvroValidationChanges() throws IOException {\r\n final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(getKiji());\r\n final TableLayoutDesc basicDesc = KijiTableLayouts.getLayout(KijiTableLayouts.SCHEMA_REG_TEST);\r\n basicDesc.setVersion(\"layout-1.3.0\");\r\n final KijiColumnName validatedColumn = KijiColumnName.create(\"info:fullname\");\r\n final Schema intSchema = Schema.create(Type.INT);\r\n final Schema stringSchema = Schema.create(Type.STRING);\r\n\r\n final TableLayoutDesc strictIntDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)\r\n .withReader(validatedColumn, intSchema)\r\n .build();\r\n final TableLayoutDesc strictStringDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)\r\n .withWriter(validatedColumn, stringSchema)\r\n .build();\r\n final TableLayoutDesc developerIntDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.DEVELOPER)\r\n .withReader(validatedColumn, intSchema)\r\n .build();\r\n final TableLayoutDesc developerStringDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.DEVELOPER)\r\n .withWriter(validatedColumn, stringSchema)\r\n .build();\r\n final TableLayoutDesc noneIntDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.NONE)\r\n .withReader(validatedColumn, intSchema)\r\n .build();\r\n final TableLayoutDesc noneStringDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.NONE)\r\n .withWriter(validatedColumn, stringSchema)\r\n .build();\r\n final TableLayoutDesc schema10IntDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.SCHEMA_1_0)\r\n .withReader(validatedColumn, intSchema)\r\n .build();\r\n final TableLayoutDesc schema10StringDesc = new TableLayoutBuilder(basicDesc, getKiji())\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.SCHEMA_1_0)\r\n .withWriter(validatedColumn, stringSchema)\r\n .build();\r\n\r\n final List<TableLayoutDesc> intDescs =\r\n Lists.newArrayList(strictIntDesc, developerIntDesc, noneIntDesc, schema10IntDesc);\r\n\r\n // Increasing or decreasing validation strictness is acceptable in either direction. The new\r\n // layout sets the validation policy which will be run. For an increase in validation to\r\n // succeed old readers and writers must be internally compatible and compatible with new readers\r\n // and writers.\r\n\r\n // Test each validation mode modified to STRICT.\r\n for (TableLayoutDesc intDesc : intDescs) {\r\n // Increasing the layout validation to STRICT should throw an exception.\r\n try {\r\n validator.validate(\r\n KijiTableLayout.newLayout(intDesc), KijiTableLayout.newLayout(strictStringDesc));\r\n fail(\"validate should have thrown InvalidLayoutSchemaException because int and string are \"\r\n + \"incompatible.\");\r\n } catch (InvalidLayoutSchemaException ilse) {\r\n assertTrue(ilse.getReasons().contains(\r\n \"In column: 'info:fullname' Reader schema: \\\"int\\\" is incompatible with \"\r\n + \"writer schema: \\\"string\\\".\"));\r\n assertTrue(ilse.getReasons().size() == 1);\r\n }\r\n }\r\n\r\n // Test each validation mode modified to DEVELOPER.\r\n for (TableLayoutDesc intDesc : intDescs) {\r\n // Increasing the layout validation to DEVELOPER should throw an exception.\r\n try {\r\n validator.validate(\r\n KijiTableLayout.newLayout(intDesc), KijiTableLayout.newLayout(developerStringDesc));\r\n fail(\"validate should have thrown InvalidLayoutSchemaException because int and string are \"\r\n + \"incompatible.\");\r\n } catch (InvalidLayoutSchemaException ilse) {\r\n assertTrue(ilse.getReasons().contains(\r\n \"In column: 'info:fullname' Reader schema: \\\"int\\\" is incompatible with \"\r\n + \"writer schema: \\\"string\\\".\"));\r\n assertTrue(ilse.getReasons().size() == 1);\r\n }\r\n }\r\n\r\n // Test each validation mode modified to SCHEMA_1_0.\r\n for (TableLayoutDesc intDesc : intDescs) {\r\n // Reducing the layout validation to SCHEMA_1_0 should eliminate errors.\r\n validator.validate(\r\n KijiTableLayout.newLayout(intDesc), KijiTableLayout.newLayout(schema10StringDesc));\r\n }\r\n\r\n // Test each validation mode modified to NONE.\r\n for (TableLayoutDesc intDesc : intDescs) {\r\n // Reducing the layout validation to NONE should eliminate errors.\r\n validator.validate(\r\n KijiTableLayout.newLayout(intDesc), KijiTableLayout.newLayout(noneStringDesc));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Validates a new table layout against a reference layout for mutual compatibility.\\\\\\\\n *\\\\\\\\n * @param reference the reference layout against which to validate.\\\\\\\\n * @param layout the new layout to validate.\\\\\\\\n * @throws IOException in case of an IO Error reading from the schema table.\\\\\\\\n * Throws InvalidLayoutException if the layouts are incompatible.\\\\\\\\n */', '')\", \"('', '// Layout versions older than layout-1.3.0 do not require validation\\\\n')\", \"('', '// Accumulator for error messages which will be used to create an exception if errors occur.\\\\n')\", \"('', '// Iterate through all families/columns in the new layout,\\\\n')\", \"('', '// find a potential matching reference family/column,\\\\n')\", \"('', '// and validate the reader/writer schema sets.\\\\n')\", \"('', '// If no matching family/column exists in the reference layout the newly create column is valid.\\\\n')\", \"('', '// If there is a reference layout, check for a locality group matching the ID of the LG for\\\\n')\", \"('', '// this family. Locality Group IDs should not change between layouts.\\\\n')\", \"('', '// If there is a matching reference LG get its layout by name.\\\\n')\", \"('', '// The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\\\\n')\", \"('', '// this family in the reference layout if present.\\\\n')\", \"('', '// If the family is map-type, get the CellSchema for all values in the family.\\\\n')\", \"('', '// If there is a matching reference LG, check for the existence of this family.\\\\n')\", \"('', '// If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\\\\n')\", \"('', '// If the FamilyLayout changed from group-type to map-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// Check for a matching family from the reference layout.\\\\n')\", \"('', '// If there is a matching reference family and it is the same family type, iterate\\\\n')\", \"('', '// through the columns checking schema compatibility. Only checks columns from the new\\\\n')\", \"('', '// layout because removed columns are inherently valid.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// layout.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// CellSchema.\\\\n')\", \"('', '// If there is no matching column, refCellSchema will be null and this will only test\\\\n')\", \"('', '// that the new reader and writer schemas are internally compatible.\\\\n')\", \"('', '// If the FamilyLayout changed from map-type to group-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// If there were any incompatibility errors, throw an exception.\\\\n')\"]", "focal_method": "b'/**\\n * Validates a new table layout against a reference layout for mutual compatibility.\\n *\\n * @param reference the reference layout against which to validate.\\n * @param layout the new layout to validate.\\n * @throws IOException in case of an IO Error reading from the schema table.\\n * Throws InvalidLayoutException if the layouts are incompatible.\\n */'public void validate(KijiTableLayout reference, KijiTableLayout layout) throws IOException {\r\n\r\n final ProtocolVersion layoutVersion = ProtocolVersion.parse(layout.getDesc().getVersion());\r\n\r\n if (layoutVersion.compareTo(Versions.LAYOUT_VALIDATION_VERSION) < 0) {\r\n // Layout versions older than layout-1.3.0 do not require validation\r\n return;\r\n }\r\n\r\n // Accumulator for error messages which will be used to create an exception if errors occur.\r\n final List<String> incompatabilityMessages = Lists.newArrayList();\r\n\r\n // Iterate through all families/columns in the new layout,\r\n // find a potential matching reference family/column,\r\n // and validate the reader/writer schema sets.\r\n // If no matching family/column exists in the reference layout the newly create column is valid.\r\n for (FamilyLayout flayout : layout.getFamilies()) {\r\n final ColumnId lgid = flayout.getLocalityGroup().getId();\r\n\r\n LocalityGroupLayout refLGLayout = null;\r\n if (reference != null) {\r\n // If there is a reference layout, check for a locality group matching the ID of the LG for\r\n // this family. Locality Group IDs should not change between layouts.\r\n final String refLGName = reference.getLocalityGroupIdNameMap().get(lgid);\r\n if (refLGName != null) {\r\n // If there is a matching reference LG get its layout by name.\r\n refLGLayout = reference.getLocalityGroupMap().get(refLGName);\r\n }\r\n }\r\n\r\n // The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\r\n // this family in the reference layout if present.\r\n final ColumnId familyId = flayout.getId();\r\n\r\n if (flayout.isMapType()) {\r\n // If the family is map-type, get the CellSchema for all values in the family.\r\n final CellSchema cellSchema = flayout.getDesc().getMapSchema();\r\n\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n // If there is a matching reference LG, check for the existence of this family.\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\r\n final CellSchema refCellSchema = refFamilyLayout.getDesc().getMapSchema();\r\n\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(refCellSchema, cellSchema)));\r\n } else if (refFamilyLayout.isGroupType()) {\r\n // If the FamilyLayout changed from group-type to map-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from group-type to map-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(null, cellSchema)));\r\n }\r\n } else if (flayout.isGroupType()) {\r\n // Check for a matching family from the reference layout.\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isGroupType()) {\r\n // If there is a matching reference family and it is the same family type, iterate\r\n // through the columns checking schema compatibility. Only checks columns from the new\r\n // layout because removed columns are inherently valid.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n\r\n final String refColumnName =\r\n refFamilyLayout.getColumnIdNameMap().get(columnLayout.getId());\r\n ColumnLayout refColumnLayout = null;\r\n if (refColumnName != null) {\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // layout.\r\n refColumnLayout = refFamilyLayout.getColumnMap().get(refColumnName);\r\n }\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // CellSchema.\r\n final CellSchema refCellSchema =\r\n (refColumnLayout == null) ? null : refColumnLayout.getDesc().getColumnSchema();\r\n\r\n // If there is no matching column, refCellSchema will be null and this will only test\r\n // that the new reader and writer schemas are internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(),\r\n columnLayout.getName(),\r\n validateCellSchema(refCellSchema, cellSchema)));\r\n }\r\n } else if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout changed from map-type to group-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from map-type to group-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), columnLayout.getName(), validateCellSchema(null, cellSchema)));\r\n }\r\n }\r\n\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", flayout.getName()));\r\n }\r\n }\r\n\r\n // If there were any incompatibility errors, throw an exception.\r\n if (incompatabilityMessages.size() != 0) {\r\n throw new InvalidLayoutSchemaException(incompatabilityMessages);\r\n }\r\n }", "test_case": "@Test\r\n public void testOldLayoutVersions() throws IOException {\r\n final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(getKiji());\r\n {\r\n final TableLayoutDesc desc =\r\n KijiTableLayouts.getLayout(INVALID_AVRO_VALIDATION_TEST);\r\n desc.setVersion(Versions.LAYOUT_1_2_0.toString());\r\n\r\n try {\r\n KijiTableLayout.createUpdatedLayout(desc, null);\r\n fail(\"Must throw InvalidLayoutException \"\r\n + \"because AVRO cell type requires layout version >= 1.3.0\");\r\n } catch (InvalidLayoutException ile) {\r\n LOG.info(\"Expected error: {}\", ile.getMessage());\r\n assertTrue(ile.getMessage(),\r\n ile.getMessage().contains(\r\n \"Cell type AVRO requires table layout version >= layout-1.3.0, \"\r\n + \"got version layout-1.2.0\"));\r\n }\r\n }\r\n\r\n // Layout-1.3.0 does support validation. The layout is invalid and will throw an exception.\r\n final TableLayoutDesc desc =\r\n KijiTableLayouts.getLayout(INVALID_AVRO_VALIDATION_TEST);\r\n try {\r\n validator.validate(null, KijiTableLayout.newLayout(desc));\r\n fail(\"should have thrown InvalidLayoutSchemaException because int and string are \"\r\n + \"incompatible.\");\r\n } catch (InvalidLayoutSchemaException ilse) {\r\n assertTrue(ilse.getReasons().contains(\r\n \"In column: 'info:fullname' Reader schema: \\\"int\\\" is incompatible with \"\r\n + \"writer schema: \\\"string\\\".\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Validates a new table layout against a reference layout for mutual compatibility.\\\\\\\\n *\\\\\\\\n * @param reference the reference layout against which to validate.\\\\\\\\n * @param layout the new layout to validate.\\\\\\\\n * @throws IOException in case of an IO Error reading from the schema table.\\\\\\\\n * Throws InvalidLayoutException if the layouts are incompatible.\\\\\\\\n */', '')\", \"('', '// Layout versions older than layout-1.3.0 do not require validation\\\\n')\", \"('', '// Accumulator for error messages which will be used to create an exception if errors occur.\\\\n')\", \"('', '// Iterate through all families/columns in the new layout,\\\\n')\", \"('', '// find a potential matching reference family/column,\\\\n')\", \"('', '// and validate the reader/writer schema sets.\\\\n')\", \"('', '// If no matching family/column exists in the reference layout the newly create column is valid.\\\\n')\", \"('', '// If there is a reference layout, check for a locality group matching the ID of the LG for\\\\n')\", \"('', '// this family. Locality Group IDs should not change between layouts.\\\\n')\", \"('', '// If there is a matching reference LG get its layout by name.\\\\n')\", \"('', '// The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\\\\n')\", \"('', '// this family in the reference layout if present.\\\\n')\", \"('', '// If the family is map-type, get the CellSchema for all values in the family.\\\\n')\", \"('', '// If there is a matching reference LG, check for the existence of this family.\\\\n')\", \"('', '// If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\\\\n')\", \"('', '// If the FamilyLayout changed from group-type to map-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// Check for a matching family from the reference layout.\\\\n')\", \"('', '// If there is a matching reference family and it is the same family type, iterate\\\\n')\", \"('', '// through the columns checking schema compatibility. Only checks columns from the new\\\\n')\", \"('', '// layout because removed columns are inherently valid.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// layout.\\\\n')\", \"('', '// If there is a column from the reference layout with the same column ID, get its\\\\n')\", \"('', '// CellSchema.\\\\n')\", \"('', '// If there is no matching column, refCellSchema will be null and this will only test\\\\n')\", \"('', '// that the new reader and writer schemas are internally compatible.\\\\n')\", \"('', '// If the FamilyLayout changed from map-type to group-type between table layout versions\\\\n')\", \"('', '// that is an incompatible change.\\\\n')\", \"('', '// If the reference FamilyLayout is null this indicates a new family, which is inherently\\\\n')\", \"('', '// compatible, but we still have to validate that the new readers and writers are\\\\n')\", \"('', '// internally compatible.\\\\n')\", \"('', '// If there were any incompatibility errors, throw an exception.\\\\n')\"]", "focal_method": "b'/**\\n * Validates a new table layout against a reference layout for mutual compatibility.\\n *\\n * @param reference the reference layout against which to validate.\\n * @param layout the new layout to validate.\\n * @throws IOException in case of an IO Error reading from the schema table.\\n * Throws InvalidLayoutException if the layouts are incompatible.\\n */'public void validate(KijiTableLayout reference, KijiTableLayout layout) throws IOException {\r\n\r\n final ProtocolVersion layoutVersion = ProtocolVersion.parse(layout.getDesc().getVersion());\r\n\r\n if (layoutVersion.compareTo(Versions.LAYOUT_VALIDATION_VERSION) < 0) {\r\n // Layout versions older than layout-1.3.0 do not require validation\r\n return;\r\n }\r\n\r\n // Accumulator for error messages which will be used to create an exception if errors occur.\r\n final List<String> incompatabilityMessages = Lists.newArrayList();\r\n\r\n // Iterate through all families/columns in the new layout,\r\n // find a potential matching reference family/column,\r\n // and validate the reader/writer schema sets.\r\n // If no matching family/column exists in the reference layout the newly create column is valid.\r\n for (FamilyLayout flayout : layout.getFamilies()) {\r\n final ColumnId lgid = flayout.getLocalityGroup().getId();\r\n\r\n LocalityGroupLayout refLGLayout = null;\r\n if (reference != null) {\r\n // If there is a reference layout, check for a locality group matching the ID of the LG for\r\n // this family. Locality Group IDs should not change between layouts.\r\n final String refLGName = reference.getLocalityGroupIdNameMap().get(lgid);\r\n if (refLGName != null) {\r\n // If there is a matching reference LG get its layout by name.\r\n refLGLayout = reference.getLocalityGroupMap().get(refLGName);\r\n }\r\n }\r\n\r\n // The ColumnId of the FamilyLayout from the table layout. Also matches the FamilyLayout for\r\n // this family in the reference layout if present.\r\n final ColumnId familyId = flayout.getId();\r\n\r\n if (flayout.isMapType()) {\r\n // If the family is map-type, get the CellSchema for all values in the family.\r\n final CellSchema cellSchema = flayout.getDesc().getMapSchema();\r\n\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n // If there is a matching reference LG, check for the existence of this family.\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout from both table layouts are map type, compare their CellSchemas.\r\n final CellSchema refCellSchema = refFamilyLayout.getDesc().getMapSchema();\r\n\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(refCellSchema, cellSchema)));\r\n } else if (refFamilyLayout.isGroupType()) {\r\n // If the FamilyLayout changed from group-type to map-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from group-type to map-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), null, validateCellSchema(null, cellSchema)));\r\n }\r\n } else if (flayout.isGroupType()) {\r\n // Check for a matching family from the reference layout.\r\n FamilyLayout refFamilyLayout = null;\r\n if (refLGLayout != null) {\r\n final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);\r\n if (refFamilyName != null) {\r\n refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);\r\n }\r\n }\r\n\r\n if (refFamilyLayout != null) {\r\n if (refFamilyLayout.isGroupType()) {\r\n // If there is a matching reference family and it is the same family type, iterate\r\n // through the columns checking schema compatibility. Only checks columns from the new\r\n // layout because removed columns are inherently valid.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n\r\n final String refColumnName =\r\n refFamilyLayout.getColumnIdNameMap().get(columnLayout.getId());\r\n ColumnLayout refColumnLayout = null;\r\n if (refColumnName != null) {\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // layout.\r\n refColumnLayout = refFamilyLayout.getColumnMap().get(refColumnName);\r\n }\r\n // If there is a column from the reference layout with the same column ID, get its\r\n // CellSchema.\r\n final CellSchema refCellSchema =\r\n (refColumnLayout == null) ? null : refColumnLayout.getDesc().getColumnSchema();\r\n\r\n // If there is no matching column, refCellSchema will be null and this will only test\r\n // that the new reader and writer schemas are internally compatible.\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(),\r\n columnLayout.getName(),\r\n validateCellSchema(refCellSchema, cellSchema)));\r\n }\r\n } else if (refFamilyLayout.isMapType()) {\r\n // If the FamilyLayout changed from map-type to group-type between table layout versions\r\n // that is an incompatible change.\r\n incompatabilityMessages.add(String.format(\r\n \"Family: %s changed from map-type to group-type.\", refFamilyLayout.getName()));\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", refFamilyLayout.getName()));\r\n }\r\n } else {\r\n // If the reference FamilyLayout is null this indicates a new family, which is inherently\r\n // compatible, but we still have to validate that the new readers and writers are\r\n // internally compatible.\r\n for (ColumnLayout columnLayout : flayout.getColumns()) {\r\n final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema();\r\n incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(\r\n flayout.getName(), columnLayout.getName(), validateCellSchema(null, cellSchema)));\r\n }\r\n }\r\n\r\n } else {\r\n throw new InternalKijiError(String.format(\r\n \"Family: %s is neither map-type nor group-type.\", flayout.getName()));\r\n }\r\n }\r\n\r\n // If there were any incompatibility errors, throw an exception.\r\n if (incompatabilityMessages.size() != 0) {\r\n throw new InvalidLayoutSchemaException(incompatabilityMessages);\r\n }\r\n }", "test_case": "@Test\r\n public void testAddRemoveModifyColumns() throws IOException {\r\n final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(getKiji());\r\n final KijiColumnName validatedColumn = KijiColumnName.create(\"info:qual0\");\r\n final TableLayoutDesc desc = new TableLayoutBuilder(\r\n KijiTableLayouts.getLayout(AVRO_VALIDATION_TEST), getKiji())\r\n .withReader(validatedColumn, TestRecord5.SCHEMA$)\r\n .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)\r\n .withLayoutId(\"original\")\r\n .build();\r\n\r\n // The initial layout is valid.\r\n validator.validate(null, KijiTableLayout.newLayout(desc));\r\n\r\n // Create an update which removes a column, adds a column, and modifies the set of readers for a\r\n // column in a compatible way.\r\n final TableLayoutDesc updateDesc =\r\n KijiTableLayouts.getLayout(AVRO_VALIDATION_UPDATE_TEST);\r\n updateDesc.setReferenceLayout(\"original\");\r\n updateDesc.setLayoutId(\"updated\");\r\n final TableLayoutDesc newDesc = new TableLayoutBuilder(updateDesc, getKiji())\r\n .withReader(validatedColumn, TestRecord4.SCHEMA$)\r\n .build();\r\n\r\n validator.validate(KijiTableLayout.newLayout(desc), KijiTableLayout.newLayout(newDesc));\r\n }"}
{"description": "Initializes a ZooKeeper client The new ZooKeeperClient is returned with a retain count of one @param zkAddress Address of the ZooKeeper quorum as a commaseparated list of hostport", "focal_method": "b'/**\\n * Initializes a ZooKeeper client. The new ZooKeeperClient is returned with a retain count of one.\\n *\\n * @param zkAddress Address of the ZooKeeper quorum, as a comma-separated list of \"host:port\".\\n */'private ZooKeeperClient(String zkAddress) {\r\n this.mZKAddress = zkAddress;\r\n LOG.debug(\"Created {}\", this);\r\n }", "test_case": "@Test\r\n public void testZooKeeperClient() throws Exception {\r\n final ZooKeeperClient client = ZooKeeperClient.getZooKeeperClient(getZKAddress());\r\n\r\n try {\r\n Preconditions.checkNotNull(client.getZKClient(1.0));\r\n\r\n // Kill the ZooKeeper session\r\n KillSession.kill(client.getZKClient(1.0), getZKAddress());\r\n\r\n // This operation should block until a new ZooKeeper session is established, then proceed:\r\n client.createNodeRecursively(new File(\"/a/b/c/d/e/f\"));\r\n\r\n Assert.assertEquals(0, client.exists(new File(\"/a/b/c/d/e/f\")).getVersion());\r\n\r\n } finally {\r\n client.release();\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testDeprecatedVersion() throws Exception {\r\n final TableLayoutDesc validDesc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(makeRawRKF1())\r\n .setVersion(\"kiji-1.0\")\r\n .build();\r\n try {\r\n KijiTableLayout validLayout = KijiTableLayout.newLayout(validDesc);\r\n } catch (InvalidLayoutException ile) {\r\n fail(\"Deprecated version 'kiji-1.0' should be valid.\");\r\n }\r\n\r\n final TableLayoutDesc invalidDesc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(makeRawRKF1())\r\n .setVersion(\"kiji-1.1\")\r\n .build();\r\n try {\r\n KijiTableLayout invalidLayout = KijiTableLayout.newLayout(invalidDesc);\r\n fail(\"Layout version kiji-1.1 should be invalid.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected.\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testDuplicateFamilyName() throws Exception {\r\n RowKeyFormat2 format = makeHashPrefixedRowKeyFormat();\r\n // Reference layout with a single column: \"family_name:column_name\"\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(format)\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .setLocalityGroups(Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder()\r\n .setName(\"locality_group_name\")\r\n .setInMemory(false)\r\n .setTtlSeconds(84600)\r\n .setMaxVersions(1)\r\n .setCompressionType(CompressionType.GZ)\r\n .setFamilies(Lists.newArrayList(\r\n FamilyDesc.newBuilder()\r\n .setName(\"family_name\")\r\n .setColumns(Lists.newArrayList(\r\n ColumnDesc.newBuilder()\r\n .setName(\"column_name\")\r\n .setColumnSchema(CellSchema.newBuilder()\r\n .setStorage(SchemaStorage.UID)\r\n .setType(SchemaType.INLINE)\r\n .setValue(\"\\\"string\\\"\")\r\n .build())\r\n .build(),\r\n ColumnDesc.newBuilder()\r\n .setName(\"column2_name\")\r\n .setColumnSchema(CellSchema.newBuilder()\r\n .setStorage(SchemaStorage.UID)\r\n .setType(SchemaType.INLINE)\r\n .setValue(\"\\\"bytes\\\"\")\r\n .build())\r\n .build()\r\n ))\r\n .build(),\r\n FamilyDesc.newBuilder()\r\n .setName(\"family2_name\")\r\n .setMapSchema(CellSchema.newBuilder()\r\n .setStorage(SchemaStorage.FINAL)\r\n .setType(SchemaType.COUNTER)\r\n .build())\r\n .build()\r\n ))\r\n .build(),\r\n LocalityGroupDesc.newBuilder()\r\n .setName(\"locality_group2_name\")\r\n .setInMemory(false)\r\n .setTtlSeconds(84600)\r\n .setMaxVersions(1)\r\n .setCompressionType(CompressionType.GZ)\r\n .setFamilies(Lists.newArrayList(\r\n FamilyDesc.newBuilder()\r\n .setName(\"family_name\")\r\n .setMapSchema(CellSchema.newBuilder()\r\n .setStorage(SchemaStorage.FINAL)\r\n .setType(SchemaType.COUNTER)\r\n .build())\r\n .build()\r\n ))\r\n .build()\r\n ))\r\n .build();\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Invalid layout with duplicate family name did not throw.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected duplicate family error: \" + ile);\r\n assertTrue(ile.getMessage().contains(\"duplicate family name 'family_name'\"));\r\n }\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testClusterIdentifier() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(null, uri.getInstance());\r\n assertEquals(null, uri.getTable());\r\n assertTrue(uri.getColumns().isEmpty());\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testZeroMaxFilesize() throws Exception {\r\n // Simple layout with minimal config\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMaxFilesize(0L)\r\n .build();\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"max_filesize of 0 didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected max_filesize validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"max_filesize must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testNegativeMaxFilesize() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMaxFilesize(-1L)\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Negative max_filesize didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected max_filesize validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"max_filesize must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testZeroMemstoreFlushsize() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMemstoreFlushsize(0L)\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Negative memstore_flushsize didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected memstore_flushsize validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"memstore_flushsize must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testNegativeMemstoreFlushsize() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMemstoreFlushsize(-1L)\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Negative memstore_flushsize didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected memstore_flushsize validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"memstore_flushsize must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testMaxfilesizeOnOlderLayoutVersion() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMaxFilesize(10L)\r\n .setVersion(TABLE_LAYOUT_1_1)\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(String.format(\"Expected exception because max_filesize is set on a table layout \"\r\n + \"with version prior to %s.\", TABLE_LAYOUT_1_2));\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"begins with layout version \"\r\n + TABLE_LAYOUT_1_2));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testMemstoreFlushsizeOnOlderLayoutVersion() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setMemstoreFlushsize(10L)\r\n .setVersion(TABLE_LAYOUT_1_1)\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(String.format(\"Expected exception because memstore_flushsize is set on a table \"\r\n + \"layout with version prior to %s.\", TABLE_LAYOUT_1_2));\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"begins with layout version \"\r\n + TABLE_LAYOUT_1_2));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testZeroBlockSize() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setLocalityGroups(\r\n Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder(makeMinimalLocalityGroup())\r\n .setBlockSize(0)\r\n .build()))\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"block_size of 0 didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"block_size must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testNegativeBlockSize() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setLocalityGroups(\r\n Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder(makeMinimalLocalityGroup())\r\n .setBlockSize(-1)\r\n .build()))\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Negative block_size didn't throw exception.\");\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"block_size must be greater than 0\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testBlockSizeOnOlderLayoutVersion() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setVersion(TABLE_LAYOUT_1_1)\r\n .setLocalityGroups(\r\n Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder(makeMinimalLocalityGroup())\r\n .setBlockSize(10)\r\n .build()))\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n String failureMsg = String.format(\"Expected exception because block_size is set on a \"\r\n + \"locality group for a table layout with version prior to %s.\", TABLE_LAYOUT_1_2);\r\n fail(failureMsg);\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"begins with layout version \"\r\n + TABLE_LAYOUT_1_2));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testBloomTypeOnOlderLayoutVersion() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder(makeMinimalValidLayout())\r\n .setVersion(TABLE_LAYOUT_1_1)\r\n .setLocalityGroups(\r\n Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder(makeMinimalLocalityGroup())\r\n .setBloomType(BloomType.ROWCOL)\r\n .build()))\r\n .build();\r\n\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n String failureMsg = String.format(\"Expected exception because bloom_type is set on a \"\r\n + \"locality group for a table layout with version prior to %s.\", TABLE_LAYOUT_1_2);\r\n fail(failureMsg);\r\n } catch (InvalidLayoutException ile) {\r\n // Expected:\r\n LOG.info(\"Expected layout version validation error: \" + ile);\r\n assertThat(ile.getMessage(), containsString(\"begins with layout version \"\r\n + TABLE_LAYOUT_1_2));\r\n }\r\n }"}
{"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n * <ul>\\\\\\\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\\\\\\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\\\\\\\n * (<tt>\"default\"</tt>).</li>\\\\\\\\n * <li>The table name and column names are explicitly left unset.</li>\\\\\\\\n * </ul>\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * <ul>\\n * <li>The Zookeeper quorum and client port is taken from the Hadoop <tt>Configuration</tt></li>\\n * <li>The Kiji instance name is set to <tt>KConstants.DEFAULT_INSTANCE_NAME</tt>\\n * (<tt>\"default\"</tt>).</li>\\n * <li>The table name and column names are explicitly left unset.</li>\\n * </ul>\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testKijiInstanceUri() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/instance\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(null, uri.getTable());\r\n assertTrue(uri.getColumns().isEmpty());\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testInvalidLocalityGroupTTLSeconds() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(makeRawRKF1())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .setLocalityGroups(Lists.newArrayList(LocalityGroupDesc.newBuilder()\r\n .setName(\"default\")\r\n .setCompressionType(CompressionType.NONE)\r\n .setTtlSeconds(-1)\r\n .setMaxVersions(1)\r\n .setInMemory(false)\r\n .build()))\r\n .build();\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Invalid locality group with negative TTL seconds did not throw\");\r\n } catch (InvalidLayoutException ile) {\r\n assertTrue(ile.getMessage().contains(\"Invalid TTL seconds for locality group\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testInvalidLocalityGroupMaxVersions() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(makeHashedRKF1())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .setLocalityGroups(Lists.newArrayList(LocalityGroupDesc.newBuilder()\r\n .setName(\"default\")\r\n .setCompressionType(CompressionType.NONE)\r\n .setTtlSeconds(1)\r\n .setMaxVersions(-1)\r\n .setInMemory(false)\r\n .build()))\r\n .build();\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Invalid locality group with negative max versions did not throw\");\r\n } catch (InvalidLayoutException ile) {\r\n assertTrue(ile.getMessage().contains(\"Invalid max versions for locality group\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testFinalColumnSchemaClassInvalid() throws Exception {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(makeHashPrefixedRKF1())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .setLocalityGroups(Lists.newArrayList(\r\n LocalityGroupDesc.newBuilder()\r\n .setName(\"locality_group_name\")\r\n .setInMemory(false)\r\n .setTtlSeconds(84600)\r\n .setMaxVersions(1)\r\n .setCompressionType(CompressionType.GZ)\r\n .setFamilies(Lists.newArrayList(\r\n FamilyDesc.newBuilder()\r\n .setName(\"family_name\")\r\n .setColumns(Lists.newArrayList(\r\n ColumnDesc.newBuilder()\r\n .setName(\"column_name\")\r\n .setColumnSchema(CellSchema.newBuilder()\r\n .setStorage(SchemaStorage.FINAL)\r\n .setType(SchemaType.CLASS)\r\n .setValue(\"dummy.Class\")\r\n .build())\r\n .build()))\r\n .build()))\r\n .build()))\r\n .build();\r\n try {\r\n KijiTableLayout.newLayout(desc);\r\n fail(\"Final column schema must be inline\");\r\n } catch (InvalidLayoutException ile) {\r\n assertTrue(ile.getMessage().contains(\"Invalid final column schema\"));\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Get the hash size for a given row key format.\\\\\\\\n *\\\\\\\\n * @param rowKeyFormat Format of row keys of type RowKeyFormat or RowKeyFormat2.\\\\\\\\n * @return The size of the hash prefix.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Get the hash size for a given row key format.\\n *\\n * @param rowKeyFormat Format of row keys of type RowKeyFormat or RowKeyFormat2.\\n * @return The size of the hash prefix.\\n */'public static int getHashSize(Object rowKeyFormat) {\r\n if (rowKeyFormat instanceof RowKeyFormat) {\r\n return ((RowKeyFormat) rowKeyFormat).getHashSize();\r\n } else if (rowKeyFormat instanceof RowKeyFormat2) {\r\n RowKeyFormat2 format2 = (RowKeyFormat2) rowKeyFormat;\r\n if (null == format2.getSalt()) {\r\n throw new RuntimeException(\"This RowKeyFormat2 instance does not specify salt/hashing.\");\r\n } else {\r\n return format2.getSalt().getHashSize();\r\n }\r\n } else {\r\n throw new RuntimeException(\"Unsupported Row Key Format\");\r\n }\r\n }", "test_case": "@Test\r\n public void testKijiTableHashSize() throws Exception {\r\n // default hash size for RowKeyFormat2 is 16\r\n assertEquals(16, KijiTableLayout.getHashSize(makeHashPrefixedRowKeyFormat()));\r\n // default hash size for RowKeyFormat is 0\r\n assertEquals(0, KijiTableLayout.getHashSize(makeHashPrefixedRKF1()));\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testSuppressMaterializationRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(suppressMaterializationRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testBadSuppressMaterializationRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(badSuppressMaterializationRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Range scans are not supported if suppress_key_materialization is true. Please \"\r\n + \"set range_scan_start_index to components.size\", ile.getMessage());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testNoComponentsRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(noComponentsRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"At least 1 component is required in row key format.\", ile.getMessage());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void testBadNullableIndexRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(badNullableIndexRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\r\n \"Invalid index for nullable component. The second component onwards can be set to null.\",\r\n ile.getMessage());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void badRangeScanIndexRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(badRangeScanIndexRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\r\n \"Invalid range scan index. Range scans are supported starting with the second component.\",\r\n ile.getMessage());\r\n }\r\n }"}
{"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void badCompNameRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(badCompNameRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Names should begin with a letter followed by a combination of letters, numbers \"\r\n + \"and underscores.\", ile.getMessage());\r\n }\r\n }"} |