description
stringlengths
11
2.86k
focal_method
stringlengths
70
6.25k
test_case
stringlengths
96
15.3k
["('/**\\\\n * Validates that the provided reader schema can be used to decode avro data written with the\\\\n * provided writer schema.\\\\n *\\\\n * @param reader schema to check.\\\\n * @param writer schema to check.\\\\n * @return a result object identifying any compatibility errors.\\\\n */', '')"]
b'/**\n * Validates that the provided reader schema can be used to decode avro data written with the\n * provided writer schema.\n *\n * @param reader schema to check.\n * @param writer schema to check.\n * @return a result object identifying any compatibility errors.\n */'public static SchemaPairCompatibility checkReaderWriterCompatibility( final Schema reader, final Schema writer ) { final SchemaCompatibilityType compatibility = new ReaderWriterCompatiblityChecker() .getCompatibility(reader, writer); final String message; switch (compatibility) { case INCOMPATIBLE: { message = String.format( "Data encoded using writer schema:%n%s%n" + "will or may fail to decode using reader schema:%n%s%n", writer.toString(true), reader.toString(true)); break; } case COMPATIBLE: { message = READER_WRITER_COMPATIBLE_MESSAGE; break; } default: throw new InternalKijiError("Unknown compatibility: " + compatibility); } return new SchemaPairCompatibility( compatibility, reader, writer, message); }
@Test public void testReaderWriterIncompatibility() { for (ReaderWriter readerWriter : INCOMPATIBLE_READER_WRITER_TEST_CASES) { final Schema reader = readerWriter.getReader(); final Schema writer = readerWriter.getWriter(); LOG.debug("Testing incompatibility of reader {} with writer {}.", reader, writer); final SchemaPairCompatibility result = AvroUtils.checkReaderWriterCompatibility(reader, writer); assertEquals(String.format( "Expecting reader %s to be incompatible with writer %s, but tested compatible.", reader, writer), SchemaCompatibilityType.INCOMPATIBLE, result.getType()); } }
Validates that the provided reader schemas can be used to decode data written with the provided writer schema @param readers that must be able to be used to decode data encoded with the provided writer schema @param writer schema to check @return a list of compatibility results Check compatibility between each readerwriter pair
b'/**\n * Validates that the provided reader schemas can be used to decode data written with the provided\n * writer schema.\n *\n * @param readers that must be able to be used to decode data encoded with the provided writer\n * schema.\n * @param writer schema to check.\n * @return a list of compatibility results.\n */'public static SchemaSetCompatibility checkWriterCompatibility( Iterator<Schema> readers, Schema writer) { final List<SchemaPairCompatibility> results = Lists.newArrayList(); while (readers.hasNext()) { // Check compatibility between each reader/writer pair. results.add(checkReaderWriterCompatibility(readers.next(), writer)); } return new SchemaSetCompatibility(results); }
@Test public void testCheckWriterCompatibility() throws Exception { // Setup schema fields. final List<Schema.Field> writerFields = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null)); final List<Schema.Field> readerFields1 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("newfield1", INT_SCHEMA, null, IntNode.valueOf(42))); final List<Schema.Field> readerFields2 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null), new Schema.Field("newfield1", INT_SCHEMA, null, IntNode.valueOf(42))); final List<Schema.Field> readerFields3 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null)); final List<Schema.Field> readerFields4 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("newfield1", INT_SCHEMA, null, null)); // Setup schemas. final Schema writer = Schema.createRecord(writerFields); final Schema reader1 = Schema.createRecord(readerFields1); final Schema reader2 = Schema.createRecord(readerFields2); final Schema reader3 = Schema.createRecord(readerFields3); final Schema reader4 = Schema.createRecord(readerFields4); final Set<Schema> readers = Sets.newHashSet( reader1, reader2, reader3, reader4); // Setup expectations. final AvroUtils.SchemaPairCompatibility result1 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.COMPATIBLE, reader1, writer, AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE); final AvroUtils.SchemaPairCompatibility result2 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.COMPATIBLE, reader2, writer, AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE); final AvroUtils.SchemaPairCompatibility result3 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.COMPATIBLE, reader3, writer, AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE); final AvroUtils.SchemaPairCompatibility result4 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, reader4, writer, String.format( "Data encoded using writer schema:\n%s\n" + "will or may fail to decode using reader schema:\n%s\n", writer.toString(true), reader4.toString(true))); // Perform the check. final AvroUtils.SchemaSetCompatibility results = AvroUtils .checkWriterCompatibility(readers.iterator(), writer); // Ensure that the results contain the expected values. assertEquals(AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, results.getType()); assertTrue(results.getCauses().contains(result1)); assertTrue(results.getCauses().contains(result2)); assertTrue(results.getCauses().contains(result3)); assertTrue(results.getCauses().contains(result4)); }
Validates that the provided reader schema can read data written with the provided writer schemas @param reader schema to check @param writers that must be compatible with the provided reader schema @return a list of compatibility results Check compatibility between each readerwriter pair
b'/**\n * Validates that the provided reader schema can read data written with the provided writer\n * schemas.\n *\n * @param reader schema to check.\n * @param writers that must be compatible with the provided reader schema.\n * @return a list of compatibility results.\n */'public static SchemaSetCompatibility checkReaderCompatibility( Schema reader, Iterator<Schema> writers) { final List<SchemaPairCompatibility> results = Lists.newArrayList(); while (writers.hasNext()) { // Check compatibility between each reader/writer pair. results.add(checkReaderWriterCompatibility(reader, writers.next())); } return new SchemaSetCompatibility(results); }
@Test public void testCheckReaderCompatibility() throws Exception { // Setup schema fields. final List<Schema.Field> writerFields1 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null)); final List<Schema.Field> writerFields2 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null), new Schema.Field("newfield1", INT_SCHEMA, null, null)); final List<Schema.Field> writerFields3 = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("newfield1", INT_SCHEMA, null, null)); final List<Schema.Field> readerFields = Lists.newArrayList( new Schema.Field("oldfield1", INT_SCHEMA, null, null), new Schema.Field("oldfield2", STRING_SCHEMA, null, null)); // Setup schemas. final Schema writer1 = Schema.createRecord(writerFields1); final Schema writer2 = Schema.createRecord(writerFields2); final Schema writer3 = Schema.createRecord(writerFields3); final Schema reader = Schema.createRecord(readerFields); final Set<Schema> written = Sets.newHashSet(writer1); final Set<Schema> writers = Sets.newHashSet(writer2, writer3); // Setup expectations. final AvroUtils.SchemaPairCompatibility result1 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.COMPATIBLE, reader, writer1, AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE); final AvroUtils.SchemaPairCompatibility result2 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.COMPATIBLE, reader, writer2, AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE); final AvroUtils.SchemaPairCompatibility result3 = new AvroUtils.SchemaPairCompatibility( AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, reader, writer3, String.format( "Data encoded using writer schema:\n%s\n" + "will or may fail to decode using reader schema:\n%s\n", writer3.toString(true), reader.toString(true))); // Perform the check. final AvroUtils.SchemaSetCompatibility results = AvroUtils .checkReaderCompatibility(reader, Iterators.concat(written.iterator(), writers.iterator())); // Ensure that the results contain the expected values. assertEquals(AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, results.getType()); assertTrue(results.getCauses().contains(result1)); assertTrue(results.getCauses().contains(result2)); assertTrue(results.getCauses().contains(result3)); }
Compares two AvroSchema objects for equality within the context of the given SchemaTable @param schemaTable SchemaTable with which to resolve schema UIDs @param first one AvroSchema object to compare for equality @param second another AvroSchema object to compare for equality @return whether the two objects represent the same Schema @throws IOException in case of an error reading from the SchemaTable
b'/**\n * Compares two AvroSchema objects for equality within the context of the given SchemaTable.\n *\n * @param schemaTable SchemaTable with which to resolve schema UIDs.\n * @param first one AvroSchema object to compare for equality.\n * @param second another AvroSchema object to compare for equality.\n * @return whether the two objects represent the same Schema.\n * @throws IOException in case of an error reading from the SchemaTable.\n */'public static boolean avroSchemaEquals( final KijiSchemaTable schemaTable, final AvroSchema first, final AvroSchema second ) throws IOException { final AvroSchemaResolver resolver = new SchemaTableAvroResolver(schemaTable); return Objects.equal(resolver.apply(first), resolver.apply(second)); }
@Test public void testAvroSchemaEquals() throws IOException { final KijiSchemaTable schemaTable = getKiji().getSchemaTable(); final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA); final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA); final String stringJSON = STRING_SCHEMA.toString(); final String intJSON = INT_SCHEMA.toString(); final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build(); final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build(); final AvroSchema intUIDAS = AvroSchema.newBuilder().setUid(intUID).build(); final AvroSchema intJSONAS = AvroSchema.newBuilder().setJson(intJSON).build(); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, stringUIDAS)); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, stringJSONAS)); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, stringUIDAS)); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intUIDAS, intUIDAS)); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intUIDAS, intJSONAS)); assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intJSONAS, intUIDAS)); assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, intUIDAS)); assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, intJSONAS)); assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, intJSONAS)); assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, intUIDAS)); }
["('/**\\\\n * Check whether a collection of AvroSchema objects contains a given AvroSchema element, resolving\\\\n * UIDs using the given KijiSchemaTable.\\\\n *\\\\n * @param schemaTable KijiSchemaTable with which to resolve schema UIDs.\\\\n * @param schemaCollection collection of AvroSchemas to check for the presence of the given\\\\n * element.\\\\n * @param element AvroSchema for whose presence to check in schemaCollection.\\\\n * @return whether schemaCollection contains element after resolving UIDs using schemaTable.\\\\n * @throws IOException in case of an error reading from the schema table.\\\\n */', '')", "('', '// If none match, return false.\\n')"]
b'/**\n * Check whether a collection of AvroSchema objects contains a given AvroSchema element, resolving\n * UIDs using the given KijiSchemaTable.\n *\n * @param schemaTable KijiSchemaTable with which to resolve schema UIDs.\n * @param schemaCollection collection of AvroSchemas to check for the presence of the given\n * element.\n * @param element AvroSchema for whose presence to check in schemaCollection.\n * @return whether schemaCollection contains element after resolving UIDs using schemaTable.\n * @throws IOException in case of an error reading from the schema table.\n */'public static boolean avroSchemaCollectionContains( final KijiSchemaTable schemaTable, final Collection<AvroSchema> schemaCollection, final AvroSchema element ) throws IOException { for (AvroSchema schema : schemaCollection) { if (avroSchemaEquals(schemaTable, schema, element)) { return true; } } // If none match, return false. return false; }
@Test public void testAvroSchemaListContains() throws IOException { final KijiSchemaTable schemaTable = getKiji().getSchemaTable(); final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA); final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA); final String stringJSON = STRING_SCHEMA.toString(); final String intJSON = INT_SCHEMA.toString(); final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build(); final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build(); final AvroSchema intUIDAS = AvroSchema.newBuilder().setUid(intUID).build(); final AvroSchema intJSONAS = AvroSchema.newBuilder().setJson(intJSON).build(); final List<AvroSchema> stringList = Lists.newArrayList(stringJSONAS, stringUIDAS); final List<AvroSchema> intList = Lists.newArrayList(intJSONAS, intUIDAS); final List<AvroSchema> bothList = Lists.newArrayList(stringJSONAS, intUIDAS); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, stringJSONAS)); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, stringUIDAS)); assertFalse(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, intUIDAS)); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, intJSONAS)); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, intUIDAS)); assertFalse(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, stringUIDAS)); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, bothList, stringJSONAS)); assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, bothList, intUIDAS)); }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testExtraPath() { try { KijiURI.newBuilder("kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/extra"); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals("Invalid Kiji URI: 'kiji-hbase://(zkhost1,zkhost2):1234/" + "instance/table/col/extra' : Too many path segments.", kurie.getMessage()); } }
["('/**\\\\n * Decodes a JSON encoded record.\\\\n *\\\\n * @param json JSON tree to decode, encoded as a string.\\\\n * @param schema Avro schema of the value to decode.\\\\n * @return the decoded value.\\\\n * @throws IOException on error.\\\\n */', '')"]
b'/**\n * Decodes a JSON encoded record.\n *\n * @param json JSON tree to decode, encoded as a string.\n * @param schema Avro schema of the value to decode.\n * @return the decoded value.\n * @throws IOException on error.\n */'public static Object fromJsonString(String json, Schema schema) throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JsonParser parser = new JsonFactory().createJsonParser(json) .enable(Feature.ALLOW_COMMENTS) .enable(Feature.ALLOW_SINGLE_QUOTES) .enable(Feature.ALLOW_UNQUOTED_FIELD_NAMES); final JsonNode root = mapper.readTree(parser); return fromJsonNode(root, schema); }
@Test public void testPrimitivesFromJson() throws Exception { assertEquals((Integer) 1, FromJson.fromJsonString("1", Schema.create(Schema.Type.INT))); assertEquals((Long) 1L, FromJson.fromJsonString("1", Schema.create(Schema.Type.LONG))); assertEquals((Float) 1.0f, FromJson.fromJsonString("1", Schema.create(Schema.Type.FLOAT))); assertEquals((Double) 1.0, FromJson.fromJsonString("1", Schema.create(Schema.Type.DOUBLE))); assertEquals((Float) 1.0f, FromJson.fromJsonString("1.0", Schema.create(Schema.Type.FLOAT))); assertEquals((Double) 1.0, FromJson.fromJsonString("1.0", Schema.create(Schema.Type.DOUBLE))); assertEquals("Text", FromJson.fromJsonString("'Text'", Schema.create(Schema.Type.STRING))); assertEquals("Text", FromJson.fromJsonString("\"Text\"", Schema.create(Schema.Type.STRING))); assertEquals(true, FromJson.fromJsonString("true", Schema.create(Schema.Type.BOOLEAN))); assertEquals(false, FromJson.fromJsonString("false", Schema.create(Schema.Type.BOOLEAN))); }
Hashes the input string @param input The string to hash @return The 128bit MD5 hash of the input
b'/**\n * Hashes the input string.\n *\n * @param input The string to hash.\n * @return The 128-bit MD5 hash of the input.\n */'public static byte[] hash(String input) { try { return hash(input.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@Test public void testHash() { assertArrayEquals(Hasher.hash("foo"), Hasher.hash("foo")); // 16 bytes = 128-bit MD5. assertEquals(16, Hasher.hash("bar").length); assertFalse(Arrays.equals(Hasher.hash("foo"), Hasher.hash("bar"))); }
Determines whether a string is a valid Java identifier pA valid Java identifier may not start with a number but may contain any combination of letters digits underscores or dollar signsp pSee the a hrefhttpjavasuncomdocsbooksjlsthirdeditionhtmllexicalhtml38 Java Language Specificationap @param identifier The identifier to test for validity @return Whether the identifier was valid
b'/**\n * Determines whether a string is a valid Java identifier.\n *\n * <p>A valid Java identifier may not start with a number, but may contain any\n * combination of letters, digits, underscores, or dollar signs.</p>\n *\n * <p>See the <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8">\n * Java Language Specification</a></p>\n *\n * @param identifier The identifier to test for validity.\n * @return Whether the identifier was valid.\n */'public static boolean isValidIdentifier(String identifier) { if (identifier.isEmpty() || !Character.isJavaIdentifierStart(identifier.charAt(0))) { return false; } for (int i = 1; i < identifier.length(); i++) { if (!Character.isJavaIdentifierPart(identifier.charAt(i))) { return false; } } return true; }
@Test public void testIsValidIdentifier() { assertFalse(JavaIdentifiers.isValidIdentifier("")); assertTrue(JavaIdentifiers.isValidIdentifier("a")); assertTrue(JavaIdentifiers.isValidIdentifier("B")); assertTrue(JavaIdentifiers.isValidIdentifier("_")); assertFalse(JavaIdentifiers.isValidIdentifier("-")); assertFalse(JavaIdentifiers.isValidIdentifier(".")); assertFalse(JavaIdentifiers.isValidIdentifier("0")); assertTrue(JavaIdentifiers.isValidIdentifier("_1")); assertTrue(JavaIdentifiers.isValidIdentifier("_c")); assertTrue(JavaIdentifiers.isValidIdentifier("_giw07nf")); assertTrue(JavaIdentifiers.isValidIdentifier("giw07nf")); assertFalse(JavaIdentifiers.isValidIdentifier("2giw07nf")); }
Determines whether a string could be the name of a Java class pIf this method returns true it does not necessarily mean that the Java class with codeclassNamecode exists it only means that one could write a Java class with that fullyqualified namep @param className A string to test @return Whether the class name was valid A valid class name is a bunch of valid Java identifiers separated by dots
b'/**\n * Determines whether a string could be the name of a Java class.\n *\n * <p>If this method returns true, it does not necessarily mean that the Java class with\n * <code>className</code> exists; it only means that one could write a Java class with\n * that fully-qualified name.</p>\n *\n * @param className A string to test.\n * @return Whether the class name was valid.\n */'public static boolean isValidClassName(String className) { // A valid class name is a bunch of valid Java identifiers separated by dots. for (String part : StringUtils.splitByWholeSeparatorPreserveAllTokens(className, ".")) { if (!isValidIdentifier(part)) { return false; } } return true; }
@Test public void testIsValidClassName() { assertTrue(JavaIdentifiers.isValidClassName("org.kiji.schema.Foo")); assertFalse(JavaIdentifiers.isValidClassName("org.kiji.schema..Foo")); assertTrue(JavaIdentifiers.isValidClassName("org.kiji.schema.Foo$Bar")); assertTrue(JavaIdentifiers.isValidClassName("Foo")); assertFalse(JavaIdentifiers.isValidClassName("Foo.")); assertFalse(JavaIdentifiers.isValidClassName(".Foo")); assertTrue(JavaIdentifiers.isValidClassName("_Foo")); assertTrue(JavaIdentifiers.isValidClassName("com._Foo")); assertFalse(JavaIdentifiers.isValidClassName("com.8Foo")); assertTrue(JavaIdentifiers.isValidClassName("com.Foo8")); }
Utility class may not be instantiated
b'/** Utility class may not be instantiated. */'private JvmId() { }
@Test public void testJvmId() throws Exception { final String jvmId = JvmId.get(); LOG.info("JVM ID: {}", jvmId); assertEquals(jvmId, JvmId.get()); }
["('/**\\\\n * @return true if name is a valid name for a table, locality group, family,\\\\n * or column name, and false otherwise.\\\\n * @param name the name to check.\\\\n */', '')"]
b'/**\n * @return true if name is a valid name for a table, locality group, family,\n * or column name, and false otherwise.\n * @param name the name to check.\n */'public static boolean isValidLayoutName(CharSequence name) { return VALID_LAYOUT_NAME_PATTERN.matcher(name).matches(); }
@Test public void testIsValidIdentifier() { assertFalse(KijiNameValidator.isValidLayoutName("")); assertFalse(KijiNameValidator.isValidLayoutName("0123")); assertFalse(KijiNameValidator.isValidLayoutName("0123abc")); assertFalse(KijiNameValidator.isValidLayoutName("-asdb")); assertFalse(KijiNameValidator.isValidLayoutName("abc-def")); assertFalse(KijiNameValidator.isValidLayoutName("abcdef$")); assertFalse(KijiNameValidator.isValidLayoutName("abcdef-")); assertFalse(KijiNameValidator.isValidLayoutName("abcdef(")); assertFalse(KijiNameValidator.isValidLayoutName("(bcdef")); assertFalse(KijiNameValidator.isValidLayoutName("(bcdef)")); assertTrue(KijiNameValidator.isValidLayoutName("_")); assertTrue(KijiNameValidator.isValidLayoutName("foo")); assertTrue(KijiNameValidator.isValidLayoutName("FOO")); assertTrue(KijiNameValidator.isValidLayoutName("FooBar")); assertTrue(KijiNameValidator.isValidLayoutName("foo123")); assertTrue(KijiNameValidator.isValidLayoutName("foo_bar")); assertFalse(KijiNameValidator.isValidLayoutName("abc:def")); assertFalse(KijiNameValidator.isValidLayoutName("abc\\def")); assertFalse(KijiNameValidator.isValidLayoutName("abc/def")); assertFalse(KijiNameValidator.isValidLayoutName("abc=def")); assertFalse(KijiNameValidator.isValidLayoutName("abc+def")); }
@return true if name is a valid alias for a table locality group family or column name and false otherwise @param name the name to check
b'/**\n * @return true if name is a valid alias for a table, locality group, family,\n * or column name, and false otherwise.\n * @param name the name to check.\n */'public static boolean isValidAlias(CharSequence name) { return VALID_ALIAS_PATTERN.matcher(name).matches(); }
@Test public void testIsValidAlias() { assertFalse(KijiNameValidator.isValidAlias("")); assertTrue(KijiNameValidator.isValidAlias("0123")); // Digits are ok in a leading capacity. assertTrue(KijiNameValidator.isValidAlias("0123abc")); assertTrue(KijiNameValidator.isValidAlias("abc-def")); // Dashes are ok in aliases... assertTrue(KijiNameValidator.isValidAlias("-asdb")); // Even as the first character. assertTrue(KijiNameValidator.isValidAlias("asdb-")); // Even as the first character. assertFalse(KijiNameValidator.isValidAlias("abcdef(")); assertFalse(KijiNameValidator.isValidAlias("(bcdef")); assertFalse(KijiNameValidator.isValidAlias("(bcdef)")); assertTrue(KijiNameValidator.isValidAlias("_")); assertTrue(KijiNameValidator.isValidAlias("foo")); assertTrue(KijiNameValidator.isValidAlias("FOO")); assertTrue(KijiNameValidator.isValidAlias("FooBar")); assertTrue(KijiNameValidator.isValidAlias("foo123")); assertTrue(KijiNameValidator.isValidAlias("foo_bar")); assertFalse(KijiNameValidator.isValidAlias("abc:def")); assertFalse(KijiNameValidator.isValidAlias("abc\\def")); assertFalse(KijiNameValidator.isValidAlias("abc/def")); assertFalse(KijiNameValidator.isValidAlias("abc=def")); assertFalse(KijiNameValidator.isValidAlias("abc+def")); }
["('/**\\\\n * @return true if name is a valid name for a Kiji instance and false otherwise.\\\\n * @param name the name to check.\\\\n */', '')"]
b'/**\n * @return true if name is a valid name for a Kiji instance and false otherwise.\n * @param name the name to check.\n */'public static boolean isValidKijiName(CharSequence name) { return VALID_INSTANCE_PATTERN.matcher(name).matches(); }
@Test public void testIsValidInstanceName() { assertFalse(KijiNameValidator.isValidKijiName("")); // empty string is disallowed here. assertTrue(KijiNameValidator.isValidKijiName("0123")); // leading digits are okay. assertTrue(KijiNameValidator.isValidKijiName("0123abc")); // leading digits are okay. assertFalse(KijiNameValidator.isValidKijiName("-asdb")); assertFalse(KijiNameValidator.isValidKijiName("abc-def")); assertFalse(KijiNameValidator.isValidKijiName("abcd-")); assertFalse(KijiNameValidator.isValidKijiName("abcd$")); assertTrue(KijiNameValidator.isValidKijiName("_")); assertTrue(KijiNameValidator.isValidKijiName("foo")); assertTrue(KijiNameValidator.isValidKijiName("FOO")); assertTrue(KijiNameValidator.isValidKijiName("FooBar")); assertTrue(KijiNameValidator.isValidKijiName("foo123")); assertTrue(KijiNameValidator.isValidKijiName("foo_bar")); assertFalse(KijiNameValidator.isValidKijiName("abc:def")); assertFalse(KijiNameValidator.isValidKijiName("abc\\def")); assertFalse(KijiNameValidator.isValidKijiName("abc/def")); assertFalse(KijiNameValidator.isValidKijiName("abc=def")); assertFalse(KijiNameValidator.isValidKijiName("abc+def")); }
Returns the string representation of this ProtocolVersion that was initially parsed to create this ProtocolVersion Use @link toCanonicalString to get a string representation that preserves the equals relationship @inheritDoc
b'/**\n * Returns the string representation of this ProtocolVersion that was initially\n * parsed to create this ProtocolVersion. Use {@link #toCanonicalString()} to get\n * a string representation that preserves the equals() relationship.\n *\n * {@inheritDoc}\n */'@Override public String toString() { return mParsedStr; }
@Test public void testToString() { ProtocolVersion pv1 = ProtocolVersion.parse("proto-1.2"); ProtocolVersion pv2 = ProtocolVersion.parse("proto-1.2.0"); assertEquals("proto-1.2", pv1.toString()); assertEquals("proto-1.2.0", pv2.toString()); assertTrue(pv1.equals(pv2)); assertEquals("proto-1.2.0", pv1.toCanonicalString()); assertEquals("proto-1.2.0", pv2.toCanonicalString()); }
@inheritDoc
b'/** {@inheritDoc} */'@Override public boolean equals(Object other) { if (null == other) { return false; } else if (this == other) { return true; } else if (!(other instanceof ProtocolVersion)) { return false; } ProtocolVersion otherVer = (ProtocolVersion) other; if (!checkEquality(mProtocol, otherVer.mProtocol)) { return false; } return getMajorVersion() == otherVer.getMajorVersion() && getMinorVersion() == otherVer.getMinorVersion() && getRevision() == otherVer.getRevision(); }
@Test public void testEquals() { ProtocolVersion pv1 = ProtocolVersion.parse("proto-1.2.3"); ProtocolVersion pv2 = ProtocolVersion.parse("proto-1.2.3"); assertTrue(pv1.equals(pv2)); assertTrue(pv2.equals(pv1)); assertEquals(pv1.hashCode(), pv2.hashCode()); assertEquals(0, pv1.compareTo(pv2)); assertEquals(0, pv2.compareTo(pv1)); // Required for our equals() method to imply the same hash code. assertEquals(0, Integer.valueOf(0).hashCode()); }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testURIWithQuery() { final KijiURI uri = KijiURI.newBuilder("kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col?query").build(); assertEquals("zkhost1", uri.getZookeeperQuorum().get(0)); assertEquals("zkhost2", uri.getZookeeperQuorum().get(1)); assertEquals(1234, uri.getZookeeperClientPort()); assertEquals("instance", uri.getInstance()); assertEquals("table", uri.getTable()); assertEquals("col", uri.getColumns().get(0).getName()); }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testCompare() { List<ProtocolVersion> list = Arrays.asList( ProtocolVersion.parse("proto-1.10.0"), ProtocolVersion.parse("proto-1.3.1"), ProtocolVersion.parse("proto-2.1"), ProtocolVersion.parse("proto-0.4"), ProtocolVersion.parse("proto-2.0.0"), ProtocolVersion.parse("proto-1"), ProtocolVersion.parse("proto-1.1"), ProtocolVersion.parse("other-0.9")); List<ProtocolVersion> expected = Arrays.asList( ProtocolVersion.parse("other-0.9"), ProtocolVersion.parse("proto-0.4"), ProtocolVersion.parse("proto-1"), ProtocolVersion.parse("proto-1.1"), ProtocolVersion.parse("proto-1.3.1"), ProtocolVersion.parse("proto-1.10.0"), ProtocolVersion.parse("proto-2.0.0"), ProtocolVersion.parse("proto-2.1")); Collections.sort(list); assertEquals(expected, list); }
Returns true if both are null or both are nonnull and thing1equalsthing2 @param thing1 an element to check @param thing2 the other element to check @return true if theyre both null or if thing1equalsthing2 false otherwise theyre both null
b"/**\n * Returns true if both are null, or both are non-null and\n * thing1.equals(thing2).\n *\n * @param thing1 an element to check\n * @param thing2 the other element to check\n * @return true if they're both null, or if thing1.equals(thing2);\n * false otherwise.\n */"static boolean checkEquality(Object thing1, Object thing2) { if (null == thing1 && null != thing2) { return false; } if (null != thing1 && null == thing2) { return false; } if (thing1 != null) { return thing1.equals(thing2); } else { assert null == thing2; return true; // they're both null. } }
@Test public void testCheckEquality() { assertTrue(ProtocolVersion.checkEquality(null, null)); assertTrue(ProtocolVersion.checkEquality("hi", "hi")); assertFalse(ProtocolVersion.checkEquality("hi", null)); assertFalse(ProtocolVersion.checkEquality(null, "hi")); assertTrue(ProtocolVersion.checkEquality(Integer.valueOf(32), Integer.valueOf(32))); assertFalse(ProtocolVersion.checkEquality(Integer.valueOf(32), Integer.valueOf(7))); assertFalse(ProtocolVersion.checkEquality(Integer.valueOf(32), "ohai")); assertFalse(ProtocolVersion.checkEquality("meep", "ohai")); }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoJustProto() { try { ProtocolVersion.parse("proto"); } catch (IllegalArgumentException iae) { assertEquals("verString may contain at most one dash character, separating the protocol " + "name from the version number.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoJustProto2() { try { ProtocolVersion.parse("proto-"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may contain at most one dash character, separating the protocol " + "name from the version number.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testDashRequired() { try { ProtocolVersion.parse("foo1.4"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may contain at most one dash character, separating the protocol " + "name from the version number.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoLeadingDash() { try { ProtocolVersion.parse("-foo-1.4"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may not start with a dash", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoMoreThan3() { try { ProtocolVersion.parse("1.2.3.4"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Version numbers may have at most three components.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoMoreThan3withProto() { try { ProtocolVersion.parse("proto-1.2.3.4"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Version numbers may have at most three components.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoLeadingDashWithoutProto() { try { ProtocolVersion.parse("-1.2.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may not start with a dash", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoLeadingDashes() { try { ProtocolVersion.parse("--1.2.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may not start with a dash", iae.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testURIWithFragment() { final KijiURI uri = KijiURI.newBuilder("kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col#frag").build(); assertEquals("zkhost1", uri.getZookeeperQuorum().get(0)); assertEquals("zkhost2", uri.getZookeeperQuorum().get(1)); assertEquals(1234, uri.getZookeeperClientPort()); assertEquals("instance", uri.getInstance()); assertEquals("table", uri.getTable()); assertEquals("col", uri.getColumns().get(0).getName()); }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoMultiDash() { try { ProtocolVersion.parse("proto--1.2.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may contain at most one dash character, separating the protocol " + "name from the version number.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoDashInProto() { try { ProtocolVersion.parse("proto-col-1.2.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may contain at most one dash character, separating the protocol " + "name from the version number.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoNegativeMinor() { try { ProtocolVersion.parse("1.-2"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Minor version number must be non-negative.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoNegativeRev() { try { ProtocolVersion.parse("1.2.-3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Revision number must be non-negative.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoMultiDots() { try { ProtocolVersion.parse("1..2"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Could not parse numeric version info in 1..2", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoMultiDots2() { try { ProtocolVersion.parse("1..2.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Version numbers may have at most three components.", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoNamedMinor() { try { ProtocolVersion.parse("1.x"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Could not parse numeric version info in 1.x", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoNamedMinorWithProto() { try { ProtocolVersion.parse("proto-1.x"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Could not parse numeric version info in proto-1.x", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoLeadingNumber() { try { ProtocolVersion.parse("2foo-1.3"); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("Could not parse numeric version info in 2foo-1.3", iae.getMessage()); } }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoEmptyString() { try { ProtocolVersion.parse(""); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may not be empty", iae.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testPartialURIZookeeper() { final KijiURI uri = KijiURI.newBuilder("kiji-hbase://zkhost:1234").build(); assertEquals("zkhost", uri.getZookeeperQuorum().get(0)); assertEquals(1234, uri.getZookeeperClientPort()); assertEquals(null, uri.getInstance()); }
['(\'/**\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\n *\\\\n * <p>This method parses its argument as a string of the form:\\\\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\\\\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\\\\n * dash character is not part of the protocol name. The protocol name may not include\\\\n * a \\\\\\\'-\\\\\\\' character and must not start with a digit.\\\\n * If the protocol name is not specified, then the dash must be omitted.</p>\\\\n *\\\\n * <p>The following are examples of legal protocol versions:</p>\\\\n * <ul>\\\\n * <li>"data-1.0"</li>\\\\n * <li>"kiji-1.2.3"</li>\\\\n * <li>"1.3.1"</li>\\\\n * <li>"76"</li>\\\\n * <li>"2.3"</li>\\\\n * <li>"spec-1"</li>\\\\n * </ul>\\\\n *\\\\n * <p>The following are illegal:</p>\\\\n * <ul>\\\\n * <li>"foo" (no version number)</li>\\\\n * <li>"foo1.2" (no dash after the protocol name)</li>\\\\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\\\\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\\\\n * <li>"-1.2.3" (version numbers may not be negative)</li>\\\\n * <li>"1.-2" (version numbers may not be negative)</li>\\\\n * <li>"1.x" (version numbers must be integers)</li>\\\\n * <li>"foo-1.x" (version numbers must be integers)</li>\\\\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\\\\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\\\\n * <li>"" (the empty string is not allowed as a version)</li>\\\\n * <li>null</li>\\\\n * </ul>\\\\n *\\\\n * @param verString the version string to parse.\\\\n * @return a new, parsed ProtocolVersion instance.\\\\n * @throws IllegalArgumentException if the version string cannot be parsed according\\\\n * to the rules above.\\\\n */\', \'\')', '(\'\', "// Start by parsing a protocol name. Scan forward to the \'-\'.\\n")', '(\'\', "// only use the string part after the \'-\' for ver numbers.\\n")']
b'/**\n * Static factory method that creates new ProtocolVersion instances.\n *\n * <p>This method parses its argument as a string of the form:\n * <tt>protocol-maj.min.rev</tt>. All fields except the major digit are optional.\n * maj, min, and rev must be non-negative integers. protocol is a string; the trailing\n * dash character is not part of the protocol name. The protocol name may not include\n * a \'-\' character and must not start with a digit.\n * If the protocol name is not specified, then the dash must be omitted.</p>\n *\n * <p>The following are examples of legal protocol versions:</p>\n * <ul>\n * <li>"data-1.0"</li>\n * <li>"kiji-1.2.3"</li>\n * <li>"1.3.1"</li>\n * <li>"76"</li>\n * <li>"2.3"</li>\n * <li>"spec-1"</li>\n * </ul>\n *\n * <p>The following are illegal:</p>\n * <ul>\n * <li>"foo" (no version number)</li>\n * <li>"foo1.2" (no dash after the protocol name)</li>\n * <li>"-foo-1.2" (protocol may not start with a dash)</li>\n * <li>"1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"bar-1.2.3.4" (only 3-component version numbers are supported)</li>\n * <li>"-1.2.3" (version numbers may not be negative)</li>\n * <li>"1.-2" (version numbers may not be negative)</li>\n * <li>"1.x" (version numbers must be integers)</li>\n * <li>"foo-1.x" (version numbers must be integers)</li>\n * <li>"2foo-1.3" (protocol names may not start with a digit)</li>\n * <li>"foo-bar-1.x" (protocol names may not contain a dash)</li>\n * <li>"" (the empty string is not allowed as a version)</li>\n * <li>null</li>\n * </ul>\n *\n * @param verString the version string to parse.\n * @return a new, parsed ProtocolVersion instance.\n * @throws IllegalArgumentException if the version string cannot be parsed according\n * to the rules above.\n */'public static ProtocolVersion parse(String verString) { Preconditions.checkArgument(null != verString, "verString may not be null"); Preconditions.checkArgument(!verString.isEmpty(), "verString may not be empty"); Preconditions.checkArgument(verString.charAt(0) != '-', "verString may not start with a dash"); String proto = null; int major = 0; int minor = 0; int rev = 0; int pos = 0; String numericPart = verString; if (!Character.isDigit(verString.charAt(pos))) { // Start by parsing a protocol name. Scan forward to the '-'. String[] nameParts = verString.split("-"); if (nameParts.length != 2) { throw new IllegalArgumentException("verString may contain at most one dash character, " + "separating the protocol name from the version number."); } proto = nameParts[0]; numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers. } String[] verParts = numericPart.split("\\."); if (verParts.length > 3) { throw new IllegalArgumentException("Version numbers may have at most three components."); } try { major = Integer.parseInt(verParts[0]); if (verParts.length > 1) { minor = Integer.parseInt(verParts[1]); } if (verParts.length > 2) { rev = Integer.parseInt(verParts[2]); } } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Could not parse numeric version info in " + verString); } if (major < 0) { throw new IllegalArgumentException("Major version number must be non-negative."); } if (minor < 0) { throw new IllegalArgumentException("Minor version number must be non-negative."); } if (rev < 0) { throw new IllegalArgumentException("Revision number must be non-negative."); } return new ProtocolVersion(verString, proto, major, minor, rev); }
@Test public void testNoNull() { try { ProtocolVersion.parse(null); fail("Should fail with an IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertEquals("verString may not be null", iae.getMessage()); } }
["('/**\\\\n * Make a best effort at closing all the cached values. This method is *not* guaranteed to close\\\\n * every cached value if there are concurrent users of the cache. As a result, this method\\\\n * should only be relied upon if only a single thread is using this cache while {@code #close} is\\\\n * called.\\\\n *\\\\n * @throws IOException if any entry throws an IOException while closing. An entry throwing an\\\\n * IOException will prevent any further entries from being cleaned up.\\\\n */', '')", "('', '// Attempt to remove the entry from the cache\\n')", "('', '// If successfull, close the value\\n')"]
b'/**\n * Make a best effort at closing all the cached values. This method is *not* guaranteed to close\n * every cached value if there are concurrent users of the cache. As a result, this method\n * should only be relied upon if only a single thread is using this cache while {@code #close} is\n * called.\n *\n * @throws IOException if any entry throws an IOException while closing. An entry throwing an\n * IOException will prevent any further entries from being cleaned up.\n */'@Override public void close() throws IOException { mIsOpen = false; for (Map.Entry<K, CacheEntry<V>> entry : mMap.entrySet()) { // Attempt to remove the entry from the cache if (mMap.remove(entry.getKey(), entry.getValue())) { // If successfull, close the value CacheEntry<V> cacheEntry = entry.getValue(); synchronized (cacheEntry) { cacheEntry.getValue().close(); } } } }
@Test(expected = IllegalStateException.class) public void closeableOnceFailsWhenDoubleClosed() throws Exception { Closeable closeable = new CloseableOnce<Object>(null); closeable.close(); closeable.close(); }
["('/**\\\\n * Constructs a split key file from an input stream. This object will take ownership of\\\\n * the inputStream, which you should clean up by calling close().\\\\n *\\\\n * @param inputStream The file contents.\\\\n * @return the region boundaries, as a list of row keys.\\\\n * @throws IOException on I/O error.\\\\n */', '')"]
b'/**\n * Constructs a split key file from an input stream. This object will take ownership of\n * the inputStream, which you should clean up by calling close().\n *\n * @param inputStream The file contents.\n * @return the region boundaries, as a list of row keys.\n * @throws IOException on I/O error.\n */'public static List<byte[]> decodeRegionSplitList(InputStream inputStream) throws IOException { try { final String content = Bytes.toString(IOUtils.toByteArray(Preconditions.checkNotNull(inputStream))); final String[] encodedKeys = content.split("\n"); final List<byte[]> keys = Lists.newArrayListWithCapacity(encodedKeys.length); for (String encodedKey : encodedKeys) { keys.add(decodeRowKey(encodedKey)); } return keys; } finally { ResourceUtils.closeOrLog(inputStream); } }
@Test public void testDecodeSplitKeyFile() throws Exception { final String content = "key1\n" + "key2\n"; final List<byte[]> keys = SplitKeyFile.decodeRegionSplitList(new ByteArrayInputStream(Bytes.toBytes(content))); assertEquals(2, keys.size()); assertArrayEquals(Bytes.toBytes("key1"), keys.get(0)); assertArrayEquals(Bytes.toBytes("key2"), keys.get(1)); }
["('/**\\\\n * Constructs a split key file from an input stream. This object will take ownership of\\\\n * the inputStream, which you should clean up by calling close().\\\\n *\\\\n * @param inputStream The file contents.\\\\n * @return the region boundaries, as a list of row keys.\\\\n * @throws IOException on I/O error.\\\\n */', '')"]
b'/**\n * Constructs a split key file from an input stream. This object will take ownership of\n * the inputStream, which you should clean up by calling close().\n *\n * @param inputStream The file contents.\n * @return the region boundaries, as a list of row keys.\n * @throws IOException on I/O error.\n */'public static List<byte[]> decodeRegionSplitList(InputStream inputStream) throws IOException { try { final String content = Bytes.toString(IOUtils.toByteArray(Preconditions.checkNotNull(inputStream))); final String[] encodedKeys = content.split("\n"); final List<byte[]> keys = Lists.newArrayListWithCapacity(encodedKeys.length); for (String encodedKey : encodedKeys) { keys.add(decodeRowKey(encodedKey)); } return keys; } finally { ResourceUtils.closeOrLog(inputStream); } }
@Test public void testDecodeSplitKeyFileNoEndNewLine() throws Exception { final String content = "key1\n" + "key2"; final List<byte[]> keys = SplitKeyFile.decodeRegionSplitList(new ByteArrayInputStream(Bytes.toBytes(content))); assertEquals(2, keys.size()); assertArrayEquals(Bytes.toBytes("key1"), keys.get(0)); assertArrayEquals(Bytes.toBytes("key2"), keys.get(1)); }
Decodes a string encoded row key @param encoded Encoded row key @return the row key as a byte array @throws IOException on IO error Escaped backslash Escaped byte in hexadecimal
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKey() throws Exception { assertArrayEquals(Bytes.toBytes("this is a \n key"), SplitKeyFile.decodeRowKey("this is a \n key")); assertArrayEquals(Bytes.toBytes("this is a \\ key"), SplitKeyFile.decodeRowKey("this is a \\\\ key")); assertArrayEquals(Bytes.toBytes("this is a \n key"), SplitKeyFile.decodeRowKey("this is a \\x0A key")); assertArrayEquals(Bytes.toBytes("this is a \n key"), SplitKeyFile.decodeRowKey("this is a \\x0a key")); }
["('/**\\\\n * Decodes a string encoded row key.\\\\n *\\\\n * @param encoded Encoded row key.\\\\n * @return the row key, as a byte array.\\\\n * @throws IOException on I/O error.\\\\n */', '')", "('', '// Escaped backslash:\\n')", "('', '// Escaped byte in hexadecimal:\\n')"]
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKeyInvalidHexEscape() throws Exception { try { SplitKeyFile.decodeRowKey("this is a \\xZZ key"); fail("An exception should have been thrown."); } catch (IOException ioe) { assertEquals("Invalid hexadecimal escape in encoded row key: 'this is a \\xZZ key'.", ioe.getMessage()); } }
["('/**\\\\n * Decodes a string encoded row key.\\\\n *\\\\n * @param encoded Encoded row key.\\\\n * @return the row key, as a byte array.\\\\n * @throws IOException on I/O error.\\\\n */', '')", "('', '// Escaped backslash:\\n')", "('', '// Escaped byte in hexadecimal:\\n')"]
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKeyInvalidEscape() throws Exception { // \n is escaped as \x0a try { SplitKeyFile.decodeRowKey("this is a \\n key"); fail("An exception should have been thrown."); } catch (IOException ioe) { assertEquals("Invalid escape in encoded row key: 'this is a \\n key'.", ioe.getMessage()); } }
["('/**\\\\n * Decodes a string encoded row key.\\\\n *\\\\n * @param encoded Encoded row key.\\\\n * @return the row key, as a byte array.\\\\n * @throws IOException on I/O error.\\\\n */', '')", "('', '// Escaped backslash:\\n')", "('', '// Escaped byte in hexadecimal:\\n')"]
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKeyUnterminatedEscape() throws Exception { try { SplitKeyFile.decodeRowKey("this is a \\"); fail("An exception should have been thrown."); } catch (IOException ioe) { assertEquals("Invalid trailing escape in encoded row key: 'this is a \\'.", ioe.getMessage()); } }
["('/**\\\\n * Decodes a string encoded row key.\\\\n *\\\\n * @param encoded Encoded row key.\\\\n * @return the row key, as a byte array.\\\\n * @throws IOException on I/O error.\\\\n */', '')", "('', '// Escaped backslash:\\n')", "('', '// Escaped byte in hexadecimal:\\n')"]
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKeyInvalidHex() throws Exception { try { SplitKeyFile.decodeRowKey("this is a \\x-6"); fail("An exception should have been thrown."); } catch (IOException ioe) { assertEquals("Invalid hexadecimal escape in encoded row key: 'this is a \\x-6'.", ioe.getMessage()); } }
["('/**\\\\n * Decodes a string encoded row key.\\\\n *\\\\n * @param encoded Encoded row key.\\\\n * @return the row key, as a byte array.\\\\n * @throws IOException on I/O error.\\\\n */', '')", "('', '// Escaped backslash:\\n')", "('', '// Escaped byte in hexadecimal:\\n')"]
b'/**\n * Decodes a string encoded row key.\n *\n * @param encoded Encoded row key.\n * @return the row key, as a byte array.\n * @throws IOException on I/O error.\n */'public static byte[] decodeRowKey(String encoded) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); int index = 0; final byte[] bytes = Bytes.toBytes(encoded); while (index < bytes.length) { final byte data = bytes[index++]; if (data != '\\') { os.write(data); } else { if (index == bytes.length) { throw new IOException(String.format( "Invalid trailing escape in encoded row key: '%s'.", encoded)); } final byte escaped = bytes[index++]; switch (escaped) { case '\\': { // Escaped backslash: os.write('\\'); break; } case 'x': { // Escaped byte in hexadecimal: if (index + 1 >= bytes.length) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2)); try { final int decodedByte = Integer.parseInt(hex, 16); if ((decodedByte < 0) || (decodedByte > 255)) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } os.write(decodedByte); } catch (NumberFormatException nfe) { throw new IOException(String.format( "Invalid hexadecimal escape in encoded row key: '%s'.", encoded)); } index += 2; break; } default: throw new IOException(String.format("Invalid escape in encoded row key: '%s'.", encoded)); } } } return os.toByteArray(); }
@Test public void testDecodeRowKeyIncompleteHex() throws Exception { try { SplitKeyFile.decodeRowKey("this is a \\x6"); fail("An exception should have been thrown."); } catch (IOException ioe) { assertEquals("Invalid hexadecimal escape in encoded row key: 'this is a \\x6'.", ioe.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testToString() { String uri = "kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/"; assertEquals(uri, KijiURI.newBuilder(uri).build().toString()); uri = "kiji-hbase://zkhost1:1234/instance/table/col/"; assertEquals(uri, KijiURI.newBuilder(uri).build().toString()); uri = "kiji-hbase://zkhost:1234/instance/table/col1,col2/"; assertEquals(uri, KijiURI.newBuilder(uri).build().toString()); uri = "kiji-hbase://zkhost:1234/.unset/table/col/"; assertEquals(uri, KijiURI.newBuilder(uri).build().toString()); }
Gets the version of the Kiji client software @return The version string @throws IOException on IO error Proper release use the value of ImplementationVersion in METAINFMANIFESTMF Most likely a development version
b'/**\n * Gets the version of the Kiji client software.\n *\n * @return The version string.\n * @throws IOException on I/O error.\n */'public static String getSoftwareVersion() throws IOException { final String version = VersionInfo.class.getPackage().getImplementationVersion(); if (version != null) { // Proper release: use the value of 'Implementation-Version' in META-INF/MANIFEST.MF: return version; } // Most likely a development version: final Properties kijiProps = loadKijiSchemaProperties(); return kijiProps.getProperty(KIJI_SCHEMA_VERSION_PROP_NAME, DEFAULT_DEVELOPMENT_VERSION); }
@Test public void testGetSoftwareVersion() throws Exception { // We cannot compare against any concrete value here, or else the test will fail // depending on whether this is a development version or a release... assertFalse(VersionInfo.getSoftwareVersion().isEmpty()); }
Reports the maximum system version of the Kiji instance format understood by the client p The instance format describes the layout of the global metadata state of a Kiji instance This version number specifies which Kiji instances it would be compatible with See @link isKijiVersionCompatible to determine whether a deployment is compatible with this version p @return A parsed version of the instance format protocol version string
b'/**\n * Reports the maximum system version of the Kiji instance format understood by the client.\n *\n * <p>\n * The instance format describes the layout of the global metadata state of\n * a Kiji instance. This version number specifies which Kiji instances it would\n * be compatible with. See {@link #isKijiVersionCompatible} to determine whether\n * a deployment is compatible with this version.\n * </p>\n *\n * @return A parsed version of the instance format protocol version string.\n */'public static ProtocolVersion getClientDataVersion() { return Versions.MAX_SYSTEM_VERSION; }
@Test public void testGetClientDataVersion() { // This is the actual version we expect to be in there right now. assertEquals(Versions.MAX_SYSTEM_VERSION, VersionInfo.getClientDataVersion()); }
Gets the version of the Kiji instance format installed on the HBase cluster pThe instance format describes the layout of the global metadata state of a Kiji instancep @param systemTable An open KijiSystemTable @return A parsed version of the storage format protocol version string @throws IOException on IO error
b'/**\n * Gets the version of the Kiji instance format installed on the HBase cluster.\n *\n * <p>The instance format describes the layout of the global metadata state of\n * a Kiji instance.</p>\n *\n * @param systemTable An open KijiSystemTable.\n * @return A parsed version of the storage format protocol version string.\n * @throws IOException on I/O error.\n */'private static ProtocolVersion getClusterDataVersion(KijiSystemTable systemTable) throws IOException { try { final ProtocolVersion dataVersion = systemTable.getDataVersion(); return dataVersion; } catch (TableNotFoundException e) { final KijiURI kijiURI = systemTable.getKijiURI(); throw new KijiNotInstalledException( String.format("Kiji instance %s is not installed.", kijiURI), kijiURI); } }
@Test public void testGetClusterDataVersion() throws Exception { final KijiSystemTable systemTable = createMock(KijiSystemTable.class); // This version number for this test was picked out of a hat. expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse("system-1.1")).anyTimes(); final Kiji kiji = createMock(Kiji.class); expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes(); replay(systemTable); replay(kiji); assertEquals(ProtocolVersion.parse("system-1.1"), VersionInfo.getClusterDataVersion(kiji)); verify(systemTable); verify(kiji); }
Validates that the client instance format version is compatible with the instance format version installed on a Kiji instance Throws IncompatibleKijiVersionException if not pFor the definition of compatibility used in this method see @link isKijiVersionCompatiblep @param kiji An open kiji instance @throws IOException on IO error reading the data version from the cluster or throws IncompatibleKijiVersionException if the installed instance format version is incompatible with the version supported by the client
b'/**\n * Validates that the client instance format version is compatible with the instance\n * format version installed on a Kiji instance.\n * Throws IncompatibleKijiVersionException if not.\n *\n * <p>For the definition of compatibility used in this method, see {@link\n * #isKijiVersionCompatible}</p>\n *\n * @param kiji An open kiji instance.\n * @throws IOException on I/O error reading the data version from the cluster,\n * or throws IncompatibleKijiVersionException if the installed instance format version\n * is incompatible with the version supported by the client.\n */'public static void validateVersion(Kiji kiji) throws IOException { validateVersion(kiji.getSystemTable()); }
@Test public void testValidateVersion() throws Exception { final KijiSystemTable systemTable = createMock(KijiSystemTable.class); expect(systemTable.getDataVersion()).andReturn(VersionInfo.getClientDataVersion()).anyTimes(); final Kiji kiji = createMock(Kiji.class); expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes(); replay(systemTable); replay(kiji); // This should validate, since we set the cluster data version to match the client version. VersionInfo.validateVersion(kiji); verify(systemTable); verify(kiji); }
["('/**\\\\n * Validates that the client instance format version is compatible with the instance\\\\n * format version installed on a Kiji instance.\\\\n * Throws IncompatibleKijiVersionException if not.\\\\n *\\\\n * <p>For the definition of compatibility used in this method, see {@link\\\\n * #isKijiVersionCompatible}</p>\\\\n *\\\\n * @param kiji An open kiji instance.\\\\n * @throws IOException on I/O error reading the data version from the cluster,\\\\n * or throws IncompatibleKijiVersionException if the installed instance format version\\\\n * is incompatible with the version supported by the client.\\\\n */', '')"]
b'/**\n * Validates that the client instance format version is compatible with the instance\n * format version installed on a Kiji instance.\n * Throws IncompatibleKijiVersionException if not.\n *\n * <p>For the definition of compatibility used in this method, see {@link\n * #isKijiVersionCompatible}</p>\n *\n * @param kiji An open kiji instance.\n * @throws IOException on I/O error reading the data version from the cluster,\n * or throws IncompatibleKijiVersionException if the installed instance format version\n * is incompatible with the version supported by the client.\n */'public static void validateVersion(Kiji kiji) throws IOException { validateVersion(kiji.getSystemTable()); }
@Test public void testValidateVersionFail() throws Exception { final KijiSystemTable systemTable = createMock(KijiSystemTable.class); expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse("kiji-0.9")).anyTimes(); final Kiji kiji = createMock(Kiji.class); expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes(); replay(systemTable); replay(kiji); // This should throw an invalid version exception. try { VersionInfo.validateVersion(kiji); fail("An exception should have been thrown."); } catch (IncompatibleKijiVersionException ikve) { assertTrue(ikve.getMessage(), Pattern.matches( "Data format of Kiji instance \\(kiji-0\\.9\\) cannot operate " + "with client \\(system-[0-9]\\.[0-9]\\)", ikve.getMessage())); } }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testKijiVsSystemProtocol() { // New client (1.0.0-rc4 or higher) interacting with a table installed via 1.0.0-rc3. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-1.0"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("kiji-1.0"); assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testOldKijiRefusesToReadNewSystemProtocol() { // The old 1.0.0-rc3 client should refuse to interop with a new instance created by // 1.0.0-rc4 or higher due to the data version protocol namespace change. Forwards // compatibility is not supported by the release candidates, even though we honor // backwards compatibility. final ProtocolVersion clientVersion = ProtocolVersion.parse("kiji-1.0"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("system-1.0"); assertFalse(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testKijiVsNewerSystemProtocol() { // An even newer client (not yet defined as of 1.0.0-rc4) that uses a 'system-1.1' // protocol should still be compatible with a table installed via 1.0.0-rc3. // kiji-1.0 => system-1.0, and all system-1.x versions should be compatible. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-1.1"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("kiji-1.0"); assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testDifferentSystemProtocols() { // In the future, when we release it, system-1.1 should be compatible with system-1.0. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-1.1"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("system-1.0"); assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testSystemProtocolName() { // A client (1.0.0-rc4 or higher) interacting with a table installed via 1.0.0-rc4. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-1.0"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("system-1.0"); assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testNormalizedQuorum() { KijiURI uri = KijiURI.newBuilder("kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/").build(); KijiURI reversedQuorumUri = KijiURI.newBuilder("kiji-hbase://(zkhost2,zkhost1):1234/instance/table/col/").build(); assertEquals(uri.toString(), reversedQuorumUri.toString()); assertEquals(uri.getZookeeperQuorum(), reversedQuorumUri.getZookeeperQuorum()); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testNoForwardCompatibility() { // A system-1.0-capable client should not be able to read a system-2.0 installation. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-1.0"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("system-2.0"); assertFalse(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
['("/**\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\n *\\\\n * <p>package-level visibility for unit testing.</p>\\\\n *\\\\n * @param clientVersion the client software\'s instance version.\\\\n * @param clusterVersion the cluster\'s installed instance version.\\\\n * @return true if the installed instance format\\\\n * version is compatible with this client, false otherwise.\\\\n */", \'\')', '(\'\', \'// The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests.\\n\')', "('', '// See SCHEMA-469.\\n')", "('', '// From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\\n')", "('', '//\\n')", "('', '// (quote)\\n')", "('', '// Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\\n')", "('', '// will read and interact with data written by Version 1.y, if x > y.\\n')", "('', '//\\n')", "('', '// ...\\n')", "('', '//\\n')", "('', '// The instance format describes the feature set and format of the entire Kiji instance.\\n')", "('', '// This allows a client to determine whether it can connect to the instance at all, read\\n')", "('', '// any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\\n')", "('', '// well as the range of supported associated formats within that metadata.\\n')", "('', '//\\n')", "('', '// The kiji version command specifies the instance version presently installed on the\\n')", "('', '// cluster, and the system data version supported by the client. The major version numbers\\n')", "('', '// of these must agree to connect to one another.\\n')", "('', '// (end quote)\\n')", "('', '//\\n')", '(\'\', "// Given these requirements, we require that our client\'s supported instance version major\\n")', "('', '// digit be greater than or equal to the major digit of the system installation.\\n')", "('', '//\\n')", "('', '// If we ever deprecate an instance format and then target it for end-of-life (i.e., when\\n')", "('', '// contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\\n')", '(\'\', "// the most recent \'k\' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\\n")', "('', '// reading/writing instances only as far back as system-9.0. This is not yet implemented;\\n')", "('', '// if we do go down this route, then this method would be the place to do it.\\n')"]
b"/**\n * Actual comparison logic that validates client/cluster data compatibility according to\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\n *\n * <p>package-level visibility for unit testing.</p>\n *\n * @param clientVersion the client software's instance version.\n * @param clusterVersion the cluster's installed instance version.\n * @return true if the installed instance format\n * version is compatible with this client, false otherwise.\n */"static boolean areInstanceVersionsCompatible( ProtocolVersion clientVersion, ProtocolVersion clusterVersion) { if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) { // The "kiji-1.0" version is equivalent to "system-1.0" in compatibility tests. clusterVersion = Versions.SYSTEM_1_0; } // See SCHEMA-469. // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility: // // (quote) // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x // will read and interact with data written by Version 1.y, if x > y. // // ... // // The instance format describes the feature set and format of the entire Kiji instance. // This allows a client to determine whether it can connect to the instance at all, read // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as // well as the range of supported associated formats within that metadata. // // The kiji version command specifies the instance version presently installed on the // cluster, and the system data version supported by the client. The major version numbers // of these must agree to connect to one another. // (end quote) // // Given these requirements, we require that our client's supported instance version major // digit be greater than or equal to the major digit of the system installation. // // If we ever deprecate an instance format and then target it for end-of-life (i.e., when // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support // reading/writing instances only as far back as system-9.0. This is not yet implemented; // if we do go down this route, then this method would be the place to do it. return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion(); }
@Test public void testBackCompatibilityThroughMajorVersions() { // A system-2.0-capable client should still be able to read a system-1.0 installation. final ProtocolVersion clientVersion = ProtocolVersion.parse("system-2.0"); final ProtocolVersion clusterVersion = ProtocolVersion.parse("system-1.0"); assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion)); }
Constructs a ZooKeeper lock object @param zookeeper ZooKeeper client @param lockDir Path of the directory node to use for the lock ZooKeeperClientretain should be the last line of the constructor
b'/**\n * Constructs a ZooKeeper lock object.\n *\n * @param zookeeper ZooKeeper client.\n * @param lockDir Path of the directory node to use for the lock.\n */'public ZooKeeperLock(ZooKeeperClient zookeeper, File lockDir) { this.mConstructorStack = CLEANUP_LOG.isDebugEnabled() ? Debug.getStackTrace() : null; this.mZKClient = zookeeper; this.mLockDir = lockDir; this.mLockPathPrefix = new File(lockDir, LOCK_NAME_PREFIX); // ZooKeeperClient.retain() should be the last line of the constructor. this.mZKClient.retain(); DebugResourceTracker.get().registerResource(this); }
@Test public void testZooKeeperLock() throws Exception { final File lockDir = new File("/lock"); final ZooKeeperClient zkClient = ZooKeeperClient.getZooKeeperClient(getZKAddress()); try { final CyclicBarrier barrier = new CyclicBarrier(2); final ZooKeeperLock lock1 = new ZooKeeperLock(zkClient, lockDir); final ZooKeeperLock lock2 = new ZooKeeperLock(zkClient, lockDir); lock1.lock(); final Thread thread = new Thread() { /** {@inheritDoc} */ @Override public void run() { try { assertFalse(lock2.lock(0.1)); barrier.await(); lock2.lock(); lock2.unlock(); lock2.lock(); lock2.unlock(); lock2.close(); barrier.await(); } catch (Exception e) { LOG.warn("Exception caught in locking thread: {}", e.getMessage()); } } }; thread.start(); barrier.await(5, TimeUnit.SECONDS); // Eventually fail lock1.unlock(); lock1.close(); barrier.await(5, TimeUnit.SECONDS); // Eventually fail } finally { zkClient.release(); } }
Try to recursively delete a directory in ZooKeeper If another thread modifies the directory or any children of the directory the recursive delete will fail and this method will return @code false @param zkClient connection to ZooKeeper @param path to the node to remove @return whether the delete succeeded or failed @throws IOException on unrecoverable ZooKeeper error Node was deleted out from under us we still have to try again because if this is thrown any parents of the deleted node possibly still exist Someone else created a node in the tree between the time we built the transaction and committed it
b'/**\n * Try to recursively delete a directory in ZooKeeper. If another thread modifies the directory\n * or any children of the directory, the recursive delete will fail, and this method will return\n * {@code false}.\n *\n * @param zkClient connection to ZooKeeper.\n * @param path to the node to remove.\n * @return whether the delete succeeded or failed.\n * @throws IOException on unrecoverable ZooKeeper error.\n */'public static boolean atomicRecursiveDelete( final CuratorFramework zkClient, final String path ) throws IOException { try { buildAtomicRecursiveDelete(zkClient, zkClient.inTransaction(), path).commit(); return true; } catch (NoNodeException nne) { LOG.debug("NoNodeException while attempting an atomic recursive delete: {}.", nne.getMessage()); // Node was deleted out from under us; we still have to try again because if this is // thrown any parents of the deleted node possibly still exist. } catch (NotEmptyException nee) { LOG.debug("NotEmptyException while attempting an atomic recursive delete: {}.", nee.getMessage()); // Someone else created a node in the tree between the time we built the transaction and // committed it. } catch (Exception e) { wrapAndRethrow(e); } return false; }
@Test public void testAtomicRecursiveDelete() throws Exception { final String path = "/foo/bar/baz/faz/fooz"; mZKClient.create().creatingParentsIfNeeded().forPath(path); ZooKeeperUtils.atomicRecursiveDelete(mZKClient, "/foo"); Assert.assertNull(mZKClient.checkExists().forPath("/foo")); }
["('/**\\\\n * Try to recursively delete a directory in ZooKeeper. If another thread modifies the directory\\\\n * or any children of the directory, the recursive delete will fail, and this method will return\\\\n * {@code false}.\\\\n *\\\\n * @param zkClient connection to ZooKeeper.\\\\n * @param path to the node to remove.\\\\n * @return whether the delete succeeded or failed.\\\\n * @throws IOException on unrecoverable ZooKeeper error.\\\\n */', '')", "('', '// Node was deleted out from under us; we still have to try again because if this is\\n')", "('', '// thrown any parents of the deleted node possibly still exist.\\n')", "('', '// Someone else created a node in the tree between the time we built the transaction and\\n')", "('', '// committed it.\\n')"]
b'/**\n * Try to recursively delete a directory in ZooKeeper. If another thread modifies the directory\n * or any children of the directory, the recursive delete will fail, and this method will return\n * {@code false}.\n *\n * @param zkClient connection to ZooKeeper.\n * @param path to the node to remove.\n * @return whether the delete succeeded or failed.\n * @throws IOException on unrecoverable ZooKeeper error.\n */'public static boolean atomicRecursiveDelete( final CuratorFramework zkClient, final String path ) throws IOException { try { buildAtomicRecursiveDelete(zkClient, zkClient.inTransaction(), path).commit(); return true; } catch (NoNodeException nne) { LOG.debug("NoNodeException while attempting an atomic recursive delete: {}.", nne.getMessage()); // Node was deleted out from under us; we still have to try again because if this is // thrown any parents of the deleted node possibly still exist. } catch (NotEmptyException nee) { LOG.debug("NotEmptyException while attempting an atomic recursive delete: {}.", nee.getMessage()); // Someone else created a node in the tree between the time we built the transaction and // committed it. } catch (Exception e) { wrapAndRethrow(e); } return false; }
@Test public void testAtomicRecursiveDeleteWithPersistentENode() throws Exception { final String path = "/foo/bar/baz/faz/fooz"; PersistentEphemeralNode node = new PersistentEphemeralNode(mZKClient, Mode.EPHEMERAL, path, new byte[0]); try { node.start(); node.waitForInitialCreate(5, TimeUnit.SECONDS); Assert.assertTrue(ZooKeeperUtils.atomicRecursiveDelete(mZKClient, "/foo")); Thread.sleep(1000); // Give ephemeral node time to recreate itself Assert.assertNotNull(mZKClient.checkExists().forPath("/foo")); } finally { node.close(); } }
["('/**\\\\n * Build a transaction to atomically delete a directory tree. Package private for testing.\\\\n *\\\\n * @param zkClient connection to ZooKeeper.\\\\n * @param tx recursive transaction being built up.\\\\n * @param path current directory to delete.\\\\n * @return a transaction to delete the directory tree.\\\\n * @throws Exception on unrecoverable ZooKeeper error.\\\\n */', '')"]
b'/**\n * Build a transaction to atomically delete a directory tree. Package private for testing.\n *\n * @param zkClient connection to ZooKeeper.\n * @param tx recursive transaction being built up.\n * @param path current directory to delete.\n * @return a transaction to delete the directory tree.\n * @throws Exception on unrecoverable ZooKeeper error.\n */'static CuratorTransactionFinal buildAtomicRecursiveDelete( final CuratorFramework zkClient, final CuratorTransaction tx, final String path ) throws Exception { final List<String> children = zkClient.getChildren().forPath(path); for (String child : children) { buildAtomicRecursiveDelete(zkClient, tx, path + "/" + child); } return tx.delete().forPath(path).and(); }
@Test public void testAtomicRecusiveDeleteWithConcurrentNodeAddition() throws Exception { final String path = "/foo/bar/baz/faz/fooz"; mZKClient.create().creatingParentsIfNeeded().forPath(path); CuratorTransactionFinal tx = ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), "/foo"); mZKClient.create().forPath("/foo/new-child"); try { tx.commit(); } catch (NotEmptyException nee) { // expected } Assert.assertNotNull(mZKClient.checkExists().forPath("/foo")); }
["('/**\\\\n * Build a transaction to atomically delete a directory tree. Package private for testing.\\\\n *\\\\n * @param zkClient connection to ZooKeeper.\\\\n * @param tx recursive transaction being built up.\\\\n * @param path current directory to delete.\\\\n * @return a transaction to delete the directory tree.\\\\n * @throws Exception on unrecoverable ZooKeeper error.\\\\n */', '')"]
b'/**\n * Build a transaction to atomically delete a directory tree. Package private for testing.\n *\n * @param zkClient connection to ZooKeeper.\n * @param tx recursive transaction being built up.\n * @param path current directory to delete.\n * @return a transaction to delete the directory tree.\n * @throws Exception on unrecoverable ZooKeeper error.\n */'static CuratorTransactionFinal buildAtomicRecursiveDelete( final CuratorFramework zkClient, final CuratorTransaction tx, final String path ) throws Exception { final List<String> children = zkClient.getChildren().forPath(path); for (String child : children) { buildAtomicRecursiveDelete(zkClient, tx, path + "/" + child); } return tx.delete().forPath(path).and(); }
@Test public void testAtomicRecusiveDeleteWithConcurrentNodeDeletion() throws Exception { final String path = "/foo/bar/baz/faz/fooz"; mZKClient.create().creatingParentsIfNeeded().forPath(path); CuratorTransactionFinal tx = ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), "/foo"); mZKClient.delete().forPath(path); try { tx.commit(); // should throw } catch (NoNodeException nne) { // expected } Assert.assertNotNull(mZKClient.checkExists().forPath("/foo")); }
['(\'/**\\\\n * Create a new ZooKeeper client for the provided ensemble. The returned client is already\\\\n * started, but the caller is responsible for closing it. The returned client *may* share an\\\\n * underlying connection, therefore this method is not suitable if closing the client must\\\\n * deterministically close outstanding session-based ZooKeeper items such as ephemeral nodes\\\\n * or watchers.\\\\n *\\\\n * @param zkEnsemble of the ZooKeeper ensemble to connect to. May not be null. May contain a\\\\n * namespace in suffix form, e.g. {@code "host1:port1,host2:port2/my/namespace"}.\\\\n * @return a ZooKeeper client using the new connection.\\\\n */\', \'\')']
b'/**\n * Create a new ZooKeeper client for the provided ensemble. The returned client is already\n * started, but the caller is responsible for closing it. The returned client *may* share an\n * underlying connection, therefore this method is not suitable if closing the client must\n * deterministically close outstanding session-based ZooKeeper items such as ephemeral nodes\n * or watchers.\n *\n * @param zkEnsemble of the ZooKeeper ensemble to connect to. May not be null. May contain a\n * namespace in suffix form, e.g. {@code "host1:port1,host2:port2/my/namespace"}.\n * @return a ZooKeeper client using the new connection.\n */'public static CuratorFramework getZooKeeperClient(final String zkEnsemble) { String address = zkEnsemble; String namespace = null; int index = zkEnsemble.indexOf('/'); if (index != -1) { address = zkEnsemble.substring(0, index); namespace = zkEnsemble.substring(index + 1); } return CachedCuratorFramework.create(ZK_CLIENT_CACHE, address, namespace); }
@Test public void testZooKeeperConnectionsAreCached() throws Exception { final CuratorFramework other = ZooKeeperUtils.getZooKeeperClient(getZKAddress()); try { Assert.assertTrue(mZKClient.getZookeeperClient() == other.getZookeeperClient()); } finally { other.close(); } }
['(\'/**\\\\n * Create a new ZooKeeper client for the provided ensemble. The returned client is already\\\\n * started, but the caller is responsible for closing it. The returned client *may* share an\\\\n * underlying connection, therefore this method is not suitable if closing the client must\\\\n * deterministically close outstanding session-based ZooKeeper items such as ephemeral nodes\\\\n * or watchers.\\\\n *\\\\n * @param zkEnsemble of the ZooKeeper ensemble to connect to. May not be null. May contain a\\\\n * namespace in suffix form, e.g. {@code "host1:port1,host2:port2/my/namespace"}.\\\\n * @return a ZooKeeper client using the new connection.\\\\n */\', \'\')']
b'/**\n * Create a new ZooKeeper client for the provided ensemble. The returned client is already\n * started, but the caller is responsible for closing it. The returned client *may* share an\n * underlying connection, therefore this method is not suitable if closing the client must\n * deterministically close outstanding session-based ZooKeeper items such as ephemeral nodes\n * or watchers.\n *\n * @param zkEnsemble of the ZooKeeper ensemble to connect to. May not be null. May contain a\n * namespace in suffix form, e.g. {@code "host1:port1,host2:port2/my/namespace"}.\n * @return a ZooKeeper client using the new connection.\n */'public static CuratorFramework getZooKeeperClient(final String zkEnsemble) { String address = zkEnsemble; String namespace = null; int index = zkEnsemble.indexOf('/'); if (index != -1) { address = zkEnsemble.substring(0, index); namespace = zkEnsemble.substring(index + 1); } return CachedCuratorFramework.create(ZK_CLIENT_CACHE, address, namespace); }
@Test public void testFakeURIsAreNamespaced() throws Exception { final String namespace = "testFakeURIsAreNamespaced"; final KijiURI uri = KijiURI.newBuilder("kiji://.fake." + namespace).build(); final CuratorFramework framework = ZooKeeperUtils.getZooKeeperClient(uri); try { Assert.assertEquals(namespace, framework.getNamespace()); } finally { framework.close(); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraUriDoubleApersand() { final String uriString = "kiji-cassandra://zkhost:1234/sally@cinnamon@chost:5678"; try { final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build(); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals(String.format( "Invalid Kiji URI: '%s' : Cannot have more than one '@' in URI authority", uriString), kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testNormalizedColumns() { KijiURI uri = KijiURI.newBuilder("kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/").build(); KijiURI reversedColumnURI = KijiURI.newBuilder("kiji-hbase://(zkhost2,zkhost1):1234/instance/table/col/").build(); assertEquals(uri.toString(), reversedColumnURI.toString()); assertEquals(uri.getColumns(), reversedColumnURI.getColumns()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraUriTooManyColons() { final String uriString = "kiji-cassandra://zkhost:1234/sally:cinnamon:foo@chost:5678"; try { final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build(); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals(String.format( "Invalid Kiji URI: '%s' : Cannot have more than one ':' in URI user info", uriString), kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraUriWithUsername() { final String uriString = "kiji-cassandra://zkhost:1234/sallycinnamon@chost:5678"; try { final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build(); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals(String.format( "Invalid Kiji URI: '%s' : Cassandra Kiji URIs do not support a username without a " + "password.", uriString), kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testNoAuthority() { try { CassandraKijiURI.newBuilder("kiji-cassandra:///"); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals("Invalid Kiji URI: 'kiji-cassandra:///' : ZooKeeper ensemble missing.", kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testBrokenCassandraPort() { try { CassandraKijiURI.newBuilder("kiji-cassandra://zkhost/chost:port/default").build(); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals( "Invalid Kiji URI: 'kiji-cassandra://zkhost/chost:port/default' " + ": Can not parse port 'port'.", kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testMultipleHostsNoParen() { try { CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost1,zkhost2:1234/chost:5678/instance/table/col"); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals( "Invalid Kiji URI: 'kiji-cassandra://zkhost1,zkhost2:1234/chost:5678/instance/table/col'" + " : Multiple ZooKeeper hosts must be parenthesized.", kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testMultipleHostsMultiplePorts() { try { CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost1:1234,zkhost2:2345/chost:5678/instance/table/col"); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals( "Invalid Kiji URI: 'kiji-cassandra://zkhost1:1234,zkhost2:2345/chost:5678/" + "instance/table/col' : Invalid ZooKeeper ensemble cluster identifier.", kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testExtraPath() { try { CassandraKijiURI.newBuilder( "kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/extra"); fail("An exception should have been thrown."); } catch (KijiURIException kurie) { assertEquals( "Invalid Kiji URI: 'kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/" + "instance/table/col/extra' : Too many path segments.", kurie.getMessage()); } }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testToString() { String uri = "kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/"; assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString()); uri = "kiji-cassandra://zkhost1:1234/chost:5678/instance/table/col/"; assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString()); uri = "kiji-cassandra://zkhost:1234/chost:5678/instance/table/col1,col2/"; assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString()); uri = "kiji-cassandra://zkhost:1234/chost:5678/.unset/table/col/"; assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testNormalizedQuorum() { CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/").build(); CassandraKijiURI reversedQuorumUri = CassandraKijiURI.newBuilder( "kiji-cassandra://(zkhost2,zkhost1):1234/chost:5678/instance/table/col/").build(); assertEquals(uri.toString(), reversedQuorumUri.toString()); assertEquals(uri.getZookeeperQuorum(), reversedQuorumUri.getZookeeperQuorum()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testNormalizedColumns() { CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/").build(); CassandraKijiURI reversedColumnURI = CassandraKijiURI.newBuilder( "kiji-cassandra://(zkhost2,zkhost1):1234/chost:5678/instance/table/col/").build(); assertEquals(uri.toString(), reversedColumnURI.toString()); assertEquals(uri.getColumns(), reversedColumnURI.getColumns()); }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testKijiURIBuilderDefault() { KijiURI uri = KijiURI.newBuilder().build(); assertTrue(!uri.getZookeeperQuorum().isEmpty()); // Test cannot be more specific. // Test cannot validate the value of uri.getZookeeperClientPort(). assertEquals(KConstants.DEFAULT_INSTANCE_NAME, uri.getInstance()); assertEquals(null, uri.getTable()); assertTrue(uri.getColumns().isEmpty()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testOrderedCassandraNodes() { String revString = "kiji-cassandra://zkhost:1234/(chost2,chost1):5678/instance/table/col/"; String ordString = "kiji-cassandra://zkhost:1234/(chost1,chost2):5678/instance/table/col/"; CassandraKijiURI revUri = CassandraKijiURI.newBuilder(revString).build(); // "toString" should ignore the user-defined ordering. assertEquals(ordString, revUri.toString()); // "toOrderedString" should maintain the user-defined ordering. }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraKijiURIBuilderDefault() { CassandraKijiURI uri = CassandraKijiURI.newBuilder().build(); assertTrue(!uri.getZookeeperQuorum().isEmpty()); // Test cannot be more specific. // Test cannot validate the value of uri.getZookeeperClientPort(). assertEquals(KConstants.DEFAULT_INSTANCE_NAME, uri.getInstance()); assertEquals(null, uri.getTable()); assertTrue(uri.getColumns().isEmpty()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraKijiURIBuilderFromInstance() { final CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost:1234/chost:5678/.unset/table").build(); CassandraKijiURI built = CassandraKijiURI.newBuilder(uri).build(); assertEquals(uri, built); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testCassandraKijiURIBuilderWithInstance() { final CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost:1234/chost:5678/instance1/table").build(); assertEquals("instance1", uri.getInstance()); final CassandraKijiURI modified = CassandraKijiURI.newBuilder(uri).withInstanceName("instance2").build(); assertEquals("instance2", modified.getInstance()); assertEquals("instance1", uri.getInstance()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testSetColumn() { CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost/chost:5678/instance/table/").build(); assertTrue(uri.getColumns().isEmpty()); uri = CassandraKijiURI.newBuilder(uri).withColumnNames(Arrays.asList("testcol1", "testcol2")) .build(); assertEquals(2, uri.getColumns().size()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testSetZookeeperQuorum() { final CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost/chost:5678/instance/table/col").build(); final CassandraKijiURI modified = CassandraKijiURI.newBuilder(uri) .withZookeeperQuorum(new String[] {"zkhost1", "zkhost2"}).build(); assertEquals(2, modified.getZookeeperQuorum().size()); assertEquals("zkhost1", modified.getZookeeperQuorum().get(0)); assertEquals("zkhost2", modified.getZookeeperQuorum().get(1)); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testTrailingUnset() { final CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost/chost:5678/.unset/table/.unset").build(); CassandraKijiURI result = CassandraKijiURI.newBuilder(uri).withTableName(".unset").build(); assertEquals("kiji-cassandra://zkhost:2181/chost:5678/", result.toString()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testEscapedMapColumnQualifier() { final CassandraKijiURI uri = CassandraKijiURI.newBuilder( "kiji-cassandra://zkhost/chost:5678/instance/table/map:one%20two").build(); assertEquals("map:one two", uri.getColumns().get(0).getName()); }
['(\'/**\\\\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 */\', \'\')']
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 CassandraKijiURIBuilder newBuilder() { return new CassandraKijiURIBuilder(); }
@Test public void testConstructedUriIsEscaped() { // SCHEMA-6. Column qualifier must be URL-encoded in CassandraKijiURI. final CassandraKijiURI uri = CassandraKijiURI.newBuilder("kiji-cassandra://zkhost/chost:5678/instance/table/") .addColumnName(new KijiColumnName("map:one two")).build(); assertEquals( "kiji-cassandra://zkhost:2181/chost:5678/instance/table/map:one%20two/", uri.toString()); }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test public void testGetFullyQualifiedColumn() throws Exception { for (KijiColumnName column : ImmutableList.of(PRIMITIVE_STRING, STRING_MAP_1)) { for (int pageSize : ImmutableList.of(0, 1, 2, 10)) { { // Single version | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .add(column.getFamily(), column.getQualifier())) .build(); testViewGet(request, Iterables.limit(ROW_DATA.get(column).entrySet(), 1)); } { // Single version | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .add(column.getFamily(), column.getQualifier())) .withTimeRange(4, 6) .build(); testViewGet( request, Iterables.limit(ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet(), 1)); } { // Multiple versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column.getFamily(), column.getQualifier())) .build(); testViewGet( request, ROW_DATA.get(column).entrySet()); } { // Multiple versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column.getFamily(), column.getQualifier())) .withTimeRange(4, 6) .build(); testViewGet( request, ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet()); } } } }
["('/** {@inheritDoc} */', '')", "('', '// In the case that we have enough information to generate a prefix, we will\\n')", '(\'\', "// construct a PrefixFilter that is AND\'ed with the RowFilter. This way,\\n")', "('', '// when the scan passes the end of the prefix, it can end the filtering\\n')", "('', '// process quickly.\\n')", "('', '// Define a regular expression that effectively creates a mask for the row\\n')", "('', '// key based on the key format and the components passed in. Prefix hashes\\n')", "('', '// are skipped over, and null components match any value.\\n')", "('', '// ISO-8859-1 is used so that numerals map to valid characters\\n')", "('', '// see http://stackoverflow.com/a/1387184\\n')", "('', '// Use the embedded flag (?s) to turn on single-line mode; this makes the\\n')", '(\'\', "// \'.\' match on line terminators. The RegexStringComparator uses the DOTALL\\n")', "('', '// flag during construction, but it does not use that flag upon\\n')", "('', '// deserialization. This bug has been fixed in HBASE-5667, part of the 0.95\\n')", "('', '// release.\\n')", "('', '// ^ matches the beginning of the string\\n')", "('', '// If all of the components included in the hash have been specified,\\n')", "('', '// then match on the value of the hash\\n')", "('', '// Write the hashed bytes to the prefix buffer\\n')", '(\'\', "// match any character exactly \'hash size\' number of times\\n")', "('', '// Only add to the prefix buffer until we hit a null component. We do this\\n')", "('', '// here, because the prefix is going to expect to have 0x00 component\\n')", "('', '// terminators, which we put in during this loop but not in the loop above.\\n')", "('', '// null integers can be excluded entirely if there are just nulls at\\n')", "('', '// the end of the EntityId, otherwise, match the correct number of\\n')", "('', '// bytes\\n')", "('', '// match each byte in the integer using a regex hex sequence\\n')", "('', '// null longs can be excluded entirely if there are just nulls at\\n')", "('', '// the end of the EntityId, otherwise, match the correct number of\\n')", "('', '// bytes\\n')", "('', '// match each byte in the long using a regex hex sequence\\n')", "('', '// match any non-zero character at least once, followed by a zero\\n')", "('', '// delimiter, or match nothing at all in case the component was at\\n')", "('', '// the end of the EntityId and skipped entirely\\n')", "('', '// FormattedEntityId converts a string component to UTF-8 bytes to\\n')", "('', '// create the HBase key. RegexStringComparator will convert the\\n')", "('', '// value it sees (ie, the HBase key) to a string using ISO-8859-1.\\n')", "('', '// Therefore, we need to write ISO-8859-1 characters to our regex so\\n')", "('', '// that the comparison happens correctly.\\n')", "('', '// $ matches the end of the string\\n')"]
b'/** {@inheritDoc} */'@Override public Filter toHBaseFilter(Context context) throws IOException { // In the case that we have enough information to generate a prefix, we will // construct a PrefixFilter that is AND'ed with the RowFilter. This way, // when the scan passes the end of the prefix, it can end the filtering // process quickly. boolean addPrefixFilter = false; ByteArrayOutputStream prefixBytes = new ByteArrayOutputStream(); // Define a regular expression that effectively creates a mask for the row // key based on the key format and the components passed in. Prefix hashes // are skipped over, and null components match any value. // ISO-8859-1 is used so that numerals map to valid characters // see http://stackoverflow.com/a/1387184 // Use the embedded flag (?s) to turn on single-line mode; this makes the // '.' match on line terminators. The RegexStringComparator uses the DOTALL // flag during construction, but it does not use that flag upon // deserialization. This bug has been fixed in HBASE-5667, part of the 0.95 // release. StringBuilder regex = new StringBuilder("(?s)^"); // ^ matches the beginning of the string if (null != mRowKeyFormat.getSalt()) { if (mRowKeyFormat.getSalt().getHashSize() > 0) { // If all of the components included in the hash have been specified, // then match on the value of the hash Object[] prefixComponents = getNonNullPrefixComponents(mComponents, mRowKeyFormat.getRangeScanStartIndex()); if (prefixComponents.length == mRowKeyFormat.getRangeScanStartIndex()) { ByteArrayOutputStream tohash = new ByteArrayOutputStream(); for (Object component : prefixComponents) { byte[] componentBytes = toBytes(component); tohash.write(componentBytes, 0, componentBytes.length); } byte[] hashed = Arrays.copyOfRange(Hasher.hash(tohash.toByteArray()), 0, mRowKeyFormat.getSalt().getHashSize()); for (byte hashedByte : hashed) { regex.append(String.format("\\x%02x", hashedByte & 0xFF)); } addPrefixFilter = true; // Write the hashed bytes to the prefix buffer prefixBytes.write(hashed, 0, hashed.length); } else { // match any character exactly 'hash size' number of times regex.append(".{").append(mRowKeyFormat.getSalt().getHashSize()).append("}"); } } } // Only add to the prefix buffer until we hit a null component. We do this // here, because the prefix is going to expect to have 0x00 component // terminators, which we put in during this loop but not in the loop above. boolean hitNullComponent = false; for (int i = 0; i < mComponents.length; i++) { final Object component = mComponents[i]; switch (mRowKeyFormat.getComponents().get(i).getType()) { case INTEGER: if (null == component) { // null integers can be excluded entirely if there are just nulls at // the end of the EntityId, otherwise, match the correct number of // bytes regex.append("(.{").append(Bytes.SIZEOF_INT).append("})?"); hitNullComponent = true; } else { byte[] tempBytes = toBytes((Integer) component); // match each byte in the integer using a regex hex sequence for (byte tempByte : tempBytes) { regex.append(String.format("\\x%02x", tempByte & 0xFF)); } if (!hitNullComponent) { prefixBytes.write(tempBytes, 0, tempBytes.length); } } break; case LONG: if (null == component) { // null longs can be excluded entirely if there are just nulls at // the end of the EntityId, otherwise, match the correct number of // bytes regex.append("(.{").append(Bytes.SIZEOF_LONG).append("})?"); hitNullComponent = true; } else { byte[] tempBytes = toBytes((Long) component); // match each byte in the long using a regex hex sequence for (byte tempByte : tempBytes) { regex.append(String.format("\\x%02x", tempByte & 0xFF)); } if (!hitNullComponent) { prefixBytes.write(tempBytes, 0, tempBytes.length); } } break; case STRING: if (null == component) { // match any non-zero character at least once, followed by a zero // delimiter, or match nothing at all in case the component was at // the end of the EntityId and skipped entirely regex.append("([^\\x00]+\\x00)?"); hitNullComponent = true; } else { // FormattedEntityId converts a string component to UTF-8 bytes to // create the HBase key. RegexStringComparator will convert the // value it sees (ie, the HBase key) to a string using ISO-8859-1. // Therefore, we need to write ISO-8859-1 characters to our regex so // that the comparison happens correctly. byte[] utfBytes = toBytes((String) component); String isoString = new String(utfBytes, Charsets.ISO_8859_1); regex.append(isoString).append("\\x00"); if (!hitNullComponent) { prefixBytes.write(utfBytes, 0, utfBytes.length); prefixBytes.write((byte) 0); } } break; default: throw new IllegalStateException("Unknown component type: " + mRowKeyFormat.getComponents().get(i).getType()); } } regex.append("$"); // $ matches the end of the string final RowFilter regexRowFilter = SchemaPlatformBridge.get().createRowFilterFromRegex(CompareOp.EQUAL, regex.toString()); if (addPrefixFilter) { return new FilterList(new PrefixFilter(prefixBytes.toByteArray()), regexRowFilter); } return regexRowFilter; }
@Test public void testPrefixFilterHaltsFiltering() throws Exception { RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG, LONG); EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat); FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100, null, 9000L); Filter hbaseFilter = filter.toHBaseFilter(null); EntityId passingEntityId = factory.getEntityId(100, 100L, 9000L); byte[] passingHbaseKey = passingEntityId.getHBaseRowKey(); doInclusionAssert(rowKeyFormat, filter, passingEntityId, hbaseFilter, passingHbaseKey, INCLUDE); boolean filterAllRemaining = hbaseFilter.filterAllRemaining(); String message = createFailureMessage(rowKeyFormat, filter, passingEntityId, hbaseFilter, passingHbaseKey, filterAllRemaining); assertEquals(message, false, filterAllRemaining); EntityId failingEntityId = factory.getEntityId(101, 100L, 9000L); byte[] failingHbaseKey = failingEntityId.getHBaseRowKey(); doInclusionAssert(rowKeyFormat, filter, failingEntityId, hbaseFilter, failingHbaseKey, EXCLUDE); filterAllRemaining = hbaseFilter.filterAllRemaining(); message = createFailureMessage(rowKeyFormat, filter, failingEntityId, hbaseFilter, failingHbaseKey, filterAllRemaining); assertEquals(message, true, filterAllRemaining); }
['(\'/**\\\\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 */\', \'\')']
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() { return new HBaseKijiURIBuilder(); }
@Test public void testKijiURIBuilderFromInstance() { final KijiURI uri = KijiURI.newBuilder("kiji-hbase://zkhost:1234/.unset/table").build(); KijiURI built = KijiURI.newBuilder(uri).build(); assertEquals(uri, built); }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test public void testGetMultipleFullyQualifiedColumns() throws Exception { final KijiColumnName column1 = PRIMITIVE_STRING; final KijiColumnName column2 = STRING_MAP_1; for (int pageSize : ImmutableList.of(0, 1, 2, 10)) { { // Single version | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .add(column1.getFamily(), column1.getQualifier()) .add(column2.getFamily(), column2.getQualifier())) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).entrySet(), 1); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Single version | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .add(column1.getFamily(), column1.getQualifier()) .add(column2.getFamily(), column2.getQualifier())) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Multiple versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column1.getFamily(), column1.getQualifier()) .add(column2.getFamily(), column2.getQualifier())) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet(); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Multiple versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column1.getFamily(), column1.getQualifier()) .add(column2.getFamily(), column2.getQualifier())) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Mixed versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column1.getFamily(), column1.getQualifier())) .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(1) .add(column2.getFamily(), column2.getQualifier())) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Mixed versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(1) .add(column1.getFamily(), column1.getQualifier())) .addColumns( ColumnsDef.create() .withPageSize(pageSize) .withMaxVersions(100) .add(column2.getFamily(), column2.getQualifier())) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet(); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } } }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test public void testGetFamilyColumn() throws Exception { final Map<String, ? extends List<KijiColumnName>> families = ImmutableMap.of( PRIMITIVE_FAMILY, ImmutableList.of(PRIMITIVE_DOUBLE, PRIMITIVE_STRING), STRING_MAP_FAMILY, ImmutableList.of(STRING_MAP_1, STRING_MAP_2)); for (Entry<String, ? extends List<KijiColumnName>> family : families.entrySet()) { for (int pageSize : ImmutableList.of(0, 1, 2, 10)) { final KijiColumnName familyColumn = KijiColumnName.create(family.getKey(), null); final KijiColumnName column1 = family.getValue().get(0); final KijiColumnName column2 = family.getValue().get(1); { // Single version | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).entrySet(), 1); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Single version | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn)) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Multiple versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef .create() .withPageSize(pageSize) .withMaxVersions(100) .add(familyColumn)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet(); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } { // Multiple versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef .create() .withPageSize(pageSize) .withMaxVersions(100) .add(familyColumn)) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(); testViewGet(request, Iterables.concat(column1Entries, column2Entries)); } } } }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test public void testGetMultipleFamilyColumns() throws Exception { final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null); final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null); final KijiColumnName column1 = PRIMITIVE_DOUBLE; final KijiColumnName column2 = PRIMITIVE_STRING; final KijiColumnName column3 = STRING_MAP_1; final KijiColumnName column4 = STRING_MAP_2; for (int pageSize : ImmutableList.of(0, 1, 2, 10)) { { // Single version | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns(ColumnsDef.create().add(familyColumn1)) .addColumns(ColumnsDef.create().add(familyColumn2)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column3Entries = Iterables.limit(ROW_DATA.get(column3).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column4Entries = Iterables.limit(ROW_DATA.get(column4).entrySet(), 1); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } { // Single version | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn1)) .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn2)) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column3Entries = Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column4Entries = Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } { // Multiple versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1)) .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet(); final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).entrySet(); final Iterable<? extends Entry<Long, ?>> column4Entries = ROW_DATA.get(column4).entrySet(); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } { // Multiple versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1)) .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2)) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column4Entries = ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } { // Mixed versions | no timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(2).add(familyColumn1)) .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = Iterables.limit(ROW_DATA.get(column1).entrySet(), 2); final Iterable<? extends Entry<Long, ?>> column2Entries = Iterables.limit(ROW_DATA.get(column2).entrySet(), 2); final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).entrySet(); final Iterable<? extends Entry<Long, ?>> column4Entries = ROW_DATA.get(column4).entrySet(); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } { // Multiple versions | timerange final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1)) .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(1).add(familyColumn2)) .withTimeRange(4, 6) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(); final Iterable<? extends Entry<Long, ?>> column3Entries = Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1); final Iterable<? extends Entry<Long, ?>> column4Entries = Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1); testViewGet( request, Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries)); } } }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test public void testNarrowView() throws Exception { final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null); final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null); final KijiColumnName column1 = PRIMITIVE_DOUBLE; final KijiColumnName column2 = PRIMITIVE_STRING; final KijiColumnName column3 = STRING_MAP_1; final KijiColumnName column4 = STRING_MAP_2; for (int pageSize : ImmutableList.of(0)) { final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1)) .addColumns( ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(column3)) .addColumns(ColumnsDef.create().withPageSize(pageSize).add(column4)) .withTimeRange(2, 10) .build(); final KijiResult<Object> view = mReader.getResult(mTable.getEntityId(ROW), request); try { testViewGet(view.narrowView(PRIMITIVE_LONG), ImmutableList.<Entry<Long, ?>>of()); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).subMap(10L, false, 2L, true).entrySet(); testViewGet(view.narrowView(column1), column1Entries); final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).subMap(10L, false, 2L, true).entrySet(); testViewGet(view.narrowView(column2), column2Entries); testViewGet(view.narrowView(familyColumn1), Iterables.concat(column1Entries, column2Entries)); final Iterable<? extends Entry<Long, ?>> column3Entries = ROW_DATA.get(column3).subMap(10L, false, 2L, true).entrySet(); testViewGet(view.narrowView(column3), column3Entries); final Iterable<? extends Entry<Long, ?>> column4Entries = Iterables.limit(ROW_DATA.get(column4).subMap(10L, false, 2L, true).entrySet(), 1); testViewGet(view.narrowView(column4), column4Entries); testViewGet(view.narrowView(familyColumn2), Iterables.concat(column3Entries, column4Entries)); } finally { view.close(); } } }
["('/**\\\\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 */', '')"]
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( final EntityId entityId, final KijiDataRequest dataRequest, final CassandraKijiTable table, final KijiTableLayout layout, final CassandraColumnNameTranslator columnTranslator, final CellDecoderProvider decoderProvider ) throws IOException { final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder(); final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder(); unpagedRequestBuilder.withTimeRange( dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp()); for (final Column columnRequest : dataRequest.getColumns()) { if (columnRequest.getFilter() != null) { throw new UnsupportedOperationException( String.format("Cassandra Kiji does not support filters on column requests: %s.", columnRequest)); } if (columnRequest.isPagingEnabled()) { pagedRequestBuilder.newColumnsDef(columnRequest); } else { unpagedRequestBuilder.newColumnsDef(columnRequest); } } final CellDecoderProvider requestDecoderProvider = decoderProvider.getDecoderProviderForRequest(dataRequest); final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build(); final KijiDataRequest pagedRequest = pagedRequestBuilder.build(); if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) { return new EmptyKijiResult<T>(entityId, dataRequest); } final MaterializedKijiResult<T> materializedKijiResult; if (!unpagedRequest.isEmpty()) { materializedKijiResult = createMaterialized( table.getURI(), entityId, unpagedRequest, layout, columnTranslator, requestDecoderProvider, table.getAdmin()); } else { materializedKijiResult = null; } final CassandraPagedKijiResult<T> pagedKijiResult; if (!pagedRequest.isEmpty()) { pagedKijiResult = new CassandraPagedKijiResult<T>( entityId, pagedRequest, table, layout, columnTranslator, requestDecoderProvider); } else { pagedKijiResult = null; } if (unpagedRequest.isEmpty()) { return pagedKijiResult; } else if (pagedRequest.isEmpty()) { return materializedKijiResult; } else { return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult); } }
@Test(expected = UnsupportedOperationException.class) public void testGetWithFilters() throws Exception { final KijiColumnName column2 = STRING_MAP_1; final KijiDataRequest request = KijiDataRequest .builder() .addColumns( ColumnsDef.create() .withFilter( new KijiColumnRangeFilter( STRING_MAP_1.getQualifier(), true, STRING_MAP_2.getQualifier(), false)) .withMaxVersions(10) .add(column2.getFamily(), null)) .build(); final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column2).entrySet(); testViewGet(request, column1Entries); }