{"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyDirectBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n\r\n final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);\r\n buf.put(bytes).rewind();\r\n assertEquals(8, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(bytes, ptr.getByteArray(0, bytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(0, buf.position()),\r\n () -> assertEquals(8, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copySlicedDirectBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n final byte[] slicedBytes = new byte[] {2, 3, 4, 5};\r\n\r\n final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);\r\n buf.put(bytes).rewind();\r\n\r\n // slice 4 bytes\r\n buf.position(2).limit(6);\r\n assertEquals(4, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(slicedBytes, ptr.getByteArray(0, slicedBytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(2, buf.position()),\r\n () -> assertEquals(6, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyNullFloatArrayToNativeMemory() {\r\n final float[] values = null; // test case\r\n final int offset = 0;\r\n final int length = 0;\r\n\r\n assertThrows(\r\n IllegalArgumentException.class,\r\n () -> BufferUtils.copyToNativeMemory(values, offset, length));\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyNegativeOffsetFloatArrayToNativeMemory() {\r\n final float[] values = new float[] {0f, 1f, 2f, 3f};\r\n final int offset = -1; // test case\r\n final int length = values.length;\r\n\r\n assertThrows(\r\n ArrayIndexOutOfBoundsException.class,\r\n () -> BufferUtils.copyToNativeMemory(values, offset, length));\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyNegativeLengthFloatArrayToNativeMemory() {\r\n final float[] values = new float[] {0f, 1f, 2f, 3f};\r\n final int offset = 0;\r\n final int length = -1; // test case\r\n\r\n assertThrows(\r\n IllegalArgumentException.class,\r\n () -> BufferUtils.copyToNativeMemory(values, offset, length));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Throws {@link MenohException} if the errorCode of a native Menoh function is\\\\\\\\n * non-zero. This method must be called right after the invocation because it uses \\\\\\\\n * menoh_get_last_error_message.\\\\\\\\n *\\\\\\\\n * @param errorCode an error code returned from the Menoh function\\\\\\\\n */', '')\", \"('', '// ErrorCode.valueOf() throws MenohException if the error code is undefined\\\\n')\"]", "focal_method": "b'/**\\n * Throws {@link MenohException} if the errorCode of a native Menoh function is\\n * non-zero. This method must be called right after the invocation because it uses \\n * menoh_get_last_error_message.\\n *\\n * @param errorCode an error code returned from the Menoh function\\n */'static void checkError(int errorCode) throws MenohException {\r\n if (errorCode != ErrorCode.SUCCESS.getId()) {\r\n final String errorMessage = MenohNative.INSTANCE.menoh_get_last_error_message();\r\n\r\n ErrorCode ec;\r\n try {\r\n ec = ErrorCode.valueOf(errorCode);\r\n } catch (MenohException e) {\r\n // ErrorCode.valueOf() throws MenohException if the error code is undefined\r\n throw new MenohException(ErrorCode.UNDEFINED, String.format(\"%s (%d)\", errorMessage, errorCode), e);\r\n }\r\n\r\n final String errorCodeName = ec.toString().toLowerCase(Locale.ENGLISH);\r\n throw new MenohException(ec, String.format(\"%s (%s)\", errorMessage, errorCodeName));\r\n }\r\n }", "test_case": "@Test\r\n public void checkErrorSuccess() {\r\n checkError(ErrorCode.SUCCESS.getId());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Loads an ONNX model from the specified file.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Loads an ONNX model from the specified file.\\n */'public static ModelData fromOnnxFile(String onnxModelPath) throws MenohException {\r\n final PointerByReference handle = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_model_data_from_onnx(onnxModelPath, handle));\r\n\r\n return new ModelData(handle.getValue());\r\n }", "test_case": "@Test\r\n public void makeFromNonExistentOnnxFile() {\r\n MenohException e = assertThrows(\r\n MenohException.class, () -> ModelData.fromOnnxFile(\"__NON_EXISTENT_FILENAME__\"));\r\n assertAll(\"non-existent onnx file\",\r\n () -> assertEquals(ErrorCode.INVALID_FILENAME, e.getErrorCode()),\r\n () -> assertEquals(\r\n \"menoh invalid filename error: __NON_EXISTENT_FILENAME__ (invalid_filename)\",\r\n e.getMessage())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n * Loads an ONNX model from the specified file.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Loads an ONNX model from the specified file.\\n */'public static ModelData fromOnnxFile(String onnxModelPath) throws MenohException {\r\n final PointerByReference handle = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_model_data_from_onnx(onnxModelPath, handle));\r\n\r\n return new ModelData(handle.getValue());\r\n }", "test_case": "@Test\r\n public void makeFromInvalidOnnxFile() throws Exception {\r\n final String path = getResourceFilePath(\"models/invalid_format.onnx\");\r\n\r\n MenohException e = assertThrows(MenohException.class, () -> ModelData.fromOnnxFile(path));\r\n assertAll(\"invalid onnx file\",\r\n () -> assertEquals(ErrorCode.ONNX_PARSE_ERROR, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\"menoh onnx parse error: %s (onnx_parse_error)\", path),\r\n e.getMessage())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n * Loads an ONNX model from the specified file.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Loads an ONNX model from the specified file.\\n */'public static ModelData fromOnnxFile(String onnxModelPath) throws MenohException {\r\n final PointerByReference handle = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_model_data_from_onnx(onnxModelPath, handle));\r\n\r\n return new ModelData(handle.getValue());\r\n }", "test_case": "@Test\r\n public void makeFromUnsupportedOnnxOpsetVersionFile() throws Exception {\r\n // Note: This file is a copy of and_op.onnx which is edited the last byte to 127 (0x7e)\r\n final String path = getResourceFilePath(\"models/unsupported_onnx_opset_version.onnx\");\r\n\r\n MenohException e = assertThrows(MenohException.class, () -> ModelData.fromOnnxFile(path));\r\n assertAll(\"invalid onnx file\",\r\n () -> assertEquals(ErrorCode.UNSUPPORTED_ONNX_OPSET_VERSION, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\r\n \"menoh unsupported onnx opset version error: %s has \"\r\n + \"onnx opset version %d > %d (unsupported_onnx_opset_version)\",\r\n path, 127, 7),\r\n e.getMessage())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link ModelBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link ModelBuilder}.\\n */'public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref));\r\n\r\n return new ModelBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void buildModelIfBackendNotFound() throws Exception {\r\n final String path = getResourceFilePath(\"models/and_op.onnx\");\r\n final int batchSize = 4;\r\n final int inputDim = 2;\r\n final String backendName = \"__non_existent_backend__\"; // test case\r\n final String backendConfig = \"\";\r\n\r\n try (\r\n ModelData modelData = ModelData.fromOnnxFile(path);\r\n VariableProfileTableBuilder vptBuilder = VariableProfileTable.builder()\r\n .addInputProfile(\"input\", DType.FLOAT, new int[] {batchSize, inputDim})\r\n .addOutputProfile(\"output\", DType.FLOAT);\r\n VariableProfileTable vpt = vptBuilder.build(modelData);\r\n ModelBuilder modelBuilder = Model.builder(vpt)\r\n ) {\r\n modelBuilder.attachExternalBuffer(\"input\", new float[] {0f, 0f, 0f, 1f, 1f, 0f, 1f, 1f});\r\n\r\n MenohException e = assertThrows(\r\n MenohException.class, () -> modelBuilder.build(modelData, backendName, backendConfig));\r\n assertAll(\"backendName is invalid\",\r\n () -> assertEquals(ErrorCode.INVALID_BACKEND_NAME, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\"menoh invalid backend name error: %s (invalid_backend_name)\", backendName),\r\n e.getMessage())\r\n );\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void addValidInputProfile() {\r\n try (VariableProfileTableBuilder builder = VariableProfileTable.builder()) {\r\n builder.addInputProfile(\"foo\", DType.FLOAT, new int[] {1, 1});\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void addValidInputProfileWithInvalidDims() {\r\n try (VariableProfileTableBuilder builder = VariableProfileTable.builder()) {\r\n MenohException e = assertThrows(MenohException.class,\r\n // test case: dims.length == 1\r\n () -> builder.addInputProfile(\"foo\", DType.FLOAT, new int[] {1, 1, 1, 1, 1}));\r\n assertAll(\"invalid dim size\",\r\n () -> assertEquals(ErrorCode.UNDEFINED, e.getErrorCode()),\r\n () -> assertTrue(e.getMessage().startsWith(\"foo has an invalid dims size: 5\"),\r\n String.format(\"%s doesn't start with \\\"foo has an invalid dims size: 5\\\"\",\r\n e.getMessage())));\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyEmptyDirectBufferToNativeMemory() {\r\n final ByteBuffer buf = ByteBuffer.allocateDirect(0);\r\n assertEquals(0, buf.remaining());\r\n\r\n assertThrows(\r\n IllegalArgumentException.class,\r\n () -> BufferUtils.copyToNativeMemory(buf));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void addValidOutputProfile() {\r\n try (VariableProfileTableBuilder builder = VariableProfileTable.builder()) {\r\n builder.addOutputProfile(\"foo\", DType.FLOAT);\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void buildVariableProfileTableIfInputProfileNameNotFound() throws Exception {\r\n final String path = getResourceFilePath(\"models/and_op.onnx\");\r\n final int batchSize = 1;\r\n final int inputDim = 2;\r\n final String inputProfileName = \"__non_existent_variable__\"; // test case\r\n final String inputVariableNameInModel = \"input\";\r\n final String outputProfileName = \"output\";\r\n\r\n try (\r\n ModelData modelData = ModelData.fromOnnxFile(path);\r\n VariableProfileTableBuilder vptBuilder = VariableProfileTable.builder()\r\n .addInputProfile(inputProfileName, DType.FLOAT, new int[] {batchSize, inputDim})\r\n .addOutputProfile(outputProfileName, DType.FLOAT)\r\n ) {\r\n MenohException e = assertThrows(MenohException.class, () -> vptBuilder.build(modelData));\r\n assertAll(\"input profile name not found\",\r\n () -> assertEquals(ErrorCode.VARIABLE_NOT_FOUND, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\"menoh variable not found error: %s (variable_not_found)\",\r\n inputVariableNameInModel), // not `inputProfileName`\r\n e.getMessage())\r\n );\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void buildVariableProfileTableIfInputProfileDimsMismatched() throws Exception {\r\n final String path = getResourceFilePath(\"models/and_op.onnx\");\r\n final int batchSize = 1;\r\n final int inputDim = 3; // test case\r\n final String inputProfileName = \"input\";\r\n final String outputProfileName = \"output\";\r\n\r\n try (\r\n ModelData modelData = ModelData.fromOnnxFile(path);\r\n VariableProfileTableBuilder vptBuilder = VariableProfileTable.builder()\r\n .addInputProfile(inputProfileName, DType.FLOAT, new int[] {batchSize, inputDim})\r\n .addOutputProfile(outputProfileName, DType.FLOAT)\r\n ) {\r\n MenohException e = assertThrows(MenohException.class, () -> vptBuilder.build(modelData));\r\n assertAll(\"mismatched input dims\",\r\n () -> assertEquals(ErrorCode.DIMENSION_MISMATCH, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\r\n \"menoh dimension mismatch error: Gemm issuing \\\"%s\\\": input[1] and weight[1] \"\r\n + \"actual value: %d valid value: %d (dimension_mismatch)\",\r\n \"140211424823896\", // the name of output[0] in Gemm layer\r\n 3, 2),\r\n e.getMessage())\r\n );\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a {@link VariableProfileTableBuilder}.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a {@link VariableProfileTableBuilder}.\\n */'public static VariableProfileTableBuilder builder() throws MenohException {\r\n final PointerByReference ref = new PointerByReference();\r\n checkError(MenohNative.INSTANCE.menoh_make_variable_profile_table_builder(ref));\r\n\r\n return new VariableProfileTableBuilder(ref.getValue());\r\n }", "test_case": "@Test\r\n public void buildVariableProfileTableIfOutputProfileNameNotFound() throws Exception {\r\n final String path = getResourceFilePath(\"models/and_op.onnx\");\r\n final int batchSize = 1;\r\n final int inputDim = 2;\r\n final String inputProfileName = \"input\";\r\n final String outputProfileName = \"__non_existent_variable__\"; // test case\r\n\r\n try (\r\n ModelData modelData = ModelData.fromOnnxFile(path);\r\n VariableProfileTableBuilder vptBuilder = VariableProfileTable.builder()\r\n .addInputProfile(inputProfileName, DType.FLOAT, new int[] {batchSize, inputDim})\r\n .addOutputProfile(outputProfileName, DType.FLOAT)\r\n ) {\r\n MenohException e = assertThrows(MenohException.class, () -> vptBuilder.build(modelData));\r\n assertAll(\"output profile name not found\",\r\n () -> assertEquals(ErrorCode.VARIABLE_NOT_FOUND, e.getErrorCode()),\r\n () -> assertEquals(\r\n String.format(\"menoh variable not found error: %s (variable_not_found)\", outputProfileName),\r\n e.getMessage())\r\n );\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyArrayBackedBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n\r\n final ByteBuffer buf = ByteBuffer.wrap(bytes);\r\n assertEquals(8, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(bytes, ptr.getByteArray(0, bytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(0, buf.position()),\r\n () -> assertEquals(8, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copySlicedArrayBackedBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n final byte[] slicedBytes = new byte[] {2, 3, 4, 5};\r\n\r\n final ByteBuffer buf = ByteBuffer.wrap(bytes, 1, 6).slice();\r\n assertAll(\"non-zero array offset\",\r\n () -> assertEquals(1, buf.arrayOffset()),\r\n () -> assertEquals(0, buf.position()),\r\n () -> assertEquals(6, buf.limit())\r\n );\r\n\r\n // slice 4 bytes\r\n buf.position(1).limit(5);\r\n assertEquals(4, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(slicedBytes, ptr.getByteArray(0, slicedBytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(1, buf.position()),\r\n () -> assertEquals(5, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyReadOnlyBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n\r\n final ByteBuffer buf = ByteBuffer.wrap(bytes).asReadOnlyBuffer();\r\n assertEquals(8, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(bytes, ptr.getByteArray(0, bytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(0, buf.position()),\r\n () -> assertEquals(8, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copySlicedReadOnlyBufferToNativeMemory() {\r\n final byte[] bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7};\r\n final byte[] slicedBytes = new byte[] {2, 3, 4, 5};\r\n\r\n final ByteBuffer buf = ByteBuffer.wrap(bytes).asReadOnlyBuffer();\r\n\r\n // slice 4 bytes\r\n buf.position(2).limit(6);\r\n assertEquals(4, buf.remaining());\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(buf);\r\n assertNotNull(ptr);\r\n assertArrayEquals(slicedBytes, ptr.getByteArray(0, slicedBytes.length));\r\n assertAll(\"buffer's state\",\r\n () -> assertEquals(2, buf.position()),\r\n () -> assertEquals(6, buf.limit())\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyFloatArrayToNativeMemory() {\r\n final float[] values = new float[] {0f, 1f, 2f, 3f};\r\n final ByteBuffer valuesBuf = ByteBuffer.allocate(values.length * 4).order(ByteOrder.nativeOrder());\r\n valuesBuf.asFloatBuffer().put(values);\r\n final int offset = 0;\r\n final int length = values.length;\r\n\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(values, offset, length);\r\n assertNotNull(ptr);\r\n assertAll(\"copied values in native memory\",\r\n () -> assertArrayEquals(values, ptr.getFloatArray(0, length)),\r\n // check the byte order\r\n () -> assertArrayEquals(valuesBuf.array(), ptr.getByteArray(0, length * 4))\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copySlicedFloatArrayToNativeMemory() {\r\n final float[] values = new float[] {0f, 1f, 2f, 3f};\r\n final float[] slicedValues = new float[] {1f, 2f};\r\n final ByteBuffer slicedValuesBuf = ByteBuffer.allocate(slicedValues.length * 4).order(ByteOrder.nativeOrder());\r\n slicedValuesBuf.asFloatBuffer().put(slicedValues);\r\n final int offset = 1;\r\n final int length = slicedValues.length;\r\n\r\n // slice 2 elements (8 bytes)\r\n final Pointer ptr = BufferUtils.copyToNativeMemory(values, offset, length);\r\n assertNotNull(ptr);\r\n assertAll(\"copied values in native memory\",\r\n () -> assertArrayEquals(slicedValues, ptr.getFloatArray(0, length)),\r\n // check the byte order\r\n () -> assertArrayEquals(slicedValuesBuf.array(), ptr.getByteArray(0, length * 4))\r\n );\r\n }"} {"description": "[\"('/**\\\\\\\\n *

Copies a buffer to a native memory.

\\\\\\\\n *\\\\\\\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\\\\\\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\\\\\\\n * from position() to (limit() - 1) without changing its position.

\\\\\\\\n *\\\\\\\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\\\\\\\n * the native byte order of your platform may differ from JVM.

\\\\\\\\n *\\\\\\\\n * @param buffer the non-empty byte buffer from which to copy\\\\\\\\n *\\\\\\\\n * @return the pointer to the allocated native memory\\\\\\\\n * @throws IllegalArgumentException if buffer is null or empty\\\\\\\\n */', '')\", \"('', '// return a pointer to the direct buffer without copying\\\\n')\", \"('', '// it is array-backed and not read-only\\\\n')\", \"('', '// use duplicated buffer to avoid changing `position`\\\\n')\"]", "focal_method": "b'/**\\n *

Copies a buffer to a native memory.

\\n *\\n *

If the buffer is direct, it will be attached to the model directly without copying.\\n * Otherwise, it copies the content of the buffer to a newly allocated memory in the native heap ranging\\n * from position() to (limit() - 1) without changing its position.

\\n *\\n *

Note that the order() of the buffer should be {@link ByteOrder#nativeOrder()} because\\n * the native byte order of your platform may differ from JVM.

\\n *\\n * @param buffer the non-empty byte buffer from which to copy\\n *\\n * @return the pointer to the allocated native memory\\n * @throws IllegalArgumentException if buffer is null or empty\\n */'static Pointer copyToNativeMemory(final ByteBuffer buffer) {\r\n if (buffer == null || buffer.remaining() <= 0) {\r\n throw new IllegalArgumentException(\"buffer must not be null or empty\");\r\n }\r\n\r\n final int length = buffer.remaining();\r\n\r\n if (buffer.isDirect()) {\r\n final int offset = buffer.position();\r\n\r\n // return a pointer to the direct buffer without copying\r\n return Native.getDirectBufferPointer(buffer).share(offset, length);\r\n } else {\r\n final Memory mem = new Memory(length);\r\n\r\n int index;\r\n byte[] bytes;\r\n if (buffer.hasArray()) { // it is array-backed and not read-only\r\n index = buffer.arrayOffset() + buffer.position();\r\n bytes = buffer.array();\r\n } else {\r\n index = 0;\r\n // use duplicated buffer to avoid changing `position`\r\n bytes = new byte[length];\r\n buffer.duplicate().get(bytes);\r\n }\r\n mem.write(0, bytes, index, length);\r\n\r\n return mem.share(0, length);\r\n }\r\n }", "test_case": "@Test\r\n public void copyEmptyFloatArrayToNativeMemory() {\r\n final float[] values = new float[] {}; // test case\r\n final int offset = 0;\r\n final int length = values.length;\r\n\r\n assertThrows(\r\n IllegalArgumentException.class,\r\n () -> BufferUtils.copyToNativeMemory(values, offset, length));\r\n }"} {"description": "[\"('', '// Append meta data.\\\\n')\"]", "focal_method": "Uri getAuthorizationUri(URL baseOAuthUrl, String clientId) {\r\n try {\r\n final Uri.Builder builder = Uri.parse(new URL(baseOAuthUrl, ApiConstants.AUTHORIZE).toURI().toString())\r\n .buildUpon()\r\n .appendQueryParameter(ARG_RESPONSE_TYPE, \"code\")\r\n .appendQueryParameter(ARG_CLIENT_ID, clientId)\r\n .appendQueryParameter(ARG_REDIRECT_URI, redirectUri.toString())\r\n .appendQueryParameter(ARG_SCOPE, scope);\r\n\r\n if (showSignUp) {\r\n builder.appendQueryParameter(ARG_LAYOUT, LAYOUT_SIGNUP);\r\n }\r\n\r\n appendIfNotNull(builder, ARG_ACCOUNT, account);\r\n appendIfNotNull(builder, ARG_ACCOUNT_CURRENCY, accountCurrency);\r\n appendIfNotNull(builder, ARG_REFERRAL, referralId);\r\n\r\n // Append meta data.\r\n appendIfNotNull(builder, META_NAME, metaName);\r\n appendIfNotNull(builder, META_SEND_LIMIT_AMOUNT, sendLimitAmount);\r\n appendIfNotNull(builder, META_SEND_LIMIT_CURRENCY, sendLimitCurrency);\r\n appendIfNotNull(builder, META_SEND_LIMIT_PERIOD, sendLimitPeriod);\r\n\r\n return builder.build();\r\n } catch (URISyntaxException | MalformedURLException e) {\r\n throw new IllegalArgumentException(e);\r\n }\r\n }", "test_case": "@Test\r\n public void shouldBuildCorrectUri() throws Exception {\r\n // Given\r\n final String clientId = \"clientId\";\r\n final Uri redirectUri = Uri.parse(\"coinbase://some-app\");\r\n final String scope = \"user:read\";\r\n final String baseOauthUrl = \"https://www.coinbase.com/authorize\";\r\n final URL url = new URL(baseOauthUrl);\r\n final Uri wantedUri = Uri.parse(baseOauthUrl)\r\n .buildUpon()\r\n .path(ApiConstants.AUTHORIZE)\r\n // Add from request\r\n .appendQueryParameter(AuthorizationRequest.ARG_RESPONSE_TYPE, \"code\")\r\n .appendQueryParameter(AuthorizationRequest.ARG_CLIENT_ID, clientId)\r\n .appendQueryParameter(AuthorizationRequest.ARG_REDIRECT_URI, redirectUri.toString())\r\n .appendQueryParameter(AuthorizationRequest.ARG_SCOPE, scope)\r\n .build();\r\n\r\n // When\r\n final Uri authorizationUri = new AuthorizationRequest(redirectUri, scope)\r\n .getAuthorizationUri(url, clientId);\r\n\r\n // Then\r\n assertThat(authorizationUri).isEqualTo(wantedUri);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates an instance of {@link PaginationParams} to get next page items.\\\\\\\\n *

\\\\\\\\n * Keeps limit and order from original {@link PaginationParams}.\\\\\\\\n *\\\\\\\\n * @param pagination current page pagination params.\\\\\\\\n * @return {@link PaginationParams} to get next items page.\\\\\\\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getNextUri()}\\\\\\\\n * returns null, which means, the end of the items\\\\\\\\n * list is already reached.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates an instance of {@link PaginationParams} to get next page items.\\n *

\\n * Keeps limit and order from original {@link PaginationParams}.\\n *\\n * @param pagination current page pagination params.\\n * @return {@link PaginationParams} to get next items page.\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getNextUri()}\\n * returns null, which means, the end of the items\\n * list is already reached.\\n */'@SuppressWarnings(\"checkstyle:MultipleStringLiterals\")\r\n public static PaginationParams nextPage(@NonNull PagedResponse.Pagination pagination) throws IllegalArgumentException {\r\n if (pagination.getNextUri() == null) {\r\n return null;\r\n }\r\n try {\r\n String startingAfterId = getQueryParameter(pagination.getNextUri(), STARTING_AFTER_KEY);\r\n return copyLimitAndOrder(fromStartingAfter(startingAfterId), pagination);\r\n } catch (Exception e) {\r\n throw new IllegalArgumentException(\"Malformed url\", e);\r\n }\r\n }", "test_case": "@Test\r\n public void noNextPageNull_ParamsNull() {\r\n // Given\r\n PagedResponse.Pagination pagination = new PagedResponse.Pagination();\r\n\r\n // When\r\n PaginationParams paginationParams = PaginationParams.nextPage(pagination);\r\n\r\n // Then\r\n assertThat(paginationParams).isNull();\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates an instance of {@link PaginationParams} to get previous page items.\\\\\\\\n *

\\\\\\\\n * Keeps limit and order from original {@link PaginationParams}.\\\\\\\\n *\\\\\\\\n * @param pagination current page pagination params.\\\\\\\\n * @return {@link PaginationParams} to get previous items page.\\\\\\\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getPreviousUri()}\\\\\\\\n * returns null, which means, the beginning of the\\\\\\\\n * items list is already reached.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates an instance of {@link PaginationParams} to get previous page items.\\n *

\\n * Keeps limit and order from original {@link PaginationParams}.\\n *\\n * @param pagination current page pagination params.\\n * @return {@link PaginationParams} to get previous items page.\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getPreviousUri()}\\n * returns null, which means, the beginning of the\\n * items list is already reached.\\n */'@SuppressWarnings(\"checkstyle:MultipleStringLiterals\")\r\n public static PaginationParams previousPage(@NonNull PagedResponse.Pagination pagination) throws IllegalArgumentException {\r\n if (pagination.getPreviousUri() == null) {\r\n return null;\r\n }\r\n try {\r\n String endingBeforeId = getQueryParameter(pagination.getPreviousUri(), ENDING_BEFORE_KEY);\r\n return copyLimitAndOrder(fromEndingBefore(endingBeforeId), pagination);\r\n } catch (Exception e) {\r\n throw new IllegalArgumentException(\"Malformed url\", e);\r\n }\r\n }", "test_case": "@Test\r\n public void noPreviousPageNull_ParamsNull() {\r\n // Given\r\n PagedResponse.Pagination pagination = new PagedResponse.Pagination();\r\n\r\n // When\r\n PaginationParams paginationParams = PaginationParams.previousPage(pagination);\r\n\r\n // Then\r\n assertThat(paginationParams).isNull();\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates an instance of {@link PaginationParams} to get next page items.\\\\\\\\n *

\\\\\\\\n * Keeps limit and order from original {@link PaginationParams}.\\\\\\\\n *\\\\\\\\n * @param pagination current page pagination params.\\\\\\\\n * @return {@link PaginationParams} to get next items page.\\\\\\\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getNextUri()}\\\\\\\\n * returns null, which means, the end of the items\\\\\\\\n * list is already reached.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates an instance of {@link PaginationParams} to get next page items.\\n *

\\n * Keeps limit and order from original {@link PaginationParams}.\\n *\\n * @param pagination current page pagination params.\\n * @return {@link PaginationParams} to get next items page.\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getNextUri()}\\n * returns null, which means, the end of the items\\n * list is already reached.\\n */'@SuppressWarnings(\"checkstyle:MultipleStringLiterals\")\r\n public static PaginationParams nextPage(@NonNull PagedResponse.Pagination pagination) throws IllegalArgumentException {\r\n if (pagination.getNextUri() == null) {\r\n return null;\r\n }\r\n try {\r\n String startingAfterId = getQueryParameter(pagination.getNextUri(), STARTING_AFTER_KEY);\r\n return copyLimitAndOrder(fromStartingAfter(startingAfterId), pagination);\r\n } catch (Exception e) {\r\n throw new IllegalArgumentException(\"Malformed url\", e);\r\n }\r\n }", "test_case": "@Test(expected = IllegalArgumentException.class)\r\n public void noNextPage_nextIdNotProvided_ExceptionThrown() {\r\n // Given\r\n PagedResponse.Pagination pagination = new PagedResponse.Pagination();\r\n pagination.setNextUri(\"/path\");\r\n\r\n // When\r\n PaginationParams.nextPage(pagination);\r\n\r\n // Then\r\n Assertions.fail(\"Should throw an \" + IllegalArgumentException.class);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates an instance of {@link PaginationParams} to get previous page items.\\\\\\\\n *

\\\\\\\\n * Keeps limit and order from original {@link PaginationParams}.\\\\\\\\n *\\\\\\\\n * @param pagination current page pagination params.\\\\\\\\n * @return {@link PaginationParams} to get previous items page.\\\\\\\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getPreviousUri()}\\\\\\\\n * returns null, which means, the beginning of the\\\\\\\\n * items list is already reached.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates an instance of {@link PaginationParams} to get previous page items.\\n *

\\n * Keeps limit and order from original {@link PaginationParams}.\\n *\\n * @param pagination current page pagination params.\\n * @return {@link PaginationParams} to get previous items page.\\n * @throws IllegalArgumentException when {@link PagedResponse.Pagination#getPreviousUri()}\\n * returns null, which means, the beginning of the\\n * items list is already reached.\\n */'@SuppressWarnings(\"checkstyle:MultipleStringLiterals\")\r\n public static PaginationParams previousPage(@NonNull PagedResponse.Pagination pagination) throws IllegalArgumentException {\r\n if (pagination.getPreviousUri() == null) {\r\n return null;\r\n }\r\n try {\r\n String endingBeforeId = getQueryParameter(pagination.getPreviousUri(), ENDING_BEFORE_KEY);\r\n return copyLimitAndOrder(fromEndingBefore(endingBeforeId), pagination);\r\n } catch (Exception e) {\r\n throw new IllegalArgumentException(\"Malformed url\", e);\r\n }\r\n }", "test_case": "@Test(expected = IllegalArgumentException.class)\r\n public void noPreviousPage_previousIdNotProvided_ExceptionThrown() {\r\n // Given\r\n PagedResponse.Pagination pagination = new PagedResponse.Pagination();\r\n pagination.setPreviousUri(\"/path\");\r\n\r\n // When\r\n PaginationParams.previousPage(pagination);\r\n\r\n // Then\r\n Assertions.fail(\"Should throw an \" + IllegalArgumentException.class);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testUsingDeploymentForService() throws Exception {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setImpl(\"foo.Impl\");\r\n deployment.setConfig(\"-\");\r\n deployment.setServiceType(\"foo.Interface\");\r\n deployment.setName(\"The Great and wonderful Oz\");\r\n deployment.setMultiplicity(10);\r\n ServiceElement serviceElement = ServiceElementFactory.create(deployment, null);\r\n Assert.assertEquals(10, serviceElement.getPlanned());\r\n Assert.assertEquals(SorcerEnv.getActualName(\"The Great and wonderful Oz\"),\r\n serviceElement.getName());\r\n Assert.assertEquals(\"foo.Impl\", serviceElement.getComponentBundle().getClassName());\r\n Assert.assertTrue(serviceElement.getExportBundles().length==1);\r\n Assert.assertEquals(\"foo.Interface\", serviceElement.getExportBundles()[0].getClassName());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void setDeploymentWebsterUrl() throws IOException, ConfigurationException, URISyntaxException, ResolverException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir() + \"/TestIP.groovy\");\r\n deployment.setWebsterUrl(\"http://spongebob:8080\");\r\n ServiceElement serviceElement = ServiceElementFactory.create(deployment, new File(getConfigDir() + \"/TestIP.groovy\"));\r\n Assert.assertTrue(serviceElement.getExportURLs().length > 1);\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getHost(), \"spongebob\");\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getPort(), 8080);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testFixedUsingConfiguration() throws URISyntaxException, ResolverException, ConfigurationException, IOException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir()+\"/fixedConfig.config\");\r\n ServiceElement service = ServiceElementFactory.create(deployment, new File(getConfigDir()+\"/fixedConfig.config\"));\r\n Assert.assertTrue(service.getPlanned()==10);\r\n Assert.assertTrue(service.getProvisionType() == ServiceElement.ProvisionType.FIXED);\r\n Assert.assertTrue(service.getMaxPerMachine()==-1);\r\n }"} {"description": "Get the DataService data directory The @link DataServiceDATADIR system property is first consulted if that property is not setValue the default is either the TMPDIR SystemgetPropertyjavaiotmpdirsorceruserdata is used and the @link DataServiceDATADIR system property is setValue @return The DataService data directory", "focal_method": "b'/**\\n * Get the DataService data directory. The {@link DataService#DATA_DIR} system property is first\\n * consulted, if that property is not setValue, the default is either the TMPDIR\\n * System.getProperty(\"java.io.tmpdir\")/sorcer/user/data is used and the {@link DataService#DATA_DIR}\\n * system property is setValue.\\n *\\n * @return The DataService data directory.\\n */'public static String getDataDir() {\r\n String dataDir = System.getProperty(DATA_DIR);\r\n if(dataDir==null) {\r\n dataDir = getDefaultDataDir();\r\n System.setProperty(DATA_DIR, dataDir);\r\n }\r\n return dataDir;\r\n }", "test_case": "@Test\r\n public void testGetDataDir() {\r\n String tmpDir = System.getenv(\"TMPDIR\")==null?System.getProperty(\"java.io.tmpdir\"):System.getenv(\"TMPDIR\");\r\n String dataDirName = new File(String.format(String.format(\"%s%ssorcer-%s%sdata\",\r\n tmpDir,\r\n File.separator,\r\n System.getProperty(\"user.name\"),\r\n File.separator))).getAbsolutePath();\r\n System.err.println(\"===> \"+dataDirName);\r\n assertTrue(dataDirName.equals(DataService.getDataDir()));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void setDeploymentWebsterOperator() throws IOException, ConfigurationException, URISyntaxException, ResolverException {\r\n NetSignature methodEN = new NetSignature(\"executeFoo\",\r\n ServiceProvider.class,\r\n \"Yogi\");\r\n methodEN.setDeployment(deploy(configuration(getConfigDir() + \"/TestIP.groovy\"),\r\n webster(\"http://spongebob:8080\")));\r\n\r\n ServiceElement serviceElement = ServiceElementFactory.create(methodEN.getDeployment(),\r\n new File(getConfigDir() + \"/TestIP.groovy\"));\r\n Assert.assertTrue(serviceElement.getExportURLs().length>1);\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getHost(), \"spongebob\");\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getPort(), 8080);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void setDeploymentWebsterFromConfig() throws IOException, ConfigurationException, URISyntaxException, ResolverException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir() + \"/testWebster.config\");\r\n ServiceElement serviceElement = ServiceElementFactory.create(deployment, new File(getConfigDir() + \"/testWebster.config\"));\r\n Assert.assertTrue(serviceElement.getExportURLs().length > 1);\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getHost(), \"127.0.0.1\");\r\n Assert.assertEquals(serviceElement.getExportURLs()[0].getPort(), 8080);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testIPAddresses() throws Exception {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setIps(\"10.0.1.9\", \"canebay.local\");\r\n deployment.setExcludeIps(\"10.0.1.7\", \"stingray.foo.local.net\");\r\n deployment.setConfig(\"-\");\r\n ServiceElement serviceElement = ServiceElementFactory.create(deployment, null);\r\n SystemRequirements systemRequirements = serviceElement.getServiceLevelAgreements().getSystemRequirements();\r\n Assert.assertEquals(4, systemRequirements.getSystemComponents().length);\r\n\r\n verify(get(\"10.0.1.9\", false, systemRequirements.getSystemComponents()), false);\r\n verify(get(\"canebay.local\", true, systemRequirements.getSystemComponents()), false);\r\n verify(get(\"10.0.1.7\", false, systemRequirements.getSystemComponents()), true);\r\n verify(get(\"stingray.foo.local.net\", true, systemRequirements.getSystemComponents()), true);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testIPAddressestisingConfiguration() throws IOException, ConfigurationException, URISyntaxException, ResolverException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir() + \"/testIP.config\");\r\n verifyServiceElement(ServiceElementFactory.create(deployment, new File(getConfigDir() + \"/testIP.config\")));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testIPAddressesUsingGroovyConfiguration() throws IOException, ConfigurationException, URISyntaxException, ResolverException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir()+\"/TestIP.groovy\");\r\n verifyServiceElement(ServiceElementFactory.create(deployment, new File(getConfigDir()+\"/TestIP.groovy\")));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testPlannedUsingGroovyConfiguration() throws URISyntaxException, ResolverException, ConfigurationException, IOException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir()+\"/PlannedConfig.groovy\");\r\n ServiceElement service = ServiceElementFactory.create(deployment, new File(getConfigDir()+\"/PlannedConfig.groovy\"));\r\n Assert.assertTrue(service.getPlanned()==10);\r\n Assert.assertTrue(service.getMaxPerMachine()==1);\r\n Assert.assertTrue(service.getProvisionType() == ServiceElement.ProvisionType.DYNAMIC);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testFixedUsingGroovyConfiguration() throws URISyntaxException, ResolverException, ConfigurationException, IOException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir()+\"/FixedConfig.groovy\");\r\n ServiceElement service = ServiceElementFactory.create(deployment, new File(getConfigDir()+\"/FixedConfig.groovy\"));\r\n Assert.assertTrue(service.getPlanned()==10);\r\n Assert.assertTrue(service.getProvisionType() == ServiceElement.ProvisionType.FIXED);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a {@link ServiceElement}.\\\\\\\\n *\\\\\\\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\\\\\\\n *\\\\\\\\n * @return A {@code ServiceElement}\\\\\\\\n *\\\\\\\\n * @throws ConfigurationException if there are problem reading the configuration\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a {@link ServiceElement}.\\n *\\n * @param signature The {@link ServiceSignature}, must not be {@code null}.\\n *\\n * @return A {@code ServiceElement}\\n *\\n * @throws ConfigurationException if there are problem reading the configuration\\n */'public static ServiceElement create(final ServiceSignature signature, File configFile) throws IOException,\r\n ConfigurationException,\r\n ResolverException,\r\n URISyntaxException {\r\n return create(signature.getDeployment(), configFile);\r\n }", "test_case": "@Test\r\n public void testPlannedUsingConfiguration() throws URISyntaxException, ResolverException, ConfigurationException, IOException {\r\n ServiceDeployment deployment = new ServiceDeployment();\r\n deployment.setConfig(getConfigDir()+\"/plannedConfig.config\");\r\n ServiceElement service = ServiceElementFactory.create(deployment, new File(getConfigDir()+\"/plannedConfig.config\"));\r\n Assert.assertTrue(service.getPlanned()==10);\r\n Assert.assertTrue(service.getMaxPerMachine()==2);\r\n Assert.assertTrue(service.getProvisionType() == ServiceElement.ProvisionType.DYNAMIC);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Compute the set of literals common to all models of the formula.\\\\\\\\n * \\\\\\\\n * @param s\\\\\\\\n * a solver already feeded\\\\\\\\n * @return the set of literals common to all models of the formula contained\\\\\\\\n * in the solver, in dimacs format.\\\\\\\\n * @throws TimeoutException\\\\\\\\n */', '')\", \"('', '// i is in the backbone\\\\n')\", \"('', '// -i is in the backbone\\\\n')\"]", "focal_method": "b'/**\\n * Compute the set of literals common to all models of the formula.\\n * \\n * @param s\\n * a solver already feeded\\n * @return the set of literals common to all models of the formula contained\\n * in the solver, in dimacs format.\\n * @throws TimeoutException\\n */'public static IVecInt backbone(ISolver s) throws TimeoutException {\r\n IVecInt backbone = new VecInt();\r\n int nvars = s.nVars();\r\n for (int i = 1; i <= nvars; i++) {\r\n backbone.push(i);\r\n if (s.isSatisfiable(backbone)) {\r\n backbone.pop().push(-i);\r\n if (s.isSatisfiable(backbone)) {\r\n backbone.pop();\r\n } else {\r\n // i is in the backbone\r\n backbone.pop().push(i);\r\n }\r\n } else {\r\n // -i is in the backbone\r\n backbone.pop().push(-i);\r\n }\r\n }\r\n return backbone;\r\n }", "test_case": "@Test\r\n public void testBugUnitClauses() throws ContradictionException,\r\n TimeoutException {\r\n ISolver solver1 = SolverFactory.newDefault();\r\n ISolver solver2 = SolverFactory.newDefault();\r\n ISolver solver3 = SolverFactory.newDefault();\r\n\r\n int[][] cnf1 = new int[][] { new int[] { 1 }, new int[] { 1, -2 },\r\n new int[] { 1, -3 }, new int[] { -1, 2 } };\r\n // A & (A v -B) & (A v -C) & (-A v B)\r\n // (-A v B) & (A v -B) & (A v -C) & A | using a different order\r\n int[][] cnf2 = new int[][] { new int[] { -1, 2 }, new int[] { 1, -2 },\r\n new int[] { 1, -3 }, new int[] { 1 } };\r\n // (-A v B) & (A v -B) & (A v -C) & A\r\n // (-A v C) & (A v -C) & (A v -B) & A | swap B and C (2 <-> 3)\r\n // (A v -B) & (-A v C) & (A v -C) & A | shift the first 3 clauses to the\r\n // right\r\n int[][] cnf3 = new int[][] { new int[] { 1, -2 }, new int[] { -1, 3 },\r\n new int[] { 1, -3 }, new int[] { 1 } };\r\n\r\n for (int[] is : cnf1) {\r\n solver1.addClause(new VecInt(is));\r\n }\r\n for (int[] is : cnf2) {\r\n solver2.addClause(new VecInt(is));\r\n }\r\n for (int[] is : cnf3) {\r\n solver3.addClause(new VecInt(is));\r\n }\r\n\r\n IVecInt vecInt1 = RemiUtils.backbone(solver1);\r\n assertEquals(vecInt1.size(), 2);\r\n assertTrue(vecInt1.contains(1));\r\n assertTrue(vecInt1.contains(2));\r\n\r\n IVecInt vecInt2 = RemiUtils.backbone(solver2);\r\n assertEquals(vecInt2.size(), 2);\r\n assertTrue(vecInt2.contains(1));\r\n assertTrue(vecInt2.contains(2));\r\n\r\n IVecInt vecInt3 = RemiUtils.backbone(solver3);\r\n assertEquals(vecInt3.size(), 2);\r\n assertTrue(vecInt3.contains(1));\r\n assertTrue(vecInt3.contains(3));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Translate an optimization function into constraints and provides the\\\\\\\\n * binary literals in results. Works only when the value of the objective\\\\\\\\n * function is positive.\\\\\\\\n * \\\\\\\\n * @since 2.2\\\\\\\\n */', '')\", \"('', '// filling the buckets\\\\n')\", \"('', '// creating the adder\\\\n')\"]", "focal_method": "b'/**\\n * Translate an optimization function into constraints and provides the\\n * binary literals in results. Works only when the value of the objective\\n * function is positive.\\n * \\n * @since 2.2\\n */'public void optimisationFunction(IVecInt literals, IVec coefs,\r\n IVecInt result) throws ContradictionException {\r\n IVec buckets = new Vec();\r\n IVecInt bucket;\r\n // filling the buckets\r\n for (int i = 0; i < literals.size(); i++) {\r\n int p = literals.get(i);\r\n BigInteger a = coefs.get(i);\r\n for (int j = 0; j < a.bitLength(); j++) {\r\n bucket = createIfNull(buckets, j);\r\n if (a.testBit(j)) {\r\n bucket.push(p);\r\n }\r\n }\r\n }\r\n // creating the adder\r\n int x, y, z;\r\n int sum, carry;\r\n for (int i = 0; i < buckets.size(); i++) {\r\n bucket = buckets.get(i);\r\n while (bucket.size() >= 3) {\r\n x = bucket.get(0);\r\n y = bucket.get(1);\r\n z = bucket.get(2);\r\n bucket.remove(x);\r\n bucket.remove(y);\r\n bucket.remove(z);\r\n sum = nextFreeVarId(true);\r\n carry = nextFreeVarId(true);\r\n fullAdderSum(sum, x, y, z);\r\n fullAdderCarry(carry, x, y, z);\r\n additionalFullAdderConstraints(carry, sum, x, y, z);\r\n bucket.push(sum);\r\n createIfNull(buckets, i + 1).push(carry);\r\n }\r\n while (bucket.size() == 2) {\r\n x = bucket.get(0);\r\n y = bucket.get(1);\r\n bucket.remove(x);\r\n bucket.remove(y);\r\n sum = nextFreeVarId(true);\r\n carry = nextFreeVarId(true);\r\n halfAdderSum(sum, x, y);\r\n halfAdderCarry(carry, x, y);\r\n bucket.push(sum);\r\n createIfNull(buckets, i + 1).push(carry);\r\n }\r\n assert bucket.size() == 1;\r\n result.push(bucket.last());\r\n bucket.pop();\r\n assert bucket.isEmpty();\r\n }\r\n }", "test_case": "@Test\r\n public void testTwoValues() throws ContradictionException {\r\n IVecInt literals = new VecInt().push(1).push(2);\r\n IVec coefs = new Vec().push(\r\n BigInteger.valueOf(3)).push(BigInteger.valueOf(6));\r\n IVecInt result = new VecInt();\r\n this.gator.optimisationFunction(literals, coefs, result);\r\n System.out.println(result);\r\n assertEquals(4, result.size());\r\n\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen1() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertTrue(gator.isSatisfiable(new VecInt(new int[] { 1, 2, 3 })));\r\n\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen2() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertFalse(gator.isSatisfiable(new VecInt(new int[] { 1, 2, -3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen3() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertTrue(gator.isSatisfiable(new VecInt(new int[] { 1, -2, 3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen() throws ContradictionException, TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertTrue(gator.isSatisfiable(new VecInt(new int[] { 1, -2, -3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen5() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertFalse(gator.isSatisfiable(new VecInt(new int[] { -1, 2, 3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen6() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertTrue(gator.isSatisfiable(new VecInt(new int[] { -1, 2, -3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen7() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertFalse(gator.isSatisfiable(new VecInt(new int[] { -1, -2, 3 })));\r\n }"} {"description": "[\"('/**\\\\\\\\n * translate y <=> (x1 => x2)\\\\\\\\n * \\\\\\\\n * @param y\\\\\\\\n * @param x1\\\\\\\\n * the selector variable\\\\\\\\n * @param x2\\\\\\\\n * @return\\\\\\\\n * @throws ContradictionException\\\\\\\\n * @since 2.3.6\\\\\\\\n */', '')\", \"('', '// y <=> (x1 -> x2)\\\\n')\", \"('', '// y -> (x1 -> x2)\\\\n')\", \"('', '// y <- (x1 -> x2)\\\\n')\", \"('', '// not(x1 -> x2) or y\\\\n')\", \"('', '// x1 and not x2 or y\\\\n')\", \"('', '// (x1 or y) and (not x2 or y)\\\\n')\"]", "focal_method": "b'/**\\n * translate y <=> (x1 => x2)\\n * \\n * @param y\\n * @param x1\\n * the selector variable\\n * @param x2\\n * @return\\n * @throws ContradictionException\\n * @since 2.3.6\\n */'public IConstr[] it(int y, int x1, int x2) throws ContradictionException {\r\n IConstr[] constrs = new IConstr[3];\r\n IVecInt clause = new VecInt(5);\r\n // y <=> (x1 -> x2)\r\n // y -> (x1 -> x2)\r\n clause.push(-y).push(-x1).push(x2);\r\n constrs[0] = processClause(clause);\r\n clause.clear();\r\n // y <- (x1 -> x2)\r\n // not(x1 -> x2) or y\r\n // x1 and not x2 or y\r\n // (x1 or y) and (not x2 or y)\r\n clause.push(x1).push(y);\r\n constrs[1] = processClause(clause);\r\n clause.clear();\r\n clause.push(-x2).push(y);\r\n constrs[2] = processClause(clause);\r\n\r\n return constrs;\r\n }", "test_case": "@Test\r\n public void testSATIfThen8() throws ContradictionException,\r\n TimeoutException {\r\n gator.it(1, 2, 3);\r\n assertFalse(gator.isSatisfiable(new VecInt(new int[] { -1, -2, -3 })));\r\n }"} {"description": "Get the date of the first day of the current year @return date", "focal_method": "b'/**\\n * Get the date of the first day of the current year\\n *\\n * @return date\\n */'public static Date yearStart() {\r\n final GregorianCalendar calendar = new GregorianCalendar(US);\r\n calendar.set(DAY_OF_YEAR, 1);\r\n return calendar.getTime();\r\n }", "test_case": "@Test\r\n public void yearStart() {\r\n Date date = DateUtils.yearStart();\r\n assertNotNull(date);\r\n GregorianCalendar calendar = new GregorianCalendar();\r\n calendar.setTime(date);\r\n assertEquals(1, calendar.get(DAY_OF_YEAR));\r\n }"} {"description": "Get the date of the last day of the current year @return date", "focal_method": "b'/**\\n * Get the date of the last day of the current year\\n *\\n * @return date\\n */'public static Date yearEnd() {\r\n final GregorianCalendar calendar = new GregorianCalendar(US);\r\n calendar.add(YEAR, 1);\r\n calendar.set(DAY_OF_YEAR, 1);\r\n calendar.add(DAY_OF_YEAR, -1);\r\n return calendar.getTime();\r\n }", "test_case": "@Test\r\n public void yearEnd() {\r\n Date date = DateUtils.yearEnd();\r\n assertNotNull(date);\r\n GregorianCalendar calendar = new GregorianCalendar();\r\n calendar.setTime(date);\r\n assertEquals(11, calendar.get(MONTH));\r\n assertEquals(31, calendar.get(DAY_OF_MONTH));\r\n }"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * Returns true if the double is a denormal.\\\\\\\\n\\\\\\\\t */', '')\"]", "focal_method": "b'/**\\n\\t * Returns true if the double is a denormal.\\n\\t */'public static boolean isDenormal(@Unsigned long v) {\r\n\t\treturn (v & EXPONENT_MASK) == 0L;\r\n\t}", "test_case": "@Test\r\n\tpublic void double_IsDenormal() {\r\n\t\t@Unsigned long min_double64 = 0x00000000_00000001L;\r\n\t\tCHECK(Doubles.isDenormal(min_double64));\r\n\t\t@Unsigned long bits = 0x000FFFFF_FFFFFFFFL;\r\n\t\tCHECK(Doubles.isDenormal(bits));\r\n\t\tbits = 0x00100000_00000000L;\r\n\t\tCHECK(!Doubles.isDenormal(bits));\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * We consider denormals not to be special.\\\\\\\\n\\\\\\\\t * Hence only Infinity and NaN are special.\\\\\\\\n\\\\\\\\t */', '')\"]", "focal_method": "b'/**\\n\\t * We consider denormals not to be special.\\n\\t * Hence only Infinity and NaN are special.\\n\\t */'public static boolean isSpecial(@Unsigned long value) {\r\n\t\treturn (value & EXPONENT_MASK) == EXPONENT_MASK;\r\n\t}", "test_case": "@Test\r\n\tpublic void double_IsSpecial() {\r\n\t\tCHECK(Doubles.isSpecial(Double.POSITIVE_INFINITY));\r\n\t\tCHECK(Doubles.isSpecial(-Double.POSITIVE_INFINITY));\r\n\t\tCHECK(Doubles.isSpecial(Double.NaN));\r\n\t\t@Unsigned long bits = 0xFFF12345_00000000L;\r\n\t\tCHECK(Doubles.isSpecial(bits));\r\n\t\t// Denormals are not special:\r\n\t\tCHECK(!Doubles.isSpecial(5e-324));\r\n\t\tCHECK(!Doubles.isSpecial(-5e-324));\r\n\t\t// And some random numbers:\r\n\t\tCHECK(!Doubles.isSpecial(0.0));\r\n\t\tCHECK(!Doubles.isSpecial(-0.0));\r\n\t\tCHECK(!Doubles.isSpecial(1.0));\r\n\t\tCHECK(!Doubles.isSpecial(-1.0));\r\n\t\tCHECK(!Doubles.isSpecial(1000000.0));\r\n\t\tCHECK(!Doubles.isSpecial(-1000000.0));\r\n\t\tCHECK(!Doubles.isSpecial(1e23));\r\n\t\tCHECK(!Doubles.isSpecial(-1e23));\r\n\t\tCHECK(!Doubles.isSpecial(1.7976931348623157e308));\r\n\t\tCHECK(!Doubles.isSpecial(-1.7976931348623157e308));\r\n\t}"} {"description": "t Computes a decimal representation with a fixed number of digits after thet decimal point The last emitted digit is roundedt pt bExamplesbbrt codet toFixed312 1 31brt toFixed31415 3 3142brt toFixed123456789 4 12345679brt toFixed123 5 123000brt toFixed01 4 01000brt toFixed1e30 2 100000000000000001988462483865600brt toFixed01 30 0100000000000000005551115123126brt toFixed01 17 010000000000000001brt codet pt If coderequestedDigitscode equals 0 then the tail of the result depends ont the codeEMITTRAILINGDECIMALPOINTcode and codeEMITTRAILINGZEROAFTERPOINTcodet pt Examples for requestedDigits 0t let codeEMITTRAILINGDECIMALPOINTcode and codeEMITTRAILINGZEROAFTERPOINTcode bebrt tablet trtdfalse and false thentd td 12345 123 tdtrt trtd td 0678 1 tdtrt trtdtrue and false thentd td 12345 123 tdtrt trtd td 0678 1 tdtrt trtdtrue and true thentd td 12345 1230 tdtrt trtd td 0678 10 tdtrt tablet pt t @param requestedDigits the number of digits to the right of the decimal point the last emitted digit is roundedt @param formatOptionst @throws IllegalArgumentException if coderequestedDigits MAXFIXEDDIGITSBEFOREPOINTcode ort if codevalue 10MAXFIXEDDIGITSBEFOREPOINTcodet pt These two conditions imply that the result for nonspecial valuest never contains more thanbrt code1 MAXFIXEDDIGITSBEFOREPOINT 1 t MAXFIXEDDIGITSAFTERPOINTcodebrt characters one additional character for the sign and one for the decimal pointt DOUBLECONVERSIONASSERTMAXFIXEDDIGITSBEFOREPOINT 60 Find a sufficiently precise decimal representation of n", "focal_method": "b'/**\\n\\t * Computes a decimal representation with a fixed number of digits after the\\n\\t * decimal point. The last emitted digit is rounded.\\n\\t *

\\n\\t * Examples:
\\n\\t * \\n\\t * toFixed(3.12, 1) -> \"3.1\"
\\n\\t * toFixed(3.1415, 3) -> \"3.142\"
\\n\\t * toFixed(1234.56789, 4) -> \"1234.5679\"
\\n\\t * toFixed(1.23, 5) -> \"1.23000\"
\\n\\t * toFixed(0.1, 4) -> \"0.1000\"
\\n\\t * toFixed(1e30, 2) -> \"1000000000000000019884624838656.00\"
\\n\\t * toFixed(0.1, 30) -> \"0.100000000000000005551115123126\"
\\n\\t * toFixed(0.1, 17) -> \"0.10000000000000001\"
\\n\\t *
\\n\\t *

\\n\\t * If requestedDigits equals 0, then the tail of the result depends on\\n\\t * the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT.\\n\\t *

\\n\\t * Examples, for requestedDigits == 0,\\n\\t * let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be
\\n\\t * \\n\\t * \\n\\t * \\n\\t * \\n\\t * \\n\\t * \\n\\t * \\n\\t *
false and false: then 123.45 -> 123
0.678 -> 1
true and false: then 123.45 -> 123.
0.678 -> 1.
true and true: then 123.45 -> 123.0
0.678 -> 1.0
\\n\\t *

\\n\\t *\\n\\t * @param requestedDigits the number of digits to the right of the decimal point, the last emitted digit is rounded\\n\\t * @param formatOptions\\n\\t * @throws IllegalArgumentException if requestedDigits > MAX_FIXED_DIGITS_BEFORE_POINT or\\n\\t * if value > 10^MAX_FIXED_DIGITS_BEFORE_POINT\\n\\t *

\\n\\t * These two conditions imply that the result for non-special values\\n\\t * never contains more than
\\n\\t * 1 + MAX_FIXED_DIGITS_BEFORE_POINT + 1 +\\n\\t * MAX_FIXED_DIGITS_AFTER_POINT
\\n\\t * characters (one additional character for the sign, and one for the decimal point).\\n\\t */'public static void toFixed(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {\r\n\t\t// DOUBLE_CONVERSION_ASSERT(MAX_FIXED_DIGITS_BEFORE_POINT == 60);\r\n\r\n\t\tif (Doubles.isSpecial(value)) {\r\n\t\t\thandleSpecialValues(value, formatOptions, resultBuilder);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (requestedDigits > MAX_FIXED_DIGITS_AFTER_POINT) {\r\n\t\t\tthrow new IllegalArgumentException(\"requestedDigits too large. max: \" + MAX_FIXED_DIGITS_BEFORE_POINT +\r\n\t\t\t\t\"(MAX_FIXED_DIGITS_BEFORE_POINT) got: \" + requestedDigits);\r\n\t\t}\r\n\t\tif (value > FIRST_NON_FIXED || value < -FIRST_NON_FIXED) {\r\n\t\t\tthrow new IllegalArgumentException(\"value >= 10^\" + MAX_FIXED_DIGITS_BEFORE_POINT +\r\n\t\t\t\t\"(10^MAX_FIXED_DIGITS_BEFORE_POINT) got: \" + value);\r\n\t\t}\r\n\r\n\t\t// Find a sufficiently precise decimal representation of n.\r\n\t\tDecimalRepBuf decimalRep = new DecimalRepBuf(FIXED_REP_CAPACITY);\r\n\t\tdoubleToAscii(value, DtoaMode.FIXED, requestedDigits, decimalRep);\r\n\r\n\t\tcreateDecimalRepresentation(decimalRep, value, requestedDigits, formatOptions, resultBuilder);\r\n\t}", "test_case": "@Test\r\n\tvoid toFixed() {\r\n\t\t// TODO: conv = DoubleToStringConverter.ecmaScriptConverter();\r\n\r\n\t\ttestFixed(\"3.1\", 3.12, 1);\r\n\t\ttestFixed(\"3.142\", 3.1415, 3);\r\n\t\ttestFixed(\"1234.5679\", 1234.56789, 4);\r\n\t\ttestFixed(\"1.23000\", 1.23, 5);\r\n\t\ttestFixed(\"0.1000\", 0.1, 4);\r\n\t\ttestFixed(\"1000000000000000019884624838656.00\", 1e30, 2);\r\n\t\ttestFixed(\"0.100000000000000005551115123126\", 0.1, 30);\r\n\t\ttestFixed(\"0.10000000000000001\", 0.1, 17);\r\n\r\n\t\t// TODO: conv = newConv(Flags.NO_FLAGS);\r\n\t\ttestFixed(\"123\", 123.45, 0);\r\n\t\ttestFixed(\"1\", 0.678, 0);\r\n\r\n\t\ttestFixed(\"123.\", 123.45, 0, WITH_TRAILING);\r\n\t\ttestFixed(\"1.\", 0.678, 0, WITH_TRAILING);\r\n\r\n\t\t// from string-issues.lua:3\r\n\t\ttestFixed(\"20.00\", 20.0, 2, padding(5, false, false)); // %5.2f\r\n\t\ttestFixed(\" 0.05\", 5.2e-2, 2, padding(5, false, false)); // %5.2f\r\n\t\ttestFixed(\"52.30\", 52.3, 2, padding(5, false, false)); // %5.2f\r\n\r\n\t\t// padding\r\n\t\ttestFixed(\" 1.0\", 1.0, 1, padding(9, false, false));\r\n\t\ttestFixed(\"1.0 \", 1.0, 1, padding(9, false, true));\r\n\t\ttestFixed(\"0000001.0\", 1.0, 1, padding(9, true, false));\r\n\r\n\t\tboolean zeroPad = true;\r\n\t\ttestFixed(\"1\", 1.0, 0, padding(1, zeroPad, false));\r\n\t\ttestFixed(\"0\", 0.1, 0, padding(1, zeroPad, false));\r\n\t\ttestFixed(\"01\", 1.0, 0, padding(2, zeroPad, false));\r\n\t\ttestFixed(\"-1\", -1.0, 0, padding(2, zeroPad, false));\r\n\t\ttestFixed(\"001\", 1.0, 0, padding(3, zeroPad, false));\r\n\t\ttestFixed(\"-01\", -1.0, 0, padding(3, zeroPad, false));\r\n\r\n\t\ttestFixed(\"123\", 123.456, 0, padding(1, zeroPad, false));\r\n\t\ttestFixed(\"0\", 1.23456e-05, 0, padding(1, zeroPad, false));\r\n\r\n\t\ttestFixed(\"100\", 100.0, 0, padding(2, zeroPad, false));\r\n\t\ttestFixed(\"1000\", 1000.0, 0, padding(2, zeroPad, false));\r\n\r\n\t\ttestFixed(\"000100\", 100.0, 0, padding(6, zeroPad, false));\r\n\t\ttestFixed(\"001000\", 1000.0, 0, padding(6, zeroPad, false));\r\n\t\ttestFixed(\"010000\", 10000.0, 0, padding(6, zeroPad, false));\r\n\t\ttestFixed(\"100000\", 100000.0, 0, padding(6, zeroPad, false));\r\n\t\ttestFixed(\"1000000\", 1000000.0, 0, padding(6, zeroPad, false));\r\n\r\n\t\ttestFixed(\"00\", 0.01, 0, padding(2, zeroPad, false));\r\n\r\n\t\ttestFixed(\"0.0\", 0.01, 1, padding(2, false, false));\r\n\r\n\t\ttestFixed(\" 0.010000\", 0.01, 6, padding(20, false, false));\r\n\r\n\t}"} {"description": "t Computes a representation in exponential format with coderequestedDigitscodet after the decimal point The last emitted digit is roundedt pt Examples with bEMITPOSITIVEEXPONENTSIGNb deactivated andt exponentcharacter set to codeecodet pt codet toExponential312 1 31e0brt toExponential50 3 5000e0brt toExponential0001 2 100e3brt toExponential31415 4 31415e0brt toExponential31415 3 3142e0brt toExponential123456789000000 3 1235e14brt toExponential10000000000000000198846248386560 32 t 100000000000000001988462483865600e30brt toExponential1234 0 1e3brt codet t @param requestedDigits number of digits after the decimal pointlast digit roundedt @param formatOptionst @throws IllegalArgumentException if coderequestedDigits MAXEXPONENTIALDIGITScodet DOUBLECONVERSIONASSERTEXPONENTIALREPCAPACITY BASE10MAXIMALLENGTH", "focal_method": "b'/**\\n\\t * Computes a representation in exponential format with requestedDigits\\n\\t * after the decimal point. The last emitted digit is rounded.\\n\\t *

\\n\\t * Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and\\n\\t * exponent_character set to \\'e\\'.\\n\\t *

\\n\\t * \\n\\t * toExponential(3.12, 1) -> \"3.1e0\"
\\n\\t * toExponential(5.0, 3) -> \"5.000e0\"
\\n\\t * toExponential(0.001, 2) -> \"1.00e-3\"
\\n\\t * toExponential(3.1415, 4) -> \"3.1415e0\"
\\n\\t * toExponential(3.1415, 3) -> \"3.142e0\"
\\n\\t * toExponential(123456789000000, 3) -> \"1.235e14\"
\\n\\t * toExponential(1000000000000000019884624838656.0, 32) ->\\n\\t * \"1.00000000000000001988462483865600e30\"
\\n\\t * toExponential(1234, 0) -> \"1e3\"
\\n\\t *
\\n\\t *\\n\\t * @param requestedDigits number of digits after the decimal point(last digit rounded)\\n\\t * @param formatOptions\\n\\t * @throws IllegalArgumentException if requestedDigits > MAX_EXPONENTIAL_DIGITS\\n\\t */'public static void toExponential(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {\r\n\t\tif (Doubles.isSpecial(value)) {\r\n\t\t\thandleSpecialValues(value, formatOptions, resultBuilder);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (requestedDigits < 0) {\r\n\t\t\tthrow new IllegalArgumentException(String.format(\"requestedDigits must be >= 0. got: %d\", requestedDigits));\r\n\t\t}\r\n\r\n\t\tif (requestedDigits > MAX_EXPONENTIAL_DIGITS) {\r\n\t\t\tthrow new IllegalArgumentException(String.format(\"requestedDigits must be less than %d. got: %d\", MAX_EXPONENTIAL_DIGITS, requestedDigits));\r\n\t\t}\r\n\r\n\r\n\t\t// DOUBLE_CONVERSION_ASSERT(EXPONENTIAL_REP_CAPACITY > BASE_10_MAXIMAL_LENGTH);\r\n\t\tDecimalRepBuf decimalRep = new DecimalRepBuf(EXPONENTIAL_REP_CAPACITY);\r\n\r\n\t\tdoubleToAscii(value, DtoaMode.PRECISION, requestedDigits + 1, decimalRep);\r\n\t\tassert decimalRep.length() <= requestedDigits + 1;\r\n\r\n\t\tdecimalRep.zeroExtend(requestedDigits + 1);\r\n\r\n\t\tint exponent = decimalRep.getPointPosition() - 1;\r\n\t\tcreateExponentialRepresentation(decimalRep, value, decimalRep.length(), exponent, formatOptions, resultBuilder);\r\n\t}", "test_case": "@Test\r\n\tvoid toExponential() {\r\n\t\ttestExp(\"3.1e+00\", 3.12, 1);\r\n\t\ttestExp(\"5.000e+00\", 5.0, 3);\r\n\t\ttestExp(\"1.00e-03\", 0.001, 2);\r\n\t\ttestExp(\"3.1415e+00\", 3.1415, 4);\r\n\t\ttestExp(\"3.142e+00\", 3.1415, 3);\r\n\t\ttestExp(\"1.235e+14\", 123456789000000.0, 3);\r\n\t\ttestExp(\"1.00000000000000001988462483865600e+30\", 1000000000000000019884624838656.0, 32);\r\n\t\ttestExp(\"1e+03\", 1234, 0);\r\n\r\n\t\ttestExp(\"0.000000e+00\", 0.0, 6);\r\n\t\ttestExp(\"1.000000e+00\", 1.0, 6);\r\n\r\n\t\ttestExp(\"0.e+00\", 0.0, 0, formatOptTrailingPoint());\r\n\t\ttestExp(\"1.e+00\", 1.0, 0, formatOptTrailingPoint());\r\n\r\n\t\t// padding\r\n\t\ttestExp(\"01e+02\", 100, 0, padding(6, true, false));\r\n\t\ttestExp(\"-1e+02\", -100, 0, padding(6, true, false));\r\n\t\ttestExp(\"01e+03\", 1000, 0, padding(6, true, false));\r\n\t\ttestExp(\"001e+02\", 100, 0, padding(7, true, false));\r\n\r\n\t}"} {"description": "t Computes precision leading digits of the given value and returns themt either in exponential or decimal format depending ont PrecisionPolicymaxLeadingTrailingZeros given to thet constructort pt The last computed digit is roundedt pt Example with PrecisionPolicymaxLeadingZeros 6t pt codet toPrecision00000012345 2 00000012brt toPrecision000000012345 2 12e7brt codet pt Similarily the converter may add up tot PrecisionPolicymaxTrailingZeros in precision mode to avoidt returning an exponential representation A zero added by thet bEMITTRAILINGZEROAFTERPOINTb flag is counted for this limitt pt Examples for PrecisionPolicymaxTrailingZeros 1t pt codet toPrecision2300 2 230brt toPrecision2300 2 230 with EMITTRAILINGDECIMALPOINTbrt toPrecision2300 2 23e2 with EMITTRAILINGZEROAFTERPOINTbrt codet pt Examples for PrecisionPolicymaxTrailingZeros 3 and not EMITTRAILINGZEROAFTERPOINTt pt codet toPrecision1234500 6 123450brt toPrecision1234500 5 123450brt toPrecision1234500 4 123500brt toPrecision1234500 3 123000brt toPrecision1234500 2 12e5brt codet pt t @throws IllegalArgumentException when codeprecision MINPRECISIONDIGITScode ort codeprecision MAXPRECISIONDIGITScodet Find a sufficiently precise decimal representation of n Add one for the terminating null character The exponent if we print the number as xxxeyyy That is with the decimal point after the first digit Truncate trailing zeros that occur after the decimal point if exponential that is everything after the first digit Clamp precision to avoid the code below readding the zeros Fill buffer to contain precision digits Usually the buffer is already at the correct length but doubleToAscii is allowed to return less characters", "focal_method": "b'/**\\n\\t * Computes \\'precision\\' leading digits of the given \\'value\\' and returns them\\n\\t * either in exponential or decimal format, depending on\\n\\t * PrecisionPolicy.max{Leading|Trailing}Zeros (given to the\\n\\t * constructor).\\n\\t *

\\n\\t * The last computed digit is rounded.\\n\\t *

\\n\\t * Example with PrecisionPolicy.maxLeadingZeros = 6.\\n\\t *

\\n\\t * \\n\\t * toPrecision(0.0000012345, 2) -> \"0.0000012\"
\\n\\t * toPrecision(0.00000012345, 2) -> \"1.2e-7\"
\\n\\t *
\\n\\t *

\\n\\t * Similarily the converter may add up to\\n\\t * PrecisionPolicy.maxTrailingZeros in precision mode to avoid\\n\\t * returning an exponential representation. A zero added by the\\n\\t * EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit.\\n\\t *

\\n\\t * Examples for PrecisionPolicy.maxTrailingZeros = 1:\\n\\t *

\\n\\t * \\n\\t * toPrecision(230.0, 2) -> \"230\"
\\n\\t * toPrecision(230.0, 2) -> \"230.\" with EMIT_TRAILING_DECIMAL_POINT.
\\n\\t * toPrecision(230.0, 2) -> \"2.3e2\" with EMIT_TRAILING_ZERO_AFTER_POINT.
\\n\\t *
\\n\\t *

\\n\\t * Examples for PrecisionPolicy.maxTrailingZeros = 3, and no\\n\\t * EMIT_TRAILING_ZERO_AFTER_POINT:\\n\\t *

\\n\\t * \\n\\t * toPrecision(123450.0, 6) -> \"123450\"
\\n\\t * toPrecision(123450.0, 5) -> \"123450\"
\\n\\t * toPrecision(123450.0, 4) -> \"123500\"
\\n\\t * toPrecision(123450.0, 3) -> \"123000\"
\\n\\t * toPrecision(123450.0, 2) -> \"1.2e5\"
\\n\\t *
\\n\\t *

\\n\\t *\\n\\t * @throws IllegalArgumentException when precision < MIN_PRECISION_DIGITS or\\n\\t * precision > MAX_PRECISION_DIGITS\\n\\t */'public static void toPrecision(double value, int precision, FormatOptions formatOptions, CharBuffer resultBuilder) {\r\n\t\tif (Doubles.isSpecial(value)) {\r\n\t\t\thandleSpecialValues(value, formatOptions, resultBuilder);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (precision < MIN_PRECISION_DIGITS || precision > MAX_PRECISION_DIGITS) {\r\n\t\t\tthrow new IllegalArgumentException(String.format(\"argument precision must be in range (%d,%d)\", MIN_PRECISION_DIGITS, MAX_PRECISION_DIGITS));\r\n\t\t}\r\n\r\n\t\t// Find a sufficiently precise decimal representation of n.\r\n\t\t// Add one for the terminating null character.\r\n\t\tDecimalRepBuf decimalRep = new DecimalRepBuf(PRECISION_REP_CAPACITY);\r\n\t\tdoubleToAscii(value, DtoaMode.PRECISION, precision, decimalRep);\r\n\t\tassert decimalRep.length() <= precision;\r\n\r\n\t\t// The exponent if we print the number as x.xxeyyy. That is with the\r\n\t\t// decimal point after the first digit.\r\n\t\tint decimalPoint = decimalRep.getPointPosition();\r\n\t\tint exponent = decimalPoint - 1;\r\n\r\n\t\tboolean asExponential = (-decimalPoint + 1 > MAX_LEADING_ZEROS) || (decimalPoint - precision > MAX_TRAILING_ZEROS);\r\n\t\tif (!formatOptions.alternateForm()) {\r\n\t\t\t// Truncate trailing zeros that occur after the decimal point (if exponential,\r\n\t\t\t// that is everything after the first digit).\r\n\t\t\tdecimalRep.truncateZeros(asExponential);\r\n\t\t\t// Clamp precision to avoid the code below re-adding the zeros.\r\n\t\t\tprecision = Math.min(precision, decimalRep.length());\r\n\t\t}\r\n\t\tif (asExponential) {\r\n\t\t\t// Fill buffer to contain 'precision' digits.\r\n\t\t\t// Usually the buffer is already at the correct length, but 'doubleToAscii'\r\n\t\t\t// is allowed to return less characters.\r\n\t\t\tdecimalRep.zeroExtend(precision);\r\n\r\n\t\t\tcreateExponentialRepresentation(decimalRep, value, precision, exponent, formatOptions, resultBuilder);\r\n\t\t} else {\r\n\t\t\tcreateDecimalRepresentation(decimalRep, value, Math.max(0, precision - decimalRep.getPointPosition()), formatOptions, resultBuilder);\r\n\t\t}\r\n\t}", "test_case": "@Test\r\n\tvoid toPrecision() {\r\n\t\ttestPrec(\"0.00012\", 0.00012345, 2);\r\n\t\ttestPrec(\"1.2e-05\", 0.000012345, 2);\r\n\r\n\t\ttestPrec(\"2\", 2.0, 2, DEFAULT);\r\n\t\ttestPrec(\"2.0\", 2.0, 2, WITH_TRAILING);\r\n\r\n\t\t// maxTrailingZeros = 3;\r\n\t\ttestPrec(\"123450\", 123450.0, 6);\r\n\t\ttestPrec(\"1.2345e+05\", 123450.0, 5);\r\n\t\ttestPrec(\"1.235e+05\", 123450.0, 4);\r\n\t\ttestPrec(\"1.23e+05\", 123450.0, 3);\r\n\t\ttestPrec(\"1.2e+05\", 123450.0, 2);\r\n\r\n\t\ttestPrec(\"32300\", 32.3 * 1000.0, 14);\r\n\r\n\t\tint precision = 6;\r\n\t\ttestPrec(\" 100000\", 100000.0, precision, padding(20, false, false));\r\n\t\ttestPrec(\" 1e+06\", 1000000.0, precision, padding(20, false, false));\r\n\t\ttestPrec(\" 1e+07\", 10000000.0, precision, padding(20, false, false));\r\n\r\n\t\tFormatOptions fo = new FormatOptions(SYMBOLS, true, false, true, 20, false, false);\r\n\t\ttestPrec(\" +0.00000\", 0.0, precision, fo);\r\n\t\ttestPrec(\" +1.00000\", 1.0, precision, fo);\r\n\t\ttestPrec(\" -1.00000\", -1.0, precision, fo);\r\n\t}"} {"description": "t Computes a representation in hexadecimal exponential format with coderequestedDigitscode after the decimalt point The last emitted digit is roundedt t @param value The value to formatt @param requestedDigits The number of digits after the decimal place or @code 1t @param formatOptions Additional options for this numbers formattingt @param resultBuilder The buffer to output tot", "focal_method": "b\"/**\\n\\t * Computes a representation in hexadecimal exponential format with requestedDigits after the decimal\\n\\t * point. The last emitted digit is rounded.\\n\\t *\\n\\t * @param value The value to format.\\n\\t * @param requestedDigits The number of digits after the decimal place, or {@code -1}.\\n\\t * @param formatOptions Additional options for this number's formatting.\\n\\t * @param resultBuilder The buffer to output to.\\n\\t */\"public static void toHex(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {\r\n\t\tif (Doubles.isSpecial(value)) {\r\n\t\t\thandleSpecialValues(value, formatOptions, resultBuilder);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tboolean negative = shouldEmitMinus(value);\r\n\r\n\t\tdouble absValue = Math.abs(value);\r\n\t\tExponentPart significand = createHexSignificand(absValue, requestedDigits, formatOptions);\r\n\r\n\t\tint exponentValue = absValue == 0 ? 0 : Doubles.exponent(absValue) + Doubles.PHYSICAL_SIGNIFICAND_SIZE;\r\n\t\tExponentPart exponent = createExponentPart(exponentValue, 1);\r\n\r\n\t\tint valueWidth = significand.length() + exponent.length() + 3;\r\n\t\tif (negative || formatOptions.explicitPlus() || formatOptions.spaceWhenPositive()) valueWidth++;\r\n\t\tint padWidth = formatOptions.width() <= 0 ? 0 : formatOptions.width() - valueWidth;\r\n\r\n\t\tif (padWidth > 0 && !formatOptions.leftAdjust() && !formatOptions.zeroPad()) {\r\n\t\t\taddPadding(resultBuilder, ' ', padWidth);\r\n\t\t}\r\n\r\n\t\tappendSign(value, formatOptions, resultBuilder);\r\n\t\tresultBuilder.append('0');\r\n\t\tresultBuilder.append(formatOptions.symbols().hexSeparator());\r\n\r\n\t\tif (padWidth > 0 && !formatOptions.leftAdjust() && formatOptions.zeroPad()) {\r\n\t\t\taddPadding(resultBuilder, '0', padWidth);\r\n\t\t}\r\n\r\n\t\tresultBuilder.append(significand.buffer(), significand.start(), significand.length());\r\n\t\tresultBuilder.append(formatOptions.symbols().hexExponent());\r\n\t\tresultBuilder.append(exponent.buffer(), exponent.start(), exponent.length());\r\n\r\n\t\tif (padWidth > 0 && formatOptions.leftAdjust()) addPadding(resultBuilder, ' ', padWidth);\r\n\t}", "test_case": "@Test\r\n\tvoid toHex() {\r\n\t\ttestHex(\"0x0p+0\", 0.0, -1, DEFAULT);\r\n\t\ttestHex(\"0x1p+0\", 1.0, -1, DEFAULT);\r\n\t\ttestHex(\"0x1.8p+1\", 3.0, -1, DEFAULT);\r\n\t\ttestHex(\"0x1.8ae147ae147aep+3\", 12.34, -1, DEFAULT);\r\n\t\ttestHex(\"0x2p+3\", 12.34, 0, DEFAULT);\r\n\t\ttestHex(\"0x1.0ap+1\", 0x1.0ap+1, -1, DEFAULT);\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * Provides a decimal representation of v.\\\\\\\\n\\\\\\\\t * The result should be interpreted as buffer * 10^(point - outLength).\\\\\\\\n\\\\\\\\t *

\\\\\\\\n\\\\\\\\t * Precondition:\\\\\\\\n\\\\\\\\t * * v must be a strictly positive finite double.\\\\\\\\n\\\\\\\\t *

\\\\\\\\n\\\\\\\\t * Returns true if it succeeds, otherwise the result can not be trusted.\\\\\\\\n\\\\\\\\t * If the function returns true and mode equals\\\\\\\\n\\\\\\\\t * - FAST_DTOA_PRECISION, then\\\\\\\\n\\\\\\\\t * the buffer contains requestedDigits digits.\\\\\\\\n\\\\\\\\t * the difference v - (buffer * 10^(point-outLength)) is closest to zero for\\\\\\\\n\\\\\\\\t * all possible representations of requestedDigits digits.\\\\\\\\n\\\\\\\\t * If there are two values that are equally close, then fastDtoa returns\\\\\\\\n\\\\\\\\t * false.\\\\\\\\n\\\\\\\\t * For both modes the buffer must be large enough to hold the result.\\\\\\\\n\\\\\\\\t */', '')\", \"('', '// initialized to 0\\\\n')\"]", "focal_method": "b'/**\\n\\t * Provides a decimal representation of v.\\n\\t * The result should be interpreted as buffer * 10^(point - outLength).\\n\\t *

\\n\\t * Precondition:\\n\\t * * v must be a strictly positive finite double.\\n\\t *

\\n\\t * Returns true if it succeeds, otherwise the result can not be trusted.\\n\\t * If the function returns true and mode equals\\n\\t * - FAST_DTOA_PRECISION, then\\n\\t * the buffer contains requestedDigits digits.\\n\\t * the difference v - (buffer * 10^(point-outLength)) is closest to zero for\\n\\t * all possible representations of requestedDigits digits.\\n\\t * If there are two values that are equally close, then fastDtoa returns\\n\\t * false.\\n\\t * For both modes the buffer must be large enough to hold the result.\\n\\t */'public static boolean fastDtoa(double v, int requestedDigits, DecimalRepBuf buf) {\r\n\t\tassert v > 0.0;\r\n\t\tassert !Doubles.isSpecial(v);\r\n\r\n\t\tboolean result;\r\n\t\tint[] decimalExponent = new int[1]; // initialized to 0\r\n\t\tresult = grisu3Counted(v, requestedDigits, buf, decimalExponent);\r\n\t\tif (result) {\r\n\t\t\tbuf.setPointPosition(buf.length() + decimalExponent[0]);\r\n\t\t} else {\r\n\t\t\tbuf.reset();\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "test_case": "@Test\r\n\tpublic void precisionVariousDoubles() {\r\n\t\tDecimalRepBuf buffer = new DecimalRepBuf(BUFFER_SIZE);\r\n\t\tboolean status;\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(1.0, 3, buffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_GE(3, buffer.length());\r\n\t\tbuffer.truncateAllZeros();\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(1.5, 10, buffer);\r\n\t\tif (status) {\r\n\t\t\tCHECK_GE(10, buffer.length());\r\n\t\t\tbuffer.truncateAllZeros();\r\n\t\t\tCHECK_EQ(\"15\", buffer);\r\n\t\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\t\t}\r\n\r\n\t\tdouble min_double = 5e-324;\r\n\t\tstatus = FastDtoa.fastDtoa(min_double, 5,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"49407\", buffer);\r\n\t\tCHECK_EQ(-323, buffer.getPointPosition());\r\n\r\n\t\tdouble max_double = 1.7976931348623157e308;\r\n\t\tstatus = FastDtoa.fastDtoa(max_double, 7,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"1797693\", buffer);\r\n\t\tCHECK_EQ(309, buffer.getPointPosition());\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(4294967272.0, 14,\r\n\t\t\tbuffer);\r\n\t\tif (status) {\r\n\t\t\tCHECK_GE(14, buffer.length());\r\n\t\t\tbuffer.truncateAllZeros();\r\n\t\t\tCHECK_EQ(\"4294967272\", buffer);\r\n\t\t\tCHECK_EQ(10, buffer.getPointPosition());\r\n\t\t}\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(4.1855804968213567e298, 17,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"41855804968213567\", buffer);\r\n\t\tCHECK_EQ(299, buffer.getPointPosition());\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(5.5626846462680035e-309, 1,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"6\", buffer);\r\n\t\tCHECK_EQ(-308, buffer.getPointPosition());\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(2147483648.0, 5,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"21475\", buffer);\r\n\t\tCHECK_EQ(10, buffer.getPointPosition());\r\n\r\n\t\tstatus = FastDtoa.fastDtoa(3.5844466002796428e+298, 10,\r\n\t\t\tbuffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_GE(10, buffer.length());\r\n\t\tbuffer.truncateAllZeros();\r\n\t\tCHECK_EQ(\"35844466\", buffer);\r\n\t\tCHECK_EQ(299, buffer.getPointPosition());\r\n\r\n\t\tlong smallest_normal64 = 0x00100000_00000000L;\r\n\t\tdouble v = Double.longBitsToDouble(smallest_normal64);\r\n\t\tstatus = FastDtoa.fastDtoa(v, 17, buffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"22250738585072014\", buffer);\r\n\t\tCHECK_EQ(-307, buffer.getPointPosition());\r\n\r\n\t\tlong largest_denormal64 = 0x000FFFFF_FFFFFFFFL;\r\n\t\tv = Double.longBitsToDouble(largest_denormal64);\r\n\t\tstatus = FastDtoa.fastDtoa(v, 17, buffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_GE(20, buffer.length());\r\n\t\tbuffer.truncateAllZeros();\r\n\t\tCHECK_EQ(\"22250738585072009\", buffer);\r\n\t\tCHECK_EQ(-307, buffer.getPointPosition());\r\n\r\n\t\tv = 3.3161339052167390562200598e-237;\r\n\t\tstatus = FastDtoa.fastDtoa(v, 18, buffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"331613390521673906\", buffer);\r\n\t\tCHECK_EQ(-236, buffer.getPointPosition());\r\n\r\n\t\tv = 7.9885183916008099497815232e+191;\r\n\t\tstatus = FastDtoa.fastDtoa(v, 4, buffer);\r\n\t\tCHECK(status);\r\n\t\tCHECK_EQ(\"7989\", buffer);\r\n\t\tCHECK_EQ(192, buffer.getPointPosition());\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * Provides a decimal representation of v.\\\\\\\\n\\\\\\\\t * The result should be interpreted as buffer * 10^(point - outLength).\\\\\\\\n\\\\\\\\t *

\\\\\\\\n\\\\\\\\t * Precondition:\\\\\\\\n\\\\\\\\t * * v must be a strictly positive finite double.\\\\\\\\n\\\\\\\\t *

\\\\\\\\n\\\\\\\\t * Returns true if it succeeds, otherwise the result can not be trusted.\\\\\\\\n\\\\\\\\t * If the function returns true and mode equals\\\\\\\\n\\\\\\\\t * - FAST_DTOA_PRECISION, then\\\\\\\\n\\\\\\\\t * the buffer contains requestedDigits digits.\\\\\\\\n\\\\\\\\t * the difference v - (buffer * 10^(point-outLength)) is closest to zero for\\\\\\\\n\\\\\\\\t * all possible representations of requestedDigits digits.\\\\\\\\n\\\\\\\\t * If there are two values that are equally close, then fastDtoa returns\\\\\\\\n\\\\\\\\t * false.\\\\\\\\n\\\\\\\\t * For both modes the buffer must be large enough to hold the result.\\\\\\\\n\\\\\\\\t */', '')\", \"('', '// initialized to 0\\\\n')\"]", "focal_method": "b'/**\\n\\t * Provides a decimal representation of v.\\n\\t * The result should be interpreted as buffer * 10^(point - outLength).\\n\\t *

\\n\\t * Precondition:\\n\\t * * v must be a strictly positive finite double.\\n\\t *

\\n\\t * Returns true if it succeeds, otherwise the result can not be trusted.\\n\\t * If the function returns true and mode equals\\n\\t * - FAST_DTOA_PRECISION, then\\n\\t * the buffer contains requestedDigits digits.\\n\\t * the difference v - (buffer * 10^(point-outLength)) is closest to zero for\\n\\t * all possible representations of requestedDigits digits.\\n\\t * If there are two values that are equally close, then fastDtoa returns\\n\\t * false.\\n\\t * For both modes the buffer must be large enough to hold the result.\\n\\t */'public static boolean fastDtoa(double v, int requestedDigits, DecimalRepBuf buf) {\r\n\t\tassert v > 0.0;\r\n\t\tassert !Doubles.isSpecial(v);\r\n\r\n\t\tboolean result;\r\n\t\tint[] decimalExponent = new int[1]; // initialized to 0\r\n\t\tresult = grisu3Counted(v, requestedDigits, buf, decimalExponent);\r\n\t\tif (result) {\r\n\t\t\tbuf.setPointPosition(buf.length() + decimalExponent[0]);\r\n\t\t} else {\r\n\t\t\tbuf.reset();\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "test_case": "@Test\r\n\tpublic void gayPrecision() throws Exception {\r\n\t\tPrecisionState state = new PrecisionState();\r\n\r\n\t\tDoubleTestHelper.eachPrecision(state, (st, v, numberDigits, representation, decimalPoint) -> {\r\n\t\t\tboolean status;\r\n\r\n\t\t\tst.total++;\r\n\t\t\tst.underTest = String.format(\"Using {%g, %d, \\\"%s\\\", %d}\", v, numberDigits, representation, decimalPoint);\r\n\t\t\tif (numberDigits <= 15) st.total15++;\r\n\r\n\t\t\tstatus = FastDtoa.fastDtoa(v, numberDigits, st.buffer);\r\n\t\t\tCHECK_GE(numberDigits, st.buffer.length());\r\n\t\t\tif (status) {\r\n\t\t\t\tst.succeeded++;\r\n\t\t\t\tif (numberDigits <= 15) st.succeeded15++;\r\n\t\t\t\tst.buffer.truncateAllZeros();\r\n\t\t\t\tassertThat(st.underTest, st.buffer.getPointPosition(), is(equalTo(decimalPoint)));\r\n\t\t\t\tassertThat(st.underTest, stringOf(st.buffer), is(equalTo(representation)));\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// The precomputed numbers contain many entries with many requested\r\n\t\t// digits. These have a high failure rate and we therefore expect a lower\r\n\t\t// success rate than for the shortest representation.\r\n\t\tassertThat(\"85% should succeed\", state.succeeded * 1.0 / state.total, is(greaterThan(0.85)));\r\n\t\t// However with less than 15 digits almost the algorithm should almost always\r\n\t\t// succeed.\r\n\t\tassertThat(state.succeeded15 * 1.0 / state.total15, is(greaterThan(0.9999)));\r\n\r\n\t\tSystem.out.println(\"gay-precision tests run :\" + Integer.toString(state.total));\r\n\t}"} {"description": "[\"('', '// v = significand * 2^exponent (with significand a 53bit integer).\\\\n')\", \"('', '// If the exponent is larger than 20 (i.e. we may have a 73bit number) then we\\\\n')\", '(\\'\\', \"// don\\'t know how to compute the representation. 2^73 ~= 9.5*10^21.\\\\n\")', '(\\'\\', \"// If necessary this limit could probably be increased, but we don\\'t need\\\\n\")', \"('', '// more.\\\\n')\", \"('', '// At most DOUBLE_SIGNIFICAND_SIZE bits of the significand are non-zero.\\\\n')\", \"('', '// Given a 64 bit integer we have 11 0s followed by 53 potentially non-zero\\\\n')\", \"('', '// bits: 0..11*..0xxx..53*..xx\\\\n')\", \"('', '// compile-time promise that exponent is positive\\\\n')\", \"('', '// The exponent must be > 11.\\\\n')\", \"('', '//\\\\n')\", \"('', '// We know that v = significand * 2^exponent.\\\\n')\", \"('', '// And the exponent > 11.\\\\n')\", \"('', '// We simplify the task by dividing v by 10^17.\\\\n')\", \"('', '// The quotient delivers the first digits, and the remainder fits into a 64\\\\n')\", \"('', '// bit number.\\\\n')\", \"('', '// Dividing by 10^17 is equivalent to dividing by 5^17*2^17.\\\\n')\", \"('', '// 5^17\\\\n')\", \"('', '// Let v = f * 2^e with f == significand and e == exponent.\\\\n')\", \"('', '// Then need q (quotient) and r (remainder) as follows:\\\\n')\", \"('', '// v = q * 10^17 + r\\\\n')\", \"('', '// f * 2^e = q * 10^17 + r\\\\n')\", \"('', '// f * 2^e = q * 5^17 * 2^17 + r\\\\n')\", \"('', '// If e > 17 then\\\\n')\", \"('', '// f * 2^(e-17) = q * 5^17 + r/2^17\\\\n')\", \"('', '// else\\\\n')\", \"('', '// f = q * 5^17 * 2^(17-e) + r/2^e\\\\n')\", \"('', '// We only allow exponents of up to 20 and therefore (17 - e) <= 3\\\\n')\", \"('', '// 0 <= exponent <= 11\\\\n')\", \"('', '// We have to cut the number.\\\\n')\", \"('', '// This configuration (with at most 20 digits) means that all digits must be\\\\n')\", \"('', '// 0.\\\\n')\", \"('', '// The string is empty and the decimalPoint thus has no importance. Mimick\\\\n')\", '(\\'\\', \"// Gay\\'s dtoa and and set it to -fractionalCount.\\\\n\")']", "focal_method": "public static boolean fastFixedDtoa(double v, int fractionalCount, DecimalRepBuf buf) {\r\n\t\tfinal @Unsigned long kMaxUInt32 = 0xFFFF_FFFFL;\r\n\t\t@Unsigned long significand = Doubles.significand(v);\r\n\t\tint exponent = Doubles.exponent(v);\r\n\t\t// v = significand * 2^exponent (with significand a 53bit integer).\r\n\t\t// If the exponent is larger than 20 (i.e. we may have a 73bit number) then we\r\n\t\t// don't know how to compute the representation. 2^73 ~= 9.5*10^21.\r\n\t\t// If necessary this limit could probably be increased, but we don't need\r\n\t\t// more.\r\n\t\tif (exponent > 20) return false;\r\n\t\tif (fractionalCount > 20) return false;\r\n\r\n\t\tbuf.clearBuf();\r\n\t\t// At most DOUBLE_SIGNIFICAND_SIZE bits of the significand are non-zero.\r\n\t\t// Given a 64 bit integer we have 11 0s followed by 53 potentially non-zero\r\n\t\t// bits: 0..11*..0xxx..53*..xx\r\n\t\tif (exponent + DOUBLE_SIGNIFICAND_SIZE > 64) {\r\n\t\t\t// compile-time promise that exponent is positive\r\n\t\t\t@SuppressWarnings(\"cast.unsafe\")\r\n\t\t\t@SignedPositive int positiveExponent = (@SignedPositive int) exponent;\r\n\t\t\t// The exponent must be > 11.\r\n\t\t\t//\r\n\t\t\t// We know that v = significand * 2^exponent.\r\n\t\t\t// And the exponent > 11.\r\n\t\t\t// We simplify the task by dividing v by 10^17.\r\n\t\t\t// The quotient delivers the first digits, and the remainder fits into a 64\r\n\t\t\t// bit number.\r\n\t\t\t// Dividing by 10^17 is equivalent to dividing by 5^17*2^17.\r\n\t\t\tfinal @Unsigned long kFive17 = 0xB1_A2BC2EC5L; // 5^17\r\n\t\t\t@Unsigned long divisor = kFive17;\r\n\t\t\t@SignedPositive int divisorPower = 17;\r\n\t\t\t@Unsigned long dividend = significand;\r\n\t\t\t@Unsigned int quotient;\r\n\t\t\t@Unsigned long remainder;\r\n\t\t\t// Let v = f * 2^e with f == significand and e == exponent.\r\n\t\t\t// Then need q (quotient) and r (remainder) as follows:\r\n\t\t\t// v = q * 10^17 + r\r\n\t\t\t// f * 2^e = q * 10^17 + r\r\n\t\t\t// f * 2^e = q * 5^17 * 2^17 + r\r\n\t\t\t// If e > 17 then\r\n\t\t\t// f * 2^(e-17) = q * 5^17 + r/2^17\r\n\t\t\t// else\r\n\t\t\t// f = q * 5^17 * 2^(17-e) + r/2^e\r\n\t\t\tif (exponent > divisorPower) {\r\n\t\t\t\t// We only allow exponents of up to 20 and therefore (17 - e) <= 3\r\n\t\t\t\tdividend <<= toUlongFromSigned(positiveExponent - divisorPower);\r\n\t\t\t\tquotient = toUint(uDivide(dividend, divisor));\r\n\t\t\t\tremainder = uRemainder(dividend, divisor) << divisorPower;\r\n\t\t\t} else {\r\n\t\t\t\tdivisor <<= toUlongFromSigned(divisorPower - positiveExponent);\r\n\t\t\t\tquotient = toUint(uDivide(dividend, divisor));\r\n\t\t\t\tremainder = uRemainder(dividend, divisor) << exponent;\r\n\t\t\t}\r\n\t\t\tfillDigits32(quotient, buf);\r\n\t\t\tfillDigits64FixedLength(remainder, buf);\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t} else if (exponent >= 0) {\r\n\t\t\t// 0 <= exponent <= 11\r\n\t\t\tsignificand = significand << exponent;\r\n\t\t\tfillDigits64(significand, buf);\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t} else if (exponent > -DOUBLE_SIGNIFICAND_SIZE) {\r\n\t\t\t// We have to cut the number.\r\n\t\t\t@Unsigned long integrals = significand >>> -exponent;\r\n\t\t\t@Unsigned long fractionals = significand - (integrals << -exponent);\r\n\t\t\tif (!isAssignableToUint(integrals)) {\r\n\t\t\t\tfillDigits64(integrals, buf);\r\n\t\t\t} else {\r\n\t\t\t\tfillDigits32(toUint(integrals), buf);\r\n\t\t\t}\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t\tfillFractionals(fractionals, exponent, fractionalCount, buf);\r\n\t\t} else if (exponent < -128) {\r\n\t\t\t// This configuration (with at most 20 digits) means that all digits must be\r\n\t\t\t// 0.\r\n\t\t\tassert fractionalCount <= 20;\r\n\t\t\tbuf.clearBuf();\r\n\t\t\tbuf.setPointPosition(-fractionalCount);\r\n\t\t} else {\r\n\t\t\tbuf.setPointPosition(0);\r\n\t\t\tfillFractionals(significand, exponent, fractionalCount, buf);\r\n\t\t}\r\n\t\tbuf.trimZeros();\r\n\t\tif (buf.length() == 0) {\r\n\t\t\t// The string is empty and the decimalPoint thus has no importance. Mimick\r\n\t\t\t// Gay's dtoa and and set it to -fractionalCount.\r\n\t\t\tbuf.setPointPosition(-fractionalCount);\r\n\t\t}\r\n\t\treturn true;\r\n\t}", "test_case": "@Test\r\n\tpublic void variousDoubles() {\r\n\t\tDecimalRepBuf buffer = new DecimalRepBuf(kBufferSize);\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.0, 1, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.0, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.0, 0, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\t// FIXME Doesn't seem to convert in java\r\n//\t\tCHECK(FixedDtoa.fastFixedDtoa(0xFFFFFFFF, 5, buffer));\r\n//\t\tCHECK_EQ(\"4294967295\", buffer);\r\n//\t\tCHECK_EQ(10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(4294967296.0, 5, buffer));\r\n\t\tCHECK_EQ(\"4294967296\", buffer);\r\n\t\tCHECK_EQ(10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e21, 5, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\t// CHECK_EQ(22, buffer.getPointPosition());\r\n\t\tCHECK_EQ(22, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(999999999999999868928.00, 2, buffer));\r\n\t\tCHECK_EQ(\"999999999999999868928\", buffer);\r\n\t\tCHECK_EQ(21, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer));\r\n\t\tCHECK_EQ(\"6999999999999998951424\", buffer);\r\n\t\tCHECK_EQ(22, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.5, 5, buffer));\r\n\t\tCHECK_EQ(\"15\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.55, 5, buffer));\r\n\t\tCHECK_EQ(\"155\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.55, 1, buffer));\r\n\t\tCHECK_EQ(\"16\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.00000001, 15, buffer));\r\n\t\tCHECK_EQ(\"100000001\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.1, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(0, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.01, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-3, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-4, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-5, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-6, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-7, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000001, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-8, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000001, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-9, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000001, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000001, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-11, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000001, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-12, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000000001, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-13, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-14, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-15, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-16, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-17, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-18, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000000000000001, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-19, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.10000000004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(0, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.01000000004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00100000004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00010000004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-3, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00001000004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-4, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000100004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-5, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000010004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-6, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000001004, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-7, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000104, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-8, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000001000004, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-9, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000100004, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000010004, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-11, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000001004, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-12, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000000104, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-13, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000001000004, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-14, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000100004, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-15, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000010004, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-16, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000001004, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-17, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000000104, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-18, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000000014, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-19, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.10000000006, 10, buffer));\r\n\t\tCHECK_EQ(\"1000000001\", buffer);\r\n\t\tCHECK_EQ(0, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.01000000006, 10, buffer));\r\n\t\tCHECK_EQ(\"100000001\", buffer);\r\n\t\tCHECK_EQ(-1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00100000006, 10, buffer));\r\n\t\tCHECK_EQ(\"10000001\", buffer);\r\n\t\tCHECK_EQ(-2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00010000006, 10, buffer));\r\n\t\tCHECK_EQ(\"1000001\", buffer);\r\n\t\tCHECK_EQ(-3, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00001000006, 10, buffer));\r\n\t\tCHECK_EQ(\"100001\", buffer);\r\n\t\tCHECK_EQ(-4, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000100006, 10, buffer));\r\n\t\tCHECK_EQ(\"10001\", buffer);\r\n\t\tCHECK_EQ(-5, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000010006, 10, buffer));\r\n\t\tCHECK_EQ(\"1001\", buffer);\r\n\t\tCHECK_EQ(-6, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000001006, 10, buffer));\r\n\t\tCHECK_EQ(\"101\", buffer);\r\n\t\tCHECK_EQ(-7, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000000106, 10, buffer));\r\n\t\tCHECK_EQ(\"11\", buffer);\r\n\t\tCHECK_EQ(-8, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000001000006, 15, buffer));\r\n\t\tCHECK_EQ(\"100001\", buffer);\r\n\t\tCHECK_EQ(-9, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000100006, 15, buffer));\r\n\t\tCHECK_EQ(\"10001\", buffer);\r\n\t\tCHECK_EQ(-10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000010006, 15, buffer));\r\n\t\tCHECK_EQ(\"1001\", buffer);\r\n\t\tCHECK_EQ(-11, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000001006, 15, buffer));\r\n\t\tCHECK_EQ(\"101\", buffer);\r\n\t\tCHECK_EQ(-12, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000000000000106, 15, buffer));\r\n\t\tCHECK_EQ(\"11\", buffer);\r\n\t\tCHECK_EQ(-13, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000001000006, 20, buffer));\r\n\t\tCHECK_EQ(\"100001\", buffer);\r\n\t\tCHECK_EQ(-14, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000100006, 20, buffer));\r\n\t\tCHECK_EQ(\"10001\", buffer);\r\n\t\tCHECK_EQ(-15, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000010006, 20, buffer));\r\n\t\tCHECK_EQ(\"1001\", buffer);\r\n\t\tCHECK_EQ(-16, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000001006, 20, buffer));\r\n\t\tCHECK_EQ(\"101\", buffer);\r\n\t\tCHECK_EQ(-17, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000000106, 20, buffer));\r\n\t\tCHECK_EQ(\"11\", buffer);\r\n\t\tCHECK_EQ(-18, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000000000000000016, 20, buffer));\r\n\t\tCHECK_EQ(\"2\", buffer);\r\n\t\tCHECK_EQ(-19, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.6, 0, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.96, 1, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.996, 2, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.9996, 3, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.99996, 4, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.999996, 5, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.9999996, 6, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.99999996, 7, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.999999996, 8, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.9999999996, 9, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.99999999996, 10, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.999999999996, 11, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.9999999999996, 12, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.99999999999996, 13, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.999999999999996, 14, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.9999999999999996, 15, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00999999999999996, 16, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000999999999999996, 17, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.0000999999999999996, 18, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-3, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.00000999999999999996, 19, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-4, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.000000999999999999996, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-5, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(323423.234234, 10, buffer));\r\n\t\tCHECK_EQ(\"323423234234\", buffer);\r\n\t\tCHECK_EQ(6, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(12345678.901234, 4, buffer));\r\n\t\tCHECK_EQ(\"123456789012\", buffer);\r\n\t\tCHECK_EQ(8, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(98765.432109, 5, buffer));\r\n\t\tCHECK_EQ(\"9876543211\", buffer);\r\n\t\tCHECK_EQ(5, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(42, 20, buffer));\r\n\t\tCHECK_EQ(\"42\", buffer);\r\n\t\tCHECK_EQ(2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(0.5, 0, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(1, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-23, 10, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-10, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-123, 2, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-2, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-123, 0, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(0, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-23, 20, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-20, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-21, 20, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-20, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1e-22, 20, buffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-20, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(6e-21, 20, buffer));\r\n\t\tCHECK_EQ(\"1\", buffer);\r\n\t\tCHECK_EQ(-19, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(9.1193616301674545152000000e+19, 0,\r\n\t\t\tbuffer));\r\n\t\tCHECK_EQ(\"91193616301674545152\", buffer);\r\n\t\tCHECK_EQ(20, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(4.8184662102767651659096515e-04, 19,\r\n\t\t\tbuffer));\r\n\t\tCHECK_EQ(\"4818466210276765\", buffer);\r\n\t\tCHECK_EQ(-3, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1.9023164229540652612705182e-23, 8,\r\n\t\t\tbuffer));\r\n\t\tCHECK_EQ(\"\", buffer);\r\n\t\tCHECK_EQ(-8, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(1000000000000000128.0, 0,\r\n\t\t\tbuffer));\r\n\t\tCHECK_EQ(\"1000000000000000128\", buffer);\r\n\t\tCHECK_EQ(19, buffer.getPointPosition());\r\n\r\n\t\tCHECK(FixedDtoa.fastFixedDtoa(2.10861548515811875e+15, 17, buffer));\r\n\t\tCHECK_EQ(\"210861548515811875\", buffer);\r\n\t\tCHECK_EQ(16, buffer.getPointPosition());\r\n\t}"} {"description": "[\"('', '// v = significand * 2^exponent (with significand a 53bit integer).\\\\n')\", \"('', '// If the exponent is larger than 20 (i.e. we may have a 73bit number) then we\\\\n')\", '(\\'\\', \"// don\\'t know how to compute the representation. 2^73 ~= 9.5*10^21.\\\\n\")', '(\\'\\', \"// If necessary this limit could probably be increased, but we don\\'t need\\\\n\")', \"('', '// more.\\\\n')\", \"('', '// At most DOUBLE_SIGNIFICAND_SIZE bits of the significand are non-zero.\\\\n')\", \"('', '// Given a 64 bit integer we have 11 0s followed by 53 potentially non-zero\\\\n')\", \"('', '// bits: 0..11*..0xxx..53*..xx\\\\n')\", \"('', '// compile-time promise that exponent is positive\\\\n')\", \"('', '// The exponent must be > 11.\\\\n')\", \"('', '//\\\\n')\", \"('', '// We know that v = significand * 2^exponent.\\\\n')\", \"('', '// And the exponent > 11.\\\\n')\", \"('', '// We simplify the task by dividing v by 10^17.\\\\n')\", \"('', '// The quotient delivers the first digits, and the remainder fits into a 64\\\\n')\", \"('', '// bit number.\\\\n')\", \"('', '// Dividing by 10^17 is equivalent to dividing by 5^17*2^17.\\\\n')\", \"('', '// 5^17\\\\n')\", \"('', '// Let v = f * 2^e with f == significand and e == exponent.\\\\n')\", \"('', '// Then need q (quotient) and r (remainder) as follows:\\\\n')\", \"('', '// v = q * 10^17 + r\\\\n')\", \"('', '// f * 2^e = q * 10^17 + r\\\\n')\", \"('', '// f * 2^e = q * 5^17 * 2^17 + r\\\\n')\", \"('', '// If e > 17 then\\\\n')\", \"('', '// f * 2^(e-17) = q * 5^17 + r/2^17\\\\n')\", \"('', '// else\\\\n')\", \"('', '// f = q * 5^17 * 2^(17-e) + r/2^e\\\\n')\", \"('', '// We only allow exponents of up to 20 and therefore (17 - e) <= 3\\\\n')\", \"('', '// 0 <= exponent <= 11\\\\n')\", \"('', '// We have to cut the number.\\\\n')\", \"('', '// This configuration (with at most 20 digits) means that all digits must be\\\\n')\", \"('', '// 0.\\\\n')\", \"('', '// The string is empty and the decimalPoint thus has no importance. Mimick\\\\n')\", '(\\'\\', \"// Gay\\'s dtoa and and set it to -fractionalCount.\\\\n\")']", "focal_method": "public static boolean fastFixedDtoa(double v, int fractionalCount, DecimalRepBuf buf) {\r\n\t\tfinal @Unsigned long kMaxUInt32 = 0xFFFF_FFFFL;\r\n\t\t@Unsigned long significand = Doubles.significand(v);\r\n\t\tint exponent = Doubles.exponent(v);\r\n\t\t// v = significand * 2^exponent (with significand a 53bit integer).\r\n\t\t// If the exponent is larger than 20 (i.e. we may have a 73bit number) then we\r\n\t\t// don't know how to compute the representation. 2^73 ~= 9.5*10^21.\r\n\t\t// If necessary this limit could probably be increased, but we don't need\r\n\t\t// more.\r\n\t\tif (exponent > 20) return false;\r\n\t\tif (fractionalCount > 20) return false;\r\n\r\n\t\tbuf.clearBuf();\r\n\t\t// At most DOUBLE_SIGNIFICAND_SIZE bits of the significand are non-zero.\r\n\t\t// Given a 64 bit integer we have 11 0s followed by 53 potentially non-zero\r\n\t\t// bits: 0..11*..0xxx..53*..xx\r\n\t\tif (exponent + DOUBLE_SIGNIFICAND_SIZE > 64) {\r\n\t\t\t// compile-time promise that exponent is positive\r\n\t\t\t@SuppressWarnings(\"cast.unsafe\")\r\n\t\t\t@SignedPositive int positiveExponent = (@SignedPositive int) exponent;\r\n\t\t\t// The exponent must be > 11.\r\n\t\t\t//\r\n\t\t\t// We know that v = significand * 2^exponent.\r\n\t\t\t// And the exponent > 11.\r\n\t\t\t// We simplify the task by dividing v by 10^17.\r\n\t\t\t// The quotient delivers the first digits, and the remainder fits into a 64\r\n\t\t\t// bit number.\r\n\t\t\t// Dividing by 10^17 is equivalent to dividing by 5^17*2^17.\r\n\t\t\tfinal @Unsigned long kFive17 = 0xB1_A2BC2EC5L; // 5^17\r\n\t\t\t@Unsigned long divisor = kFive17;\r\n\t\t\t@SignedPositive int divisorPower = 17;\r\n\t\t\t@Unsigned long dividend = significand;\r\n\t\t\t@Unsigned int quotient;\r\n\t\t\t@Unsigned long remainder;\r\n\t\t\t// Let v = f * 2^e with f == significand and e == exponent.\r\n\t\t\t// Then need q (quotient) and r (remainder) as follows:\r\n\t\t\t// v = q * 10^17 + r\r\n\t\t\t// f * 2^e = q * 10^17 + r\r\n\t\t\t// f * 2^e = q * 5^17 * 2^17 + r\r\n\t\t\t// If e > 17 then\r\n\t\t\t// f * 2^(e-17) = q * 5^17 + r/2^17\r\n\t\t\t// else\r\n\t\t\t// f = q * 5^17 * 2^(17-e) + r/2^e\r\n\t\t\tif (exponent > divisorPower) {\r\n\t\t\t\t// We only allow exponents of up to 20 and therefore (17 - e) <= 3\r\n\t\t\t\tdividend <<= toUlongFromSigned(positiveExponent - divisorPower);\r\n\t\t\t\tquotient = toUint(uDivide(dividend, divisor));\r\n\t\t\t\tremainder = uRemainder(dividend, divisor) << divisorPower;\r\n\t\t\t} else {\r\n\t\t\t\tdivisor <<= toUlongFromSigned(divisorPower - positiveExponent);\r\n\t\t\t\tquotient = toUint(uDivide(dividend, divisor));\r\n\t\t\t\tremainder = uRemainder(dividend, divisor) << exponent;\r\n\t\t\t}\r\n\t\t\tfillDigits32(quotient, buf);\r\n\t\t\tfillDigits64FixedLength(remainder, buf);\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t} else if (exponent >= 0) {\r\n\t\t\t// 0 <= exponent <= 11\r\n\t\t\tsignificand = significand << exponent;\r\n\t\t\tfillDigits64(significand, buf);\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t} else if (exponent > -DOUBLE_SIGNIFICAND_SIZE) {\r\n\t\t\t// We have to cut the number.\r\n\t\t\t@Unsigned long integrals = significand >>> -exponent;\r\n\t\t\t@Unsigned long fractionals = significand - (integrals << -exponent);\r\n\t\t\tif (!isAssignableToUint(integrals)) {\r\n\t\t\t\tfillDigits64(integrals, buf);\r\n\t\t\t} else {\r\n\t\t\t\tfillDigits32(toUint(integrals), buf);\r\n\t\t\t}\r\n\t\t\tbuf.setPointPosition(buf.length());\r\n\t\t\tfillFractionals(fractionals, exponent, fractionalCount, buf);\r\n\t\t} else if (exponent < -128) {\r\n\t\t\t// This configuration (with at most 20 digits) means that all digits must be\r\n\t\t\t// 0.\r\n\t\t\tassert fractionalCount <= 20;\r\n\t\t\tbuf.clearBuf();\r\n\t\t\tbuf.setPointPosition(-fractionalCount);\r\n\t\t} else {\r\n\t\t\tbuf.setPointPosition(0);\r\n\t\t\tfillFractionals(significand, exponent, fractionalCount, buf);\r\n\t\t}\r\n\t\tbuf.trimZeros();\r\n\t\tif (buf.length() == 0) {\r\n\t\t\t// The string is empty and the decimalPoint thus has no importance. Mimick\r\n\t\t\t// Gay's dtoa and and set it to -fractionalCount.\r\n\t\t\tbuf.setPointPosition(-fractionalCount);\r\n\t\t}\r\n\t\treturn true;\r\n\t}", "test_case": "@Test\r\n\tpublic void gayFixed() throws Exception {\r\n\t\tDtoaTest.DataTestState state = new DtoaTest.DataTestState();\r\n\t\tDoubleTestHelper.eachFixed(state, (st, v, numberDigits, representation, decimalPoint) -> {\r\n\t\t\tst.total++;\r\n\r\n\t\t\tst.underTest = String.format(\"Using {%g, \\\"%s\\\", %d}\", v, representation, decimalPoint);\r\n\t\t\tboolean status = FixedDtoa.fastFixedDtoa(v, numberDigits, st.buffer);\r\n\r\n\t\t\tassertThat(st.underTest, status, is(true));\r\n\t\t\tassertThat(st.underTest, st.buffer.getPointPosition(), is(equalTo(decimalPoint)));\r\n\r\n\t\t\tassertThat(st.underTest, st.buffer.getPointPosition(), is(equalTo(decimalPoint)));\r\n\t\t\tassertThat(st.underTest, (st.buffer.length() - st.buffer.getPointPosition()), is(lessThanOrEqualTo(numberDigits)));\r\n\t\t\tassertThat(st.underTest, stringOf(st.buffer), is(equalTo(representation)));\r\n\t\t});\r\n\r\n\t\tSystem.out.println(\"day-precision tests run :\" + Integer.toString(state.total));\r\n\t}"} {"description": "values verified positive at beginning of method remainder quotient", "focal_method": "@SuppressWarnings(\"return.type.incompatible\") // values verified positive at beginning of method\r\n\t@Unsigned int divideModuloIntBignum(Bignum other) {\r\n\t\trequireState(val.signum() >= 0 && other.val.signum() >= 0, \"values must be positive\");\r\n\t\tBigInteger[] rets = val.divideAndRemainder(other.val);\r\n\t\tval = rets[1]; // remainder\r\n\r\n\t\treturn toUint(rets[0]); // quotient\r\n\t}", "test_case": "@Test\r\n\tpublic void divideModuloIntBignum() {\r\n\t\tchar[] buffer = new char[kBufferSize];\r\n\t\tBignum bignum = new Bignum();\r\n\t\tBignum other = new Bignum();\r\n\t\tBignum third = new Bignum();\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tother.assignUInt16((short) 2);\r\n\t\tCHECK_EQ(5, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"0\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tbignum.shiftLeft(500);\r\n\t\tother.assignUInt16((short) 2);\r\n\t\tother.shiftLeft(500);\r\n\t\tCHECK_EQ(5, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"0\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 11);\r\n\t\tother.assignUInt16((short) 2);\r\n\t\tCHECK_EQ(5, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"1\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tbignum.shiftLeft(500);\r\n\t\tother.assignUInt16((short) 1);\r\n\t\tbignum.addBignum(other);\r\n\t\tother.assignUInt16((short) 2);\r\n\t\tother.shiftLeft(500);\r\n\t\tCHECK_EQ(5, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"1\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tbignum.shiftLeft(500);\r\n\t\tother.assignBignum(bignum);\r\n\t\tbignum.multiplyByUInt32(0x1234);\r\n\t\tthird.assignUInt16((short) 0xFFF);\r\n\t\tbignum.addBignum(third);\r\n\t\tCHECK_EQ(0x1234, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"FFF\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tassignHexString(other, \"1234567890\");\r\n\t\tCHECK_EQ(0, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"A\", bignum.toHexString());\r\n\r\n\t\tassignHexString(bignum, \"12345678\");\r\n\t\tassignHexString(other, \"3789012\");\r\n\t\tCHECK_EQ(5, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"D9861E\", bignum.toHexString());\r\n\r\n\t\tassignHexString(bignum, \"70000001\");\r\n\t\tassignHexString(other, \"1FFFFFFF\");\r\n\t\tCHECK_EQ(3, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"10000004\", bignum.toHexString());\r\n\r\n\t\tassignHexString(bignum, \"28000000\");\r\n\t\tassignHexString(other, \"12A05F20\");\r\n\t\tCHECK_EQ(2, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"2BF41C0\", bignum.toHexString());\r\n\r\n\t\tbignum.assignUInt16((short) 10);\r\n\t\tbignum.shiftLeft(500);\r\n\t\tother.assignBignum(bignum);\r\n\t\tbignum.multiplyByUInt32(0x1234);\r\n\t\tthird.assignUInt16((short) 0xFFF);\r\n\t\tother.subtractBignum(third);\r\n\t\tCHECK_EQ(0x1234, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"1232DCC\", bignum.toHexString());\r\n\t\tCHECK_EQ(0, bignum.divideModuloIntBignum(other));\r\n\t\tCHECK_EQ(\"1232DCC\", bignum.toHexString());\r\n\t}"} {"description": "['(\"/**\\\\\\\\n * Creates Jetty\\'s {@link ShutdownHandler}.\\\\\\\\n * \\\\\\\\n * @param environment the environment\\\\\\\\n * @return an instance of {@link ShutdownHandler} if\\\\\\\\n * {@link Environment#SERVER_SHUTDOWN_TOKEN_KEY} is\\\\\\\\n * available; otherwise null\\\\\\\\n */\", \\'\\')']", "focal_method": "b\"/**\\n * Creates Jetty's {@link ShutdownHandler}.\\n * \\n * @param environment the environment\\n * @return an instance of {@link ShutdownHandler} if\\n * {@link Environment#SERVER_SHUTDOWN_TOKEN_KEY} is\\n * available; otherwise null\\n */\"protected ShutdownHandler createShutdownHandler(Environment environment) {\r\n String shutdownToken = environment.getServerShutdownToken();\r\n if (shutdownToken == null || shutdownToken.isEmpty()) {\r\n return null;\r\n }\r\n return new ShutdownHandler(shutdownToken, true, false);\r\n }", "test_case": "@Test\r\n public void createShutdownHandlerReturnsNullWithNoToken() throws Exception {\r\n HandlerCollectionLoader hcl = new HandlerCollectionLoader();\r\n ShutdownHandler shutdownHandler = hcl.createShutdownHandler(env);\r\n assertThat(shutdownHandler).isNull();\r\n }"} {"description": "['(\"/**\\\\\\\\n * Creates Jetty\\'s {@link ShutdownHandler}.\\\\\\\\n * \\\\\\\\n * @param environment the environment\\\\\\\\n * @return an instance of {@link ShutdownHandler} if\\\\\\\\n * {@link Environment#SERVER_SHUTDOWN_TOKEN_KEY} is\\\\\\\\n * available; otherwise null\\\\\\\\n */\", \\'\\')']", "focal_method": "b\"/**\\n * Creates Jetty's {@link ShutdownHandler}.\\n * \\n * @param environment the environment\\n * @return an instance of {@link ShutdownHandler} if\\n * {@link Environment#SERVER_SHUTDOWN_TOKEN_KEY} is\\n * available; otherwise null\\n */\"protected ShutdownHandler createShutdownHandler(Environment environment) {\r\n String shutdownToken = environment.getServerShutdownToken();\r\n if (shutdownToken == null || shutdownToken.isEmpty()) {\r\n return null;\r\n }\r\n return new ShutdownHandler(shutdownToken, true, false);\r\n }", "test_case": "@Test\r\n public void createShutdownHandlerObserversShutdownTokenWhenPresent() throws Exception {\r\n HandlerCollectionLoader hcl = new HandlerCollectionLoader();\r\n String token = UUID.randomUUID().toString();\r\n defaultEnv.put(Environment.SERVER_SHUTDOWN_TOKEN_KEY, token);\r\n env = Environment.createEnvironment(defaultEnv);\r\n ShutdownHandler shutdownHandler = hcl.createShutdownHandler(env);\r\n assertThat(shutdownHandler).isNotNull();\r\n assertThat(shutdownHandler.getShutdownToken()).isEqualTo(token);\r\n }"} {"description": "['(\"/*\\\\n\\\\t\\\\t\\\\t\\\\t * we don\\'t know for sure why the thread was interrupted, so we\\\\n\\\\t\\\\t\\\\t\\\\t * need to obey; if interrupt was not relevant, the process will\\\\n\\\\t\\\\t\\\\t\\\\t * restart; we need to restore the interrupt status so that the\\\\n\\\\t\\\\t\\\\t\\\\t * called methods know that there was an interrupt\\\\n\\\\t\\\\t\\\\t\\\\t */\", \\'\\')']", "focal_method": "@Override\r\n\tpublic synchronized void load(ElkAxiomProcessor axiomInserter,\r\n\t\t\tElkAxiomProcessor axiomDeleter) throws ElkLoadingException {\r\n\t\tif (finished_)\r\n\t\t\treturn;\r\n\r\n\t\tif (!started_) {\r\n\t\t\tparserThread_.start();\r\n\t\t\tstarted_ = true;\r\n\t\t}\r\n\r\n\t\tArrayList nextBatch;\r\n\r\n\t\tfor (;;) {\r\n\t\t\tif (isInterrupted())\r\n\t\t\t\tbreak;\r\n\t\t\ttry {\r\n\t\t\t\tnextBatch = axiomExchanger_.take();\r\n\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t/*\r\n\t\t\t\t * we don't know for sure why the thread was interrupted, so we\r\n\t\t\t\t * need to obey; if interrupt was not relevant, the process will\r\n\t\t\t\t * restart; we need to restore the interrupt status so that the\r\n\t\t\t\t * called methods know that there was an interrupt\r\n\t\t\t\t */\r\n\t\t\t\tThread.currentThread().interrupt();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (nextBatch == POISON_BATCH_) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfor (int i = 0; i < nextBatch.size(); i++) {\r\n\t\t\t\tElkAxiom axiom = nextBatch.get(i);\r\n\t\t\t\taxiomInserter.visit(axiom);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (exception != null) {\r\n\t\t\tthrow exception;\r\n\t\t}\r\n\t}", "test_case": "@Test(expected = ElkLoadingException.class)\r\n\tpublic void expectedLoadingExceptionOnSyntaxError()\r\n\t\t\tthrows ElkLoadingException {\r\n\t\tString ontology = \"\"//\r\n\t\t\t\t+ \"Prefix( : = )\"//\r\n\t\t\t\t+ \"Ontology((((()(\"//\r\n\t\t\t\t+ \"EquivalentClasses(:B :C)\"//\r\n\t\t\t\t+ \"SubClassOf(:A ObjectSomeValuesFrom(:R :B))\"//\r\n\t\t\t\t+ \"))\";\r\n\r\n\t\tload(ontology);\r\n\t}"} {"description": "['(\"/*\\\\n\\\\t\\\\t\\\\t\\\\t * we don\\'t know for sure why the thread was interrupted, so we\\\\n\\\\t\\\\t\\\\t\\\\t * need to obey; if interrupt was not relevant, the process will\\\\n\\\\t\\\\t\\\\t\\\\t * restart; we need to restore the interrupt status so that the\\\\n\\\\t\\\\t\\\\t\\\\t * called methods know that there was an interrupt\\\\n\\\\t\\\\t\\\\t\\\\t */\", \\'\\')']", "focal_method": "@Override\r\n\tpublic synchronized void load(ElkAxiomProcessor axiomInserter,\r\n\t\t\tElkAxiomProcessor axiomDeleter) throws ElkLoadingException {\r\n\t\tif (finished_)\r\n\t\t\treturn;\r\n\r\n\t\tif (!started_) {\r\n\t\t\tparserThread_.start();\r\n\t\t\tstarted_ = true;\r\n\t\t}\r\n\r\n\t\tArrayList nextBatch;\r\n\r\n\t\tfor (;;) {\r\n\t\t\tif (isInterrupted())\r\n\t\t\t\tbreak;\r\n\t\t\ttry {\r\n\t\t\t\tnextBatch = axiomExchanger_.take();\r\n\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t/*\r\n\t\t\t\t * we don't know for sure why the thread was interrupted, so we\r\n\t\t\t\t * need to obey; if interrupt was not relevant, the process will\r\n\t\t\t\t * restart; we need to restore the interrupt status so that the\r\n\t\t\t\t * called methods know that there was an interrupt\r\n\t\t\t\t */\r\n\t\t\t\tThread.currentThread().interrupt();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (nextBatch == POISON_BATCH_) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfor (int i = 0; i < nextBatch.size(); i++) {\r\n\t\t\t\tElkAxiom axiom = nextBatch.get(i);\r\n\t\t\t\taxiomInserter.visit(axiom);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (exception != null) {\r\n\t\t\tthrow exception;\r\n\t\t}\r\n\t}", "test_case": "@Test(expected = ElkLoadingException.class)\r\n\tpublic void expectedLoadingExceptionOnLexicalError() throws Exception {\r\n\t\tString ontology = \"\"//\r\n\t\t\t\t+ \"Prefix( : = )\"//\r\n\t\t\t\t+ \"Ontology-LEXICAL-ERROR(\"//\r\n\t\t\t\t+ \"EquivalentClasses(:B :C)\"//\r\n\t\t\t\t+ \"SubClassOf(:A ObjectSomeValuesFrom(:R :B))\"//\r\n\t\t\t\t+ \")\";\r\n\r\n\t\tload(ontology);\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * @param prefix\\\\\\\\n\\\\\\\\t * the prefix of configuration options to be loaded\\\\\\\\n\\\\\\\\t * @param configClass\\\\\\\\n\\\\\\\\t * the class to be instantiated with the loaded options\\\\\\\\n\\\\\\\\t * @return the {@link BaseConfiguration} for the specified parameters\\\\\\\\n\\\\\\\\t * @throws ConfigurationException\\\\\\\\n\\\\\\\\t * if loading fails\\\\\\\\n\\\\\\\\t */', '')\", '(\\'\\', \"// try to find elk.properties. if doesn\\'t exist, use the default\\\\n\")', \"('', '// parameter values for the given class\\\\n')\", \"('', '// copy parameters from the bundle\\\\n')\"]", "focal_method": "b'/**\\n\\t * @param prefix\\n\\t * the prefix of configuration options to be loaded\\n\\t * @param configClass\\n\\t * the class to be instantiated with the loaded options\\n\\t * @return the {@link BaseConfiguration} for the specified parameters\\n\\t * @throws ConfigurationException\\n\\t * if loading fails\\n\\t */'public BaseConfiguration getConfiguration(String prefix,\r\n\t\t\tClass configClass)\r\n\t\t\tthrows ConfigurationException {\r\n\t\t// try to find elk.properties. if doesn't exist, use the default\r\n\t\t// parameter values for the given class\r\n\t\tResourceBundle bundle = null;\r\n\t\tBaseConfiguration config = instantiate(configClass);\r\n\r\n\t\ttry {\r\n\t\t\tbundle = ResourceBundle.getBundle(STANDARD_RESOURCE_NAME,\r\n\t\t\t\t\tLocale.getDefault(), configClass.getClassLoader());\r\n\t\t} catch (MissingResourceException e) {\r\n\t\t}\r\n\r\n\t\tif (bundle == null) {\r\n\t\t\tLOGGER_.debug(\"Loading default configuration parameters for \"\r\n\t\t\t\t\t+ configClass);\r\n\t\t} else {\r\n\t\t\t// copy parameters from the bundle\r\n\t\t\tcopyParameters(prefix, config, bundle);\r\n\t\t}\r\n\r\n\t\tcopyParameters(prefix, config, System.getProperties());\r\n\r\n\t\treturn config;\r\n\t}", "test_case": "@SuppressWarnings(\"static-method\")\r\n\t@Test\r\n\tpublic void getDefaultConfiguration() {\r\n\t\tBaseConfiguration defaultConfig = new ConfigurationFactory()\r\n\t\t\t\t.getConfiguration(\"elk\", BaseConfiguration.class);\r\n\r\n\t\tassertEquals(3, defaultConfig.getParameterNames().size());\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * @param prefix\\\\\\\\n\\\\\\\\t * the prefix of configuration options to be loaded\\\\\\\\n\\\\\\\\t * @param configClass\\\\\\\\n\\\\\\\\t * the class to be instantiated with the loaded options\\\\\\\\n\\\\\\\\t * @return the {@link BaseConfiguration} for the specified parameters\\\\\\\\n\\\\\\\\t * @throws ConfigurationException\\\\\\\\n\\\\\\\\t * if loading fails\\\\\\\\n\\\\\\\\t */', '')\", '(\\'\\', \"// try to find elk.properties. if doesn\\'t exist, use the default\\\\n\")', \"('', '// parameter values for the given class\\\\n')\", \"('', '// copy parameters from the bundle\\\\n')\"]", "focal_method": "b'/**\\n\\t * @param prefix\\n\\t * the prefix of configuration options to be loaded\\n\\t * @param configClass\\n\\t * the class to be instantiated with the loaded options\\n\\t * @return the {@link BaseConfiguration} for the specified parameters\\n\\t * @throws ConfigurationException\\n\\t * if loading fails\\n\\t */'public BaseConfiguration getConfiguration(String prefix,\r\n\t\t\tClass configClass)\r\n\t\t\tthrows ConfigurationException {\r\n\t\t// try to find elk.properties. if doesn't exist, use the default\r\n\t\t// parameter values for the given class\r\n\t\tResourceBundle bundle = null;\r\n\t\tBaseConfiguration config = instantiate(configClass);\r\n\r\n\t\ttry {\r\n\t\t\tbundle = ResourceBundle.getBundle(STANDARD_RESOURCE_NAME,\r\n\t\t\t\t\tLocale.getDefault(), configClass.getClassLoader());\r\n\t\t} catch (MissingResourceException e) {\r\n\t\t}\r\n\r\n\t\tif (bundle == null) {\r\n\t\t\tLOGGER_.debug(\"Loading default configuration parameters for \"\r\n\t\t\t\t\t+ configClass);\r\n\t\t} else {\r\n\t\t\t// copy parameters from the bundle\r\n\t\t\tcopyParameters(prefix, config, bundle);\r\n\t\t}\r\n\r\n\t\tcopyParameters(prefix, config, System.getProperties());\r\n\r\n\t\treturn config;\r\n\t}", "test_case": "@SuppressWarnings(\"static-method\")\r\n\t@Test\r\n\tpublic void getDefaultConfigurationWithPrefix() {\r\n\t\tBaseConfiguration defaultConfig = new ConfigurationFactory()\r\n\t\t\t\t.getConfiguration(\"elk.reasoner\", BaseConfiguration.class);\r\n\r\n\t\tassertEquals(2, defaultConfig.getParameterNames().size());\r\n\r\n\t\tdefaultConfig = new ConfigurationFactory().getConfiguration(\r\n\t\t\t\t\"elk.parser\", BaseConfiguration.class);\r\n\r\n\t\tassertEquals(1, defaultConfig.getParameterNames().size());\r\n\t}"} {"description": "[\"('/**\\\\\\\\n\\\\\\\\t * @param prefix\\\\\\\\n\\\\\\\\t * the prefix of configuration options to be loaded\\\\\\\\n\\\\\\\\t * @param configClass\\\\\\\\n\\\\\\\\t * the class to be instantiated with the loaded options\\\\\\\\n\\\\\\\\t * @return the {@link BaseConfiguration} for the specified parameters\\\\\\\\n\\\\\\\\t * @throws ConfigurationException\\\\\\\\n\\\\\\\\t * if loading fails\\\\\\\\n\\\\\\\\t */', '')\", '(\\'\\', \"// try to find elk.properties. if doesn\\'t exist, use the default\\\\n\")', \"('', '// parameter values for the given class\\\\n')\", \"('', '// copy parameters from the bundle\\\\n')\"]", "focal_method": "b'/**\\n\\t * @param prefix\\n\\t * the prefix of configuration options to be loaded\\n\\t * @param configClass\\n\\t * the class to be instantiated with the loaded options\\n\\t * @return the {@link BaseConfiguration} for the specified parameters\\n\\t * @throws ConfigurationException\\n\\t * if loading fails\\n\\t */'public BaseConfiguration getConfiguration(String prefix,\r\n\t\t\tClass configClass)\r\n\t\t\tthrows ConfigurationException {\r\n\t\t// try to find elk.properties. if doesn't exist, use the default\r\n\t\t// parameter values for the given class\r\n\t\tResourceBundle bundle = null;\r\n\t\tBaseConfiguration config = instantiate(configClass);\r\n\r\n\t\ttry {\r\n\t\t\tbundle = ResourceBundle.getBundle(STANDARD_RESOURCE_NAME,\r\n\t\t\t\t\tLocale.getDefault(), configClass.getClassLoader());\r\n\t\t} catch (MissingResourceException e) {\r\n\t\t}\r\n\r\n\t\tif (bundle == null) {\r\n\t\t\tLOGGER_.debug(\"Loading default configuration parameters for \"\r\n\t\t\t\t\t+ configClass);\r\n\t\t} else {\r\n\t\t\t// copy parameters from the bundle\r\n\t\t\tcopyParameters(prefix, config, bundle);\r\n\t\t}\r\n\r\n\t\tcopyParameters(prefix, config, System.getProperties());\r\n\r\n\t\treturn config;\r\n\t}", "test_case": "@Test\r\n\tpublic void getConfigurationFromStream() throws ConfigurationException,\r\n\t\t\tIOException {\r\n\t\tInputStream stream = null;\r\n\r\n\t\ttry {\r\n\t\t\tstream = this.getClass().getClassLoader()\r\n\t\t\t\t\t.getResourceAsStream(\"elk.properties\");\r\n\r\n\t\t\tBaseConfiguration config = new ConfigurationFactory()\r\n\t\t\t\t\t.getConfiguration(stream, \"elk\", BaseConfiguration.class);\r\n\r\n\t\t\tassertEquals(3, config.getParameterNames().size());\r\n\t\t} finally {\r\n\t\t\tIOUtils.closeQuietly(stream);\r\n\t\t}\r\n\t}"} {"description": "[\"('', '// Add a token for end of sentence\\\\n')\"]", "focal_method": "public String[] tokenize(String s) {\r\n\tInputStream modelIn = null;\r\n\t\r\n\tList tokens = new ArrayList();\r\n\ttry {\r\n\t modelIn = new FileInputStream(sentenceModelFile);\r\n\t SentenceModel model = new SentenceModel(modelIn);\r\n\t \r\n\t SentenceDetector sentenceDetector = new SentenceDetectorME(model);\r\n\t String sentences[] = sentenceDetector.sentDetect(s);\r\n\t \r\n\t for (String sentence : sentences) {\r\n\t\tList toks = \r\n\t\t Arrays.asList(tokenizeHelper(sentence));\r\n\t\ttokens.addAll(toks);\r\n\t\t// Add a token for end of sentence\r\n\t\ttokens.add(\"\");\r\n\t }\r\n\t} \r\n\tcatch (IOException e) {\r\n\t System.out.println(\"Error with loading Sentence model...\");\r\n\t e.printStackTrace();\r\n\t}\r\n\tfinally {\r\n\t if (modelIn != null) {\r\n\t\ttry {\r\n\t\t modelIn.close();\r\n\t\t}\r\n\t\tcatch (IOException e) {\r\n\t\t}\r\n\t }\r\n\t}\r\n \r\n\treturn tokens.toArray(new String[tokens.size()]);\r\n }", "test_case": "@Test\r\n public void testTokenization() {\r\n\tString text = \"This, is the first sentence. This: is the second sentence \";\r\n\t\r\n\tString[] tokenizedText = tokenizer.tokenize(text);\r\n\tSystem.out.println(Arrays.toString(tokenizedText));\r\n }"} {"description": "Creates a new codeFormattedEntityIdRowFiltercode instance The row key format must have an encoding of @link RowKeyEncodingFORMATTED and if there is a salt defined it must not be set to suppress key materialization If key materialization were suppressed then there would be no component fields to match against @param rowKeyFormat the row key format of the table this filter will be used on @param components the components to match on with @code nulls indicating a match on any value If fewer than the number of components defined in the row key format are supplied the rest will be filled in as @code null Fill in null for any components defined in the row key format that have not been passed in as components for the filter This effectively makes a prefix filter looking at only the components defined at the beginning of the EntityId", "focal_method": "b'/**\\n * Creates a new FormattedEntityIdRowFilter instance. The row key\\n * format must have an encoding of {@link RowKeyEncoding#FORMATTED}, and if\\n * there is a salt defined, it must not be set to suppress key\\n * materialization. If key materialization were suppressed, then there would\\n * be no component fields to match against.\\n *\\n * @param rowKeyFormat the row key format of the table this filter will be used on\\n * @param components the components to match on, with {@code null}s indicating\\n * a match on any value. If fewer than the number of components defined in\\n * the row key format are supplied, the rest will be filled in as {@code\\n * null}.\\n */'public FormattedEntityIdRowFilter(RowKeyFormat2 rowKeyFormat, Object... components) {\r\n Preconditions.checkNotNull(rowKeyFormat, \"RowKeyFormat must be specified\");\r\n Preconditions.checkArgument(rowKeyFormat.getEncoding().equals(RowKeyEncoding.FORMATTED),\r\n \"FormattedEntityIdRowFilter only works with formatted entity IDs\");\r\n if (null != rowKeyFormat.getSalt()) {\r\n Preconditions.checkArgument(!rowKeyFormat.getSalt().getSuppressKeyMaterialization(),\r\n \"FormattedEntityIdRowFilter only works with materialized keys\");\r\n }\r\n Preconditions.checkNotNull(components, \"At least one component must be specified\");\r\n Preconditions.checkArgument(components.length > 0, \"At least one component must be specified\");\r\n Preconditions.checkArgument(components.length <= rowKeyFormat.getComponents().size(),\r\n \"More components given (%s) than are in the row key format specification (%s)\",\r\n components.length, rowKeyFormat.getComponents().size());\r\n\r\n mRowKeyFormat = rowKeyFormat;\r\n\r\n // Fill in 'null' for any components defined in the row key format that have\r\n // not been passed in as components for the filter. This effectively makes\r\n // a prefix filter, looking at only the components defined at the beginning\r\n // of the EntityId.\r\n if (components.length < rowKeyFormat.getComponents().size()) {\r\n mComponents = new Object[rowKeyFormat.getComponents().size()];\r\n for (int i = 0; i < components.length; i++) {\r\n mComponents[i] = components[i];\r\n }\r\n } else {\r\n mComponents = components;\r\n }\r\n }", "test_case": "@Test\r\n public void testFormattedEntityIdRowFilter() throws Exception {\r\n FormattedEntityIdRowFilter filter = createFilter(mRowKeyFormat, 100, null, \"value\");\r\n runTest(mRowKeyFormat, filter, mFactory, INCLUDE, 100, 2000L, \"value\");\r\n runTest(mRowKeyFormat, filter, mFactory, EXCLUDE, 100, null, null);\r\n runTest(mRowKeyFormat, filter, mFactory, EXCLUDE, 0, null, null);\r\n }"} {"description": "[\"('/** {@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')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public Filter toHBaseFilter(Context context) throws IOException {\r\n // In the case that we have enough information to generate a prefix, we will\r\n // construct a PrefixFilter that is AND'ed with the RowFilter. This way,\r\n // when the scan passes the end of the prefix, it can end the filtering\r\n // process quickly.\r\n boolean addPrefixFilter = false;\r\n ByteArrayOutputStream prefixBytes = new ByteArrayOutputStream();\r\n\r\n // Define a regular expression that effectively creates a mask for the row\r\n // key based on the key format and the components passed in. Prefix hashes\r\n // are skipped over, and null components match any value.\r\n // ISO-8859-1 is used so that numerals map to valid characters\r\n // see http://stackoverflow.com/a/1387184\r\n\r\n // Use the embedded flag (?s) to turn on single-line mode; this makes the\r\n // '.' match on line terminators. The RegexStringComparator uses the DOTALL\r\n // flag during construction, but it does not use that flag upon\r\n // deserialization. This bug has been fixed in HBASE-5667, part of the 0.95\r\n // release.\r\n StringBuilder regex = new StringBuilder(\"(?s)^\"); // ^ matches the beginning of the string\r\n if (null != mRowKeyFormat.getSalt()) {\r\n if (mRowKeyFormat.getSalt().getHashSize() > 0) {\r\n // If all of the components included in the hash have been specified,\r\n // then match on the value of the hash\r\n Object[] prefixComponents =\r\n getNonNullPrefixComponents(mComponents, mRowKeyFormat.getRangeScanStartIndex());\r\n if (prefixComponents.length == mRowKeyFormat.getRangeScanStartIndex()) {\r\n ByteArrayOutputStream tohash = new ByteArrayOutputStream();\r\n for (Object component : prefixComponents) {\r\n byte[] componentBytes = toBytes(component);\r\n tohash.write(componentBytes, 0, componentBytes.length);\r\n }\r\n byte[] hashed = Arrays.copyOfRange(Hasher.hash(tohash.toByteArray()), 0,\r\n mRowKeyFormat.getSalt().getHashSize());\r\n for (byte hashedByte : hashed) {\r\n regex.append(String.format(\"\\\\x%02x\", hashedByte & 0xFF));\r\n }\r\n\r\n addPrefixFilter = true;\r\n // Write the hashed bytes to the prefix buffer\r\n prefixBytes.write(hashed, 0, hashed.length);\r\n } else {\r\n // match any character exactly 'hash size' number of times\r\n regex.append(\".{\").append(mRowKeyFormat.getSalt().getHashSize()).append(\"}\");\r\n }\r\n }\r\n }\r\n // Only add to the prefix buffer until we hit a null component. We do this\r\n // here, because the prefix is going to expect to have 0x00 component\r\n // terminators, which we put in during this loop but not in the loop above.\r\n boolean hitNullComponent = false;\r\n for (int i = 0; i < mComponents.length; i++) {\r\n final Object component = mComponents[i];\r\n switch (mRowKeyFormat.getComponents().get(i).getType()) {\r\n case INTEGER:\r\n if (null == component) {\r\n // null integers can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_INT).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Integer) component);\r\n // match each byte in the integer using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case LONG:\r\n if (null == component) {\r\n // null longs can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_LONG).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Long) component);\r\n // match each byte in the long using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case STRING:\r\n if (null == component) {\r\n // match any non-zero character at least once, followed by a zero\r\n // delimiter, or match nothing at all in case the component was at\r\n // the end of the EntityId and skipped entirely\r\n regex.append(\"([^\\\\x00]+\\\\x00)?\");\r\n hitNullComponent = true;\r\n } else {\r\n // FormattedEntityId converts a string component to UTF-8 bytes to\r\n // create the HBase key. RegexStringComparator will convert the\r\n // value it sees (ie, the HBase key) to a string using ISO-8859-1.\r\n // Therefore, we need to write ISO-8859-1 characters to our regex so\r\n // that the comparison happens correctly.\r\n byte[] utfBytes = toBytes((String) component);\r\n String isoString = new String(utfBytes, Charsets.ISO_8859_1);\r\n regex.append(isoString).append(\"\\\\x00\");\r\n if (!hitNullComponent) {\r\n prefixBytes.write(utfBytes, 0, utfBytes.length);\r\n prefixBytes.write((byte) 0);\r\n }\r\n }\r\n break;\r\n default:\r\n throw new IllegalStateException(\"Unknown component type: \"\r\n + mRowKeyFormat.getComponents().get(i).getType());\r\n }\r\n }\r\n regex.append(\"$\"); // $ matches the end of the string\r\n\r\n final RowFilter regexRowFilter =\r\n SchemaPlatformBridge.get().createRowFilterFromRegex(CompareOp.EQUAL, regex.toString());\r\n if (addPrefixFilter) {\r\n return new FilterList(new PrefixFilter(prefixBytes.toByteArray()), regexRowFilter);\r\n }\r\n return regexRowFilter;\r\n }", "test_case": "@Test\r\n public void testLatinNewlineCharacterInclusion() throws Exception {\r\n RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG);\r\n EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);\r\n\r\n // Create and serialize a filter.\r\n FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 10);\r\n byte[] serializedFilter = filter.toHBaseFilter(null).toByteArray();\r\n\r\n // Deserialize the filter.\r\n Filter deserializedFilter = FilterList.parseFrom(serializedFilter);\r\n\r\n // Filter an entity with the deserialized filter.\r\n EntityId entityId = factory.getEntityId(10, 10L);\r\n byte[] hbaseKey = entityId.getHBaseRowKey();\r\n boolean filtered = deserializedFilter.filterRowKey(hbaseKey, 0, hbaseKey.length);\r\n assertEquals(INCLUDE, filtered);\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *

\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n * \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSingleHost() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/instance/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void badHashSizeRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(badHashSizeRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Valid hash sizes are between 1 and 16\", ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void repeatedNamesRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(repeatedNamesRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Component name already used.\", ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void tooHighRangeScanIndexRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(tooHighRangeScanIndexRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\r\n \"Invalid range scan index. Range scans are supported starting with the second component.\",\r\n ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void zeroNullableIndexRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(zeroNullableIndexRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\r\n \"Invalid index for nullable component. The second component onwards can be set to null.\",\r\n ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void tooHighNullableScanIndexRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(tooHighNullableIndexRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\r\n \"Invalid index for nullable component. The second component onwards can be set to null.\",\r\n ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\\\\\\\n * description record.\\\\\\\\n *\\\\\\\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\\\\\\\n * of the table.\\\\\\\\n * @return A new table layout.\\\\\\\\n * @throws InvalidLayoutException If the descriptor is invalid.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates and returns a new KijiTableLayout instance as specified by an Avro TableLayoutDesc\\n * description record.\\n *\\n * @param layout The Avro TableLayoutDesc descriptor record that describes the actual layout.\\n * of the table.\\n * @return A new table layout.\\n * @throws InvalidLayoutException If the descriptor is invalid.\\n */'public static KijiTableLayout newLayout(TableLayoutDesc layout) throws InvalidLayoutException {\r\n return new KijiTableLayout(layout, null);\r\n }", "test_case": "@Test\r\n public void emptyCompNameRKF() throws InvalidLayoutException {\r\n final TableLayoutDesc desc = TableLayoutDesc.newBuilder()\r\n .setName(\"table_name\")\r\n .setKeysFormat(emptyCompNameRowKeyFormat())\r\n .setVersion(TABLE_LAYOUT_VERSION)\r\n .build();\r\n try {\r\n final KijiTableLayout ktl = KijiTableLayout.newLayout(desc);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Names should begin with a letter followed by a combination of letters, numbers \"\r\n + \"and underscores.\", ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Build a new table layout descriptor.\\\\\\\\n *\\\\\\\\n * @return a built table layout descriptor.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Build a new table layout descriptor.\\n *\\n * @return a built table layout descriptor.\\n */'public TableLayoutDesc build() {\r\n return mDescBuilder.build();\r\n }", "test_case": "@Test\r\n public void testTableLayoutSafeMutation() throws IOException {\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(TEST_LAYOUT);\r\n final TableLayoutDesc tld = layout.getDesc();\r\n final TableLayoutBuilder tlb = new TableLayoutBuilder(tld, getKiji());\r\n tld.setName(\"blastoise\");\r\n final TableLayoutDesc tldBuilt = tlb.build();\r\n assertFalse(tld.getName().equals(tldBuilt.getName()));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Register a reader schema to a column.\\\\\\\\n *\\\\\\\\n * @param columnName at which to register the schema.\\\\\\\\n * @param schema to register.\\\\\\\\n * @throws IOException If the parameters are invalid.\\\\\\\\n * @return this.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Register a reader schema to a column.\\n *\\n * @param columnName at which to register the schema.\\n * @param schema to register.\\n * @throws IOException If the parameters are invalid.\\n * @return this.\\n */'public TableLayoutBuilder withReader(\r\n final KijiColumnName columnName,\r\n final Schema schema)\r\n throws IOException {\r\n return withSchema(columnName, schema, SchemaRegistrationType.READER);\r\n }", "test_case": "@Test\r\n public void testSchemaRegistrationAtBadColumns() throws IOException {\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(TEST_LAYOUT);\r\n final TableLayoutBuilder tlb = new TableLayoutBuilder(layout.getDesc(), getKiji());\r\n final Schema.Parser p = new Schema.Parser();\r\n Schema stringSchema = p.parse(\"\\\"string\\\"\");\r\n\r\n // Unqualified group family\r\n try {\r\n tlb.withReader(KijiColumnName.create(\"profile\"), stringSchema);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (NoSuchColumnException nsce) {\r\n assertEquals(\"Table 'table_name' has no column 'profile'.\", nsce.getMessage());\r\n }\r\n\r\n // Fully qualified map family\r\n try {\r\n tlb.withReader(KijiColumnName.create(\"heroism:mordor\"), stringSchema);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"A fully qualified map-type column name was provided.\", ile.getMessage());\r\n }\r\n\r\n // Nonexistent column\r\n try {\r\n tlb.withReader(KijiColumnName.create(\"info:name\"), stringSchema);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (NoSuchColumnException nsce) {\r\n assertEquals(\"Table 'table_name' has no column 'info:name'.\", nsce.getMessage());\r\n }\r\n\r\n // FINAL column\r\n try {\r\n tlb.withReader(KijiColumnName.create(\"clans\"), stringSchema);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (InvalidLayoutException ile) {\r\n assertEquals(\"Final or non-AVRO column schema cannot be modified.\", ile.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Adds the jars from a directory into the distributed cache of a job.\\\\\\\\n *\\\\\\\\n * @param job The job to configure.\\\\\\\\n * @param jarDirectory A path to a directory of jar files.\\\\\\\\n * @throws IOException If there is a problem reading from the file system.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Adds the jars from a directory into the distributed cache of a job.\\n *\\n * @param job The job to configure.\\n * @param jarDirectory A path to a directory of jar files.\\n * @throws IOException If there is a problem reading from the file system.\\n */'public static void addJarsToDistributedCache(Job job, String jarDirectory) throws IOException {\r\n addJarsToDistributedCache(job, new File(jarDirectory));\r\n }", "test_case": "@Test\r\n public void testJarsDeDupe() throws IOException {\r\n // Jar list should de-dupe to {\"myjar_a, \"myjar_b\", \"myjar_0\", \"myjar_1\"}\r\n Set dedupedJarNames = new HashSet(4);\r\n dedupedJarNames.add(\"myjar_a.jar\");\r\n dedupedJarNames.add(\"myjar_b.jar\");\r\n dedupedJarNames.add(\"myjar_0.jar\");\r\n dedupedJarNames.add(\"myjar_1.jar\");\r\n\r\n Job job = new Job();\r\n\r\n List someJars = new ArrayList();\r\n // Some unique jar names.\r\n someJars.add(\"/somepath/myjar_a.jar\");\r\n someJars.add(\"/another/path/myjar_b.jar\");\r\n someJars.add(\"/myjar_0.jar\");\r\n\r\n // Duplicate jars.\r\n someJars.add(\"/another/path/myjar_b.jar\");\r\n someJars.add(\"/yet/another/path/myjar_b.jar\");\r\n\r\n job.getConfiguration().set(CONF_TMPJARS, StringUtils.join(someJars, \",\"));\r\n\r\n // Now add some duplicate jars from mTempDir.\r\n assertEquals(0, mTempDir.getRoot().list().length);\r\n createTestJars(\"myjar_0.jar\", \"myjar_1.jar\");\r\n assertEquals(2, mTempDir.getRoot().list().length);\r\n DistributedCacheJars.addJarsToDistributedCache(job, mTempDir.getRoot());\r\n\r\n // Confirm each jar appears in de-dupe list exactly once.\r\n String listedJars = job.getConfiguration().get(CONF_TMPJARS);\r\n String[] jars = listedJars.split(\",\");\r\n for (String jar : jars) {\r\n // Check that path terminates in an expected jar.\r\n Path p = new Path(jar);\r\n assertTrue(dedupedJarNames.contains(p.getName()));\r\n dedupedJarNames.remove(p.getName());\r\n }\r\n assertEquals(0, dedupedJarNames.size());\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public void close() throws IOException {\r\n mVersionPager.close();\r\n }", "test_case": "@Test\r\n public void testQualifiersIterator() throws IOException {\r\n final EntityId eid = mTable.getEntityId(\"me\");\r\n\r\n final KijiDataRequest dataRequest = KijiDataRequest.builder()\r\n .addColumns(ColumnsDef.create()\r\n .withMaxVersions(HConstants.ALL_VERSIONS).withPageSize(1).addFamily(\"jobs\"))\r\n .build();\r\n\r\n final KijiRowData row = mReader.get(eid, dataRequest);\r\n final ColumnVersionIterator it =\r\n new ColumnVersionIterator(row, \"jobs\", \"j2\", 3);\r\n try {\r\n long counter = 5;\r\n for (Entry entry : it) {\r\n assertEquals(counter, (long) entry.getKey());\r\n counter -= 1;\r\n }\r\n } finally {\r\n it.close();\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSingleHostGroupColumn() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/instance/table/family:qualifier\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"family:qualifier\", uri.getColumns().get(0).getName());\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public boolean equals(Object object) {\r\n if (object instanceof KijiCell) {\r\n final KijiCell that = (KijiCell) object;\r\n return this.mColumn.equals(that.mColumn)\r\n && (this.mTimestamp == that.mTimestamp)\r\n && this.mDecodedCell.equals(that.mDecodedCell);\r\n } else {\r\n return false;\r\n }\r\n }", "test_case": "@Test\r\n public void testEquals() {\r\n final KijiCell cell1 =\r\n KijiCell.create(KijiColumnName.create(\"family\", \"qualifier\"), 1234L,\r\n new DecodedCell(Schema.create(Schema.Type.INT), 31415));\r\n\r\n final KijiCell cell2 =\r\n KijiCell.create(KijiColumnName.create(\"family\", \"qualifier\"), 1234L,\r\n new DecodedCell(Schema.create(Schema.Type.INT), 31415));\r\n\r\n Assert.assertTrue(cell1.equals(cell2));\r\n Assert.assertTrue(cell2.equals(cell1));\r\n\r\n Assert.assertEquals(cell1.hashCode(), cell2.hashCode());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new KijiColumnName from a family and qualifier.\\\\\\\\n *\\\\\\\\n * @param family Family of the Kiji column for which to create a name.\\\\\\\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\\\\\\\n * @return a new KijiColumnName from the given family and qualifier.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new KijiColumnName from a family and qualifier.\\n *\\n * @param family Family of the Kiji column for which to create a name.\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\n * @return a new KijiColumnName from the given family and qualifier.\\n */'public static KijiColumnName create(\r\n final String family,\r\n final String qualifier\r\n ) {\r\n return new KijiColumnName(family, qualifier);\r\n }", "test_case": "@Test\r\n public void testNull() {\r\n try {\r\n KijiColumnName.create(null);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Column name may not be null. At least specify family\", iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new KijiColumnName from a family and qualifier.\\\\\\\\n *\\\\\\\\n * @param family Family of the Kiji column for which to create a name.\\\\\\\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\\\\\\\n * @return a new KijiColumnName from the given family and qualifier.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new KijiColumnName from a family and qualifier.\\n *\\n * @param family Family of the Kiji column for which to create a name.\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\n * @return a new KijiColumnName from the given family and qualifier.\\n */'public static KijiColumnName create(\r\n final String family,\r\n final String qualifier\r\n ) {\r\n return new KijiColumnName(family, qualifier);\r\n }", "test_case": "@Test\r\n public void testNullFamily() {\r\n try {\r\n KijiColumnName.create(null, \"qualifier\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Family name may not be null.\", iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new KijiColumnName from a family and qualifier.\\\\\\\\n *\\\\\\\\n * @param family Family of the Kiji column for which to create a name.\\\\\\\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\\\\\\\n * @return a new KijiColumnName from the given family and qualifier.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new KijiColumnName from a family and qualifier.\\n *\\n * @param family Family of the Kiji column for which to create a name.\\n * @param qualifier Qualifier of the Kiji column for which to create a name.\\n * @return a new KijiColumnName from the given family and qualifier.\\n */'public static KijiColumnName create(\r\n final String family,\r\n final String qualifier\r\n ) {\r\n return new KijiColumnName(family, qualifier);\r\n }", "test_case": "@Test\r\n public void testInvalidFamilyName() {\r\n try {\r\n KijiColumnName.create(\"1:qualifier\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiInvalidNameException kine) {\r\n assertEquals(\"Invalid family name: 1 Name must match pattern: [a-zA-Z_][a-zA-Z0-9_]*\",\r\n kine.getMessage());\r\n }\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public boolean equals(Object otherObj) {\r\n if (otherObj == this) {\r\n return true;\r\n } else if (null == otherObj) {\r\n return false;\r\n } else if (!otherObj.getClass().equals(getClass())) {\r\n return false;\r\n }\r\n final KijiColumnName other = (KijiColumnName) otherObj;\r\n return other.getFamily().equals(mFamily) && Objects.equal(other.getQualifier(), mQualifier);\r\n }", "test_case": "@Test\r\n public void testEquals() {\r\n KijiColumnName columnA = KijiColumnName.create(\"family\", \"qualifier1\");\r\n KijiColumnName columnC = KijiColumnName.create(\"family\", null);\r\n KijiColumnName columnD = KijiColumnName.create(\"family\", \"qualifier2\");\r\n assertTrue(columnA.equals(columnA)); // reflexive\r\n assertFalse(columnA.equals(columnC) || columnC.equals(columnA));\r\n assertFalse(columnA.equals(columnD) || columnD.equals(columnA));\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int hashCode() {\r\n return new HashCodeBuilder().append(mFamily).append(mQualifier).toHashCode();\r\n }", "test_case": "@Test\r\n public void testHashCode() {\r\n KijiColumnName columnA = KijiColumnName.create(\"family\", \"qualifier\");\r\n KijiColumnName columnB = KijiColumnName.create(\"family:qualifier\");\r\n assertEquals(columnA.hashCode(), columnB.hashCode());\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int compareTo(KijiColumnName otherObj) {\r\n final int comparison = this.mFamily.compareTo(otherObj.mFamily);\r\n if (0 == comparison) {\r\n return (this.isFullyQualified() ? mQualifier : \"\")\r\n .compareTo(otherObj.isFullyQualified() ? otherObj.getQualifier() : \"\");\r\n } else {\r\n return comparison;\r\n }\r\n }", "test_case": "@Test\r\n public void testCompareTo() {\r\n KijiColumnName columnA = KijiColumnName.create(\"family\");\r\n KijiColumnName columnB = KijiColumnName.create(\"familyTwo\");\r\n KijiColumnName columnC = KijiColumnName.create(\"family:qualifier\");\r\n assertTrue(0 == columnA.compareTo(columnA));\r\n assertTrue(0 > columnA.compareTo(columnB) && 0 < columnB.compareTo(columnA));\r\n assertTrue(0 > columnA.compareTo(columnC) && 0 < columnC.compareTo(columnA));\r\n assertTrue(0 < columnB.compareTo(columnC) && 0 > columnC.compareTo(columnB));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a new {@link KijiDataRequestBuilder}. Use this to configure a KijiDataRequest,\\\\\\\\n * then create one with the {@link KijiDataRequestBuilder#build()} method.\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a new {@link KijiDataRequestBuilder}. Use this to configure a KijiDataRequest,\\n * then create one with the {@link KijiDataRequestBuilder#build()} method.\\n *\\n * @return a new KijiDataRequestBuilder.\\n */'public static KijiDataRequestBuilder builder() {\r\n return new KijiDataRequestBuilder();\r\n }", "test_case": "@Test\r\n public void testDataRequestEquals() {\r\n KijiDataRequestBuilder builder0 = KijiDataRequest.builder()\r\n .withTimeRange(3L, 4L);\r\n builder0.newColumnsDef().withMaxVersions(2).addFamily(\"foo\");\r\n builder0.newColumnsDef().withMaxVersions(5).add(\"bar\", \"baz\");\r\n KijiDataRequest request0 = builder0.build();\r\n\r\n KijiDataRequestBuilder builder1 = KijiDataRequest.builder()\r\n .withTimeRange(3L, 4L);\r\n builder1.newColumnsDef().withMaxVersions(2).addFamily(\"foo\");\r\n builder1.newColumnsDef().withMaxVersions(5).add(\"bar\", \"baz\");\r\n KijiDataRequest request1 = builder1.build();\r\n\r\n KijiDataRequestBuilder builder2 = KijiDataRequest.builder()\r\n .withTimeRange(3L, 4L);\r\n builder2.newColumnsDef().withMaxVersions(2).addFamily(\"foo\");\r\n builder2.newColumnsDef().withMaxVersions(5).add(\"car\", \"bot\");\r\n KijiDataRequest request2 = builder2.build();\r\n\r\n KijiDataRequestBuilder builder3 = KijiDataRequest.builder()\r\n .withTimeRange(3L, 4L);\r\n builder3.newColumnsDef().withMaxVersions(2).addFamily(\"foo\");\r\n builder3.newColumnsDef().withMaxVersions(3).add(\"car\", \"bot\");\r\n KijiDataRequest request3 = builder3.build();\r\n\r\n assertEquals(request0, request1);\r\n assertThat(new Object(), is(not((Object) request0)));\r\n assertThat(request0, is(not(request2)));\r\n assertThat(request2, is(not(request3)));\r\n }"} {"description": "Creates a new data request representing the union of this data request and the data request specified as an argument pThis method merges data requests using the widestpossible treatment of parameters This may result in cells being included in the result set that were not specified by either data set For example if request A includes ttinfofoott from time range 400 700 and request B includes ttinfobartt from time range 500 900 then AmergeB will yield a data request for both columns with time range 400 900p pMore precisely merges are handled in the following wayp ul liThe output time interval encompasses both data requests time intervalsli liAll columns associated with both data requests will be includedli liWhen maxVersions differs for the same column in both requests the greater value is chosenli liWhen pageSize differs for the same column in both requests the lesser value is chosenli liIf either request contains KijiColumnFilter definitions attached to a column this is considered an error and a RuntimeException is thrown Data requests with filters cannot be mergedli liIf one data request includes an entire column family ttfoott and the other data request includes a column within that family ttfoobartt the entire family will be requested and properties such as max versions etc for the familywide request will be merged with the column to ensure the request is as wide as possibleli ul @param other another data request to include as a part of this one @return A new KijiDataRequest instance including the union of this data request and the argument request maptype families requested First include any requests for column families And while were at it check for filters We dont know how to merge these Loop through any requests on our end that have the same family Include requests for column families on our side that arent present on theirs And while were at it check for filters We dont know how to merge these Loop through requests on their end that have the same family Now include individual columns from their side If we have corresponding definitions for the same columns merge them If the column is already covered by a request for a family ignore the individual column its already been merged We dont have a request for otherColumn so add it Now grab any columns that were present in our data request but missed entirely in the other sides data request Column in our list but not the other sides list", "focal_method": "b\"/**\\n * Creates a new data request representing the union of this data request and the\\n * data request specified as an argument.\\n *\\n *

This method merges data requests using the widest-possible treatment of\\n * parameters. This may result in cells being included in the result set that\\n * were not specified by either data set. For example, if request A includes info:foo\\n * from time range [400, 700), and request B includes info:bar from time range\\n * [500, 900), then A.merge(B) will yield a data request for both columns, with time\\n * range [400, 900).

\\n *\\n *

More precisely, merges are handled in the following way:

\\n *
    \\n *
  • The output time interval encompasses both data requests' time intervals.
  • \\n *
  • All columns associated with both data requests will be included.
  • \\n *
  • When maxVersions differs for the same column in both requests, the greater\\n * value is chosen.
  • \\n *
  • When pageSize differs for the same column in both requests, the lesser value\\n * is chosen.
  • \\n *
  • If either request contains KijiColumnFilter definitions attached to a column,\\n * this is considered an error, and a RuntimeException is thrown. Data requests with\\n * filters cannot be merged.
  • \\n *
  • If one data request includes an entire column family (foo:*) and\\n * the other data request includes a column within that family (foo:bar),\\n * the entire family will be requested, and properties such as max versions, etc.\\n * for the family-wide request will be merged with the column to ensure the request\\n * is as wide as possible.
  • \\n *
\\n *\\n * @param other another data request to include as a part of this one.\\n * @return A new KijiDataRequest instance, including the union of this data request\\n * and the argument request.\\n */\"public KijiDataRequest merge(KijiDataRequest other) {\r\n if (null == other) {\r\n throw new IllegalArgumentException(\"Input data request cannot be null.\");\r\n }\r\n\r\n List outCols = new ArrayList();\r\n Set families = new HashSet(); // map-type families requested.\r\n\r\n // First, include any requests for column families.\r\n for (Column otherCol : other.getColumns()) {\r\n if (otherCol.getFilter() != null) {\r\n // And while we're at it, check for filters. We don't know how to merge these.\r\n throw new IllegalStateException(\"Invalid merge request: \"\r\n + otherCol.getName() + \" has a filter.\");\r\n }\r\n\r\n if (otherCol.getQualifier() == null) {\r\n Column outFamily = otherCol;\r\n // Loop through any requests on our end that have the same family.\r\n for (Column myCol : getColumns()) {\r\n if (myCol.getFamily().equals(otherCol.getFamily())) {\r\n outFamily = mergeColumn(myCol.getFamily(), null, myCol, outFamily);\r\n }\r\n }\r\n\r\n outCols.add(outFamily);\r\n families.add(outFamily.getFamily());\r\n }\r\n }\r\n\r\n // Include requests for column families on our side that aren't present on their's.\r\n for (Column myCol : getColumns()) {\r\n if (myCol.getFilter() != null) {\r\n // And while we're at it, check for filters. We don't know how to merge these.\r\n throw new IllegalStateException(\"Invalid merge request: \"\r\n + myCol.getName() + \" has a filter.\");\r\n }\r\n\r\n if (myCol.getQualifier() == null && !families.contains(myCol.getFamily())) {\r\n Column outFamily = myCol;\r\n // Loop through requests on their end that have the same family.\r\n for (Column otherCol : other.getColumns()) {\r\n if (otherCol.getFamily().equals(myCol.getFamily())) {\r\n outFamily = mergeColumn(myCol.getFamily(), null, outFamily, otherCol);\r\n }\r\n }\r\n\r\n outCols.add(outFamily);\r\n families.add(outFamily.getFamily());\r\n }\r\n }\r\n\r\n\r\n // Now include individual columns from their side. If we have corresponding definitions\r\n // for the same columns, merge them. If the column is already covered by a request\r\n // for a family, ignore the individual column (it's already been merged).\r\n for (Column otherCol : other.getColumns()) {\r\n if (otherCol.getQualifier() != null && !families.contains(otherCol.getFamily())) {\r\n Column myCol = getColumn(otherCol.getFamily(), otherCol.getQualifier());\r\n if (null == myCol) {\r\n // We don't have a request for otherColumn, so add it.\r\n outCols.add(otherCol);\r\n } else {\r\n outCols.add(mergeColumn(myCol.getFamily(), myCol.getQualifier(), myCol, otherCol));\r\n }\r\n }\r\n }\r\n\r\n // Now grab any columns that were present in our data request, but missed entirely\r\n // in the other side's data request.\r\n for (Column myCol : getColumns()) {\r\n if (myCol.getQualifier() != null && !families.contains(myCol.getFamily())) {\r\n Column otherCol = other.getColumn(myCol.getFamily(), myCol.getQualifier());\r\n if (null == otherCol) {\r\n // Column in our list but not the other side's list.\r\n outCols.add(myCol);\r\n }\r\n }\r\n }\r\n\r\n long outMinTs = Math.min(getMinTimestamp(), other.getMinTimestamp());\r\n long outMaxTs = Math.max(getMaxTimestamp(), other.getMaxTimestamp());\r\n\r\n return new KijiDataRequest(outCols, outMinTs, outMaxTs);\r\n }", "test_case": "@Test\r\n public void testMerge() {\r\n KijiDataRequestBuilder builder1 = KijiDataRequest.builder().withTimeRange(3, 4);\r\n builder1.newColumnsDef().withMaxVersions(2).add(\"foo\", \"bar\");\r\n KijiDataRequest first = builder1.build();\r\n\r\n KijiDataRequestBuilder builder2 = KijiDataRequest.builder().withTimeRange(2, 4);\r\n builder2.newColumnsDef().add(\"baz\", \"bot\");\r\n builder2.newColumnsDef().withMaxVersions(6).add(\"foo\", \"bar\");\r\n KijiDataRequest second = builder2.build();\r\n\r\n KijiDataRequest merged = first.merge(second);\r\n assertTrue(\"merge() cannot mutate the object in place\", first != merged);\r\n\r\n KijiDataRequest.Column fooBarColumnRequest = merged.getColumn(\"foo\", \"bar\");\r\n assertNotNull(\"Missing column foo:bar from merged request\", fooBarColumnRequest);\r\n assertEquals(\"Max versions was not increased\", 6, fooBarColumnRequest.getMaxVersions());\r\n assertEquals(\"Time range was not extended\", 2L, merged.getMinTimestamp());\r\n assertEquals(4L, merged.getMaxTimestamp());\r\n\r\n KijiDataRequest.Column bazBotColumnRequest = merged.getColumn(\"baz\", \"bot\");\r\n assertNotNull(\"Missing column from merged-in request\", bazBotColumnRequest);\r\n\r\n KijiDataRequest symmetricMerged = second.merge(first);\r\n assertEquals(\"Merge must be symmetric\", merged, symmetricMerged);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a new {@link KijiDataRequestBuilder}. Use this to configure a KijiDataRequest,\\\\\\\\n * then create one with the {@link KijiDataRequestBuilder#build()} method.\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Creates a new {@link KijiDataRequestBuilder}. Use this to configure a KijiDataRequest,\\n * then create one with the {@link KijiDataRequestBuilder#build()} method.\\n *\\n * @return a new KijiDataRequestBuilder.\\n */'public static KijiDataRequestBuilder builder() {\r\n return new KijiDataRequestBuilder();\r\n }", "test_case": "@Test\r\n public void testInvalidColumnSpec() {\r\n // The user really wants 'builder.columns().add(\"family\", \"qualifier\")'.\r\n // This will throw an exception.\r\n try {\r\n KijiDataRequest.builder().newColumnsDef().addFamily(\"family:qualifier\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiInvalidNameException kine) {\r\n assertEquals(\r\n \"Invalid family name: family:qualifier Name must match pattern: [a-zA-Z_][a-zA-Z0-9_]*\",\r\n kine.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSingleHostDefaultInstance() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/default/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1, uri.getZookeeperQuorum().size());\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"default\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "Construct a new KijiDataRequest based on the configuration specified in this builder and its associated column builders pAfter calling build you may not use the builder anymorep @return a new KijiDataRequest object containing the column requests associated with this KijiDataRequestBuilder Entire families for which a definition has been recorded Fullyqualified columns for which a definition has been recorded Families of fullyqualified columns for which definitions have been recorded Iterate over the ColumnsDefs in the order they were added mColumnsDef is a LinkedHashSet", "focal_method": "b'/**\\n * Construct a new KijiDataRequest based on the configuration specified in this builder\\n * and its associated column builders.\\n *\\n *

After calling build(), you may not use the builder anymore.

\\n *\\n * @return a new KijiDataRequest object containing the column requests associated\\n * with this KijiDataRequestBuilder.\\n */'public KijiDataRequest build() {\r\n checkNotBuilt();\r\n mIsBuilt = true;\r\n\r\n // Entire families for which a definition has been recorded:\r\n final Set families = Sets.newHashSet();\r\n\r\n // Fully-qualified columns for which a definition has been recorded:\r\n final Set columns = Sets.newHashSet();\r\n\r\n // Families of fully-qualified columns for which definitions have been recorded:\r\n final Set familiesOfColumns = Sets.newHashSet();\r\n\r\n final List requestedColumns = Lists.newArrayList();\r\n // Iterate over the ColumnsDefs in the order they were added (mColumnsDef is a LinkedHashSet).\r\n for (ColumnsDef columnsDef : mColumnsDefs) {\r\n for (KijiDataRequest.Column column : columnsDef.buildColumns()) {\r\n if (column.getQualifier() == null) {\r\n final boolean isNotDuplicate = families.add(column.getFamily());\r\n Preconditions.checkState(isNotDuplicate,\r\n \"Duplicate definition for family '%s'.\", column.getFamily());\r\n\r\n Preconditions.checkState(!familiesOfColumns.contains(column.getFamily()),\r\n \"KijiDataRequest may not simultaneously contain definitions for family '%s' \"\r\n + \"and definitions for fully qualified columns in family '%s'.\",\r\n column.getFamily(), column.getFamily());\r\n\r\n } else {\r\n final boolean isNotDuplicate = columns.add(column.getColumnName());\r\n Preconditions.checkState(isNotDuplicate, \"Duplicate definition for column '%s'.\", column);\r\n\r\n Preconditions.checkState(!families.contains(column.getFamily()),\r\n \"KijiDataRequest may not simultaneously contain definitions for family '%s' \"\r\n + \"and definitions for fully qualified columns '%s'.\",\r\n column.getFamily(), column.getColumnName());\r\n familiesOfColumns.add(column.getFamily());\r\n }\r\n requestedColumns.add(column);\r\n }\r\n }\r\n return new KijiDataRequest(requestedColumns, mMinTimestamp, mMaxTimestamp);\r\n }", "test_case": "@Test\r\n public void testBuild() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n builder.newColumnsDef().add(\"info\", \"foo\");\r\n KijiDataRequest request = builder.build();\r\n\r\n // We should be able to use KijiDataRequest's create() method to similar effect.\r\n KijiDataRequest request2 = KijiDataRequest.create(\"info\", \"foo\");\r\n assertEquals(\"Constructions methods make different requests\", request, request2);\r\n assertTrue(\"Builder doesn't build a new object\", request != request2);\r\n\r\n assertNotNull(\"Missing info:foo!\", request.getColumn(\"info\", \"foo\"));\r\n assertNull(\"Got spurious info:missing\", request.getColumn(\"info\", \"missing\"));\r\n assertNull(\"Got spurious info: family\", request.getColumn(\"info\", null));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoRedundantColumn() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().add(\"info\", \"foo\").add(\"info\", \"foo\");\r\n fail(\"Should have thrown exception for redundant add\");\r\n } catch (IllegalArgumentException ise) {\r\n assertEquals(\"Duplicate request for column 'info:foo'.\", ise.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoNegativeMaxVer() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().withMaxVersions(-5).addFamily(\"info\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Maximum number of versions must be strictly positive, but got: -5\",\r\n iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoNegativePageSize() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().withPageSize(-5).addFamily(\"info\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Page size must be 0 (disabled) or positive, but got: null\",\r\n iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoZeroMaxVersions() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().withMaxVersions(0).addFamily(\"info\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Maximum number of versions must be strictly positive, but got: 0\",\r\n iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Construct a new KijiDataRequest based on the configuration specified in this builder\\\\\\\\n * and its associated column builders.\\\\\\\\n *\\\\\\\\n *

After calling build(), you may not use the builder anymore.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequest object containing the column requests associated\\\\\\\\n * with this KijiDataRequestBuilder.\\\\\\\\n */', '')\", \"('', '// Entire families for which a definition has been recorded:\\\\n')\", \"('', '// Fully-qualified columns for which a definition has been recorded:\\\\n')\", \"('', '// Families of fully-qualified columns for which definitions have been recorded:\\\\n')\", \"('', '// Iterate over the ColumnsDefs in the order they were added (mColumnsDef is a LinkedHashSet).\\\\n')\"]", "focal_method": "b'/**\\n * Construct a new KijiDataRequest based on the configuration specified in this builder\\n * and its associated column builders.\\n *\\n *

After calling build(), you may not use the builder anymore.

\\n *\\n * @return a new KijiDataRequest object containing the column requests associated\\n * with this KijiDataRequestBuilder.\\n */'public KijiDataRequest build() {\r\n checkNotBuilt();\r\n mIsBuilt = true;\r\n\r\n // Entire families for which a definition has been recorded:\r\n final Set families = Sets.newHashSet();\r\n\r\n // Fully-qualified columns for which a definition has been recorded:\r\n final Set columns = Sets.newHashSet();\r\n\r\n // Families of fully-qualified columns for which definitions have been recorded:\r\n final Set familiesOfColumns = Sets.newHashSet();\r\n\r\n final List requestedColumns = Lists.newArrayList();\r\n // Iterate over the ColumnsDefs in the order they were added (mColumnsDef is a LinkedHashSet).\r\n for (ColumnsDef columnsDef : mColumnsDefs) {\r\n for (KijiDataRequest.Column column : columnsDef.buildColumns()) {\r\n if (column.getQualifier() == null) {\r\n final boolean isNotDuplicate = families.add(column.getFamily());\r\n Preconditions.checkState(isNotDuplicate,\r\n \"Duplicate definition for family '%s'.\", column.getFamily());\r\n\r\n Preconditions.checkState(!familiesOfColumns.contains(column.getFamily()),\r\n \"KijiDataRequest may not simultaneously contain definitions for family '%s' \"\r\n + \"and definitions for fully qualified columns in family '%s'.\",\r\n column.getFamily(), column.getFamily());\r\n\r\n } else {\r\n final boolean isNotDuplicate = columns.add(column.getColumnName());\r\n Preconditions.checkState(isNotDuplicate, \"Duplicate definition for column '%s'.\", column);\r\n\r\n Preconditions.checkState(!families.contains(column.getFamily()),\r\n \"KijiDataRequest may not simultaneously contain definitions for family '%s' \"\r\n + \"and definitions for fully qualified columns '%s'.\",\r\n column.getFamily(), column.getColumnName());\r\n familiesOfColumns.add(column.getFamily());\r\n }\r\n requestedColumns.add(column);\r\n }\r\n }\r\n return new KijiDataRequest(requestedColumns, mMinTimestamp, mMaxTimestamp);\r\n }", "test_case": "@Test\r\n public void testEmptyOk() {\r\n assertNotNull(KijiDataRequest.builder().build());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoSettingMaxVerTwice() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().withMaxVersions(2).withMaxVersions(3).addFamily(\"info\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalStateException ise) {\r\n assertEquals(\"Cannot set max versions to 3, max versions already set to 2.\",\r\n ise.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoSettingPageSizeTwice() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().withPageSize(2).withPageSize(3).addFamily(\"info\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalStateException ise) {\r\n assertEquals(\"Cannot set page size to 3, page size already set to 2.\",\r\n ise.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Sets the time range of cells to return: [minTimestamp,\\\\\\\\n * maxTimestamp).\\\\\\\\n *\\\\\\\\n * @param minTimestamp Request cells with a timestamp at least minTimestamp.\\\\\\\\n * @param maxTimestamp Request cells with a timestamp less than maxTimestamp.\\\\\\\\n * @return This data request builder instance.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Sets the time range of cells to return: [minTimestamp,\\n * maxTimestamp).\\n *\\n * @param minTimestamp Request cells with a timestamp at least minTimestamp.\\n * @param maxTimestamp Request cells with a timestamp less than maxTimestamp.\\n * @return This data request builder instance.\\n */'public KijiDataRequestBuilder withTimeRange(long minTimestamp, long maxTimestamp) {\r\n checkNotBuilt();\r\n Preconditions.checkArgument(minTimestamp >= 0,\r\n \"minTimestamp must be positive or zero, but got: %d\", minTimestamp);\r\n Preconditions.checkArgument(maxTimestamp > minTimestamp,\r\n \"Invalid time range [%d--%d]\", minTimestamp, maxTimestamp);\r\n Preconditions.checkState(!mIsTimeRangeSet,\r\n \"Cannot set time range more than once.\");\r\n\r\n mIsTimeRangeSet = true;\r\n mMinTimestamp = minTimestamp;\r\n mMaxTimestamp = maxTimestamp;\r\n return this;\r\n }", "test_case": "@Test\r\n public void testNoSettingTimeRangeTwice() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.withTimeRange(2, 3).withTimeRange(6, 9);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalStateException ise) {\r\n assertEquals(\"Cannot set time range more than once.\", ise.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\\\\\\\n *\\\\\\\\n *

Creates an object that allows you to specify a set of related columns attached\\\\\\\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\\\\\\\n * the number of max versions.

\\\\\\\\n *\\\\\\\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\\\\\\\n * data request builder.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Return a builder for columns associated with this KijiDataRequestBuilder.\\n *\\n *

Creates an object that allows you to specify a set of related columns attached\\n * to the same KijiDataRequest that all share the same retrieval properties, like\\n * the number of max versions.

\\n *\\n * @return a new KijiDataRequestBuilder.ColumnsDef builder object associated with this\\n * data request builder.\\n */'public ColumnsDef newColumnsDef() {\r\n checkNotBuilt();\r\n final ColumnsDef c = new ColumnsDef();\r\n mColumnsDefs.add(c);\r\n return c;\r\n }", "test_case": "@Test\r\n public void testNoPropertiesAfterAdd() {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder();\r\n try {\r\n builder.newColumnsDef().add(\"info\", \"foo\").withMaxVersions(5);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IllegalStateException ise) {\r\n assertEquals(\r\n \"Properties of the columns builder cannot be changed once columns are assigned to it.\",\r\n ise.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSingleHostDefaultPort() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost/instance/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(1, uri.getZookeeperQuorum().size());\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(KijiURI.DEFAULT_ZOOKEEPER_CLIENT_PORT, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "Validates a data request against this validators table layout @param dataRequest The KijiDataRequest to validate @throws KijiDataRequestException If the data request is invalid", "focal_method": "b\"/**\\n * Validates a data request against this validator's table layout.\\n *\\n * @param dataRequest The KijiDataRequest to validate.\\n * @throws KijiDataRequestException If the data request is invalid.\\n */\"public void validate(KijiDataRequest dataRequest) {\r\n for (KijiDataRequest.Column column : dataRequest.getColumns()) {\r\n final String qualifier = column.getQualifier();\r\n final KijiTableLayout.LocalityGroupLayout.FamilyLayout fLayout =\r\n mTableLayout.getFamilyMap().get(column.getFamily());\r\n\r\n if (null == fLayout) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no family named '%s'.\",\r\n mTableLayout.getName(), column.getFamily()));\r\n }\r\n\r\n if (fLayout.isGroupType() && (null != column.getQualifier())) {\r\n if (!fLayout.getColumnMap().containsKey(qualifier)) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no column '%s'.\",\r\n mTableLayout.getName(), column.getName()));\r\n }\r\n }\r\n }\r\n }", "test_case": "@Test\r\n public void testValidate() throws InvalidLayoutException {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder().withTimeRange(2, 3);\r\n builder.newColumnsDef().withMaxVersions(1).add(\"info\", \"name\");\r\n KijiDataRequest request = builder.build();\r\n\r\n mValidator.validate(request);\r\n }"} {"description": "['(\"/**\\\\\\\\n * Validates a data request against this validator\\'s table layout.\\\\\\\\n *\\\\\\\\n * @param dataRequest The KijiDataRequest to validate.\\\\\\\\n * @throws KijiDataRequestException If the data request is invalid.\\\\\\\\n */\", \\'\\')']", "focal_method": "b\"/**\\n * Validates a data request against this validator's table layout.\\n *\\n * @param dataRequest The KijiDataRequest to validate.\\n * @throws KijiDataRequestException If the data request is invalid.\\n */\"public void validate(KijiDataRequest dataRequest) {\r\n for (KijiDataRequest.Column column : dataRequest.getColumns()) {\r\n final String qualifier = column.getQualifier();\r\n final KijiTableLayout.LocalityGroupLayout.FamilyLayout fLayout =\r\n mTableLayout.getFamilyMap().get(column.getFamily());\r\n\r\n if (null == fLayout) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no family named '%s'.\",\r\n mTableLayout.getName(), column.getFamily()));\r\n }\r\n\r\n if (fLayout.isGroupType() && (null != column.getQualifier())) {\r\n if (!fLayout.getColumnMap().containsKey(qualifier)) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no column '%s'.\",\r\n mTableLayout.getName(), column.getName()));\r\n }\r\n }\r\n }\r\n }", "test_case": "@Test\r\n public void testValidateNoSuchFamily() throws InvalidLayoutException {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder().withTimeRange(2, 3);\r\n builder.newColumnsDef().withMaxVersions(1).add(\"blahblah\", \"name\");\r\n KijiDataRequest request = builder.build();\r\n\r\n try {\r\n mValidator.validate(request);\r\n } catch (KijiDataRequestException kdre) {\r\n assertEquals(\"Table 'user' has no family named 'blahblah'.\", kdre.getMessage());\r\n }\r\n }"} {"description": "['(\"/**\\\\\\\\n * Validates a data request against this validator\\'s table layout.\\\\\\\\n *\\\\\\\\n * @param dataRequest The KijiDataRequest to validate.\\\\\\\\n * @throws KijiDataRequestException If the data request is invalid.\\\\\\\\n */\", \\'\\')']", "focal_method": "b\"/**\\n * Validates a data request against this validator's table layout.\\n *\\n * @param dataRequest The KijiDataRequest to validate.\\n * @throws KijiDataRequestException If the data request is invalid.\\n */\"public void validate(KijiDataRequest dataRequest) {\r\n for (KijiDataRequest.Column column : dataRequest.getColumns()) {\r\n final String qualifier = column.getQualifier();\r\n final KijiTableLayout.LocalityGroupLayout.FamilyLayout fLayout =\r\n mTableLayout.getFamilyMap().get(column.getFamily());\r\n\r\n if (null == fLayout) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no family named '%s'.\",\r\n mTableLayout.getName(), column.getFamily()));\r\n }\r\n\r\n if (fLayout.isGroupType() && (null != column.getQualifier())) {\r\n if (!fLayout.getColumnMap().containsKey(qualifier)) {\r\n throw new KijiDataRequestException(String.format(\"Table '%s' has no column '%s'.\",\r\n mTableLayout.getName(), column.getName()));\r\n }\r\n }\r\n }\r\n }", "test_case": "@Test\r\n public void testValidateNoSuchColumn() throws InvalidLayoutException {\r\n KijiDataRequestBuilder builder = KijiDataRequest.builder().withTimeRange(2, 3);\r\n builder.newColumnsDef().withMaxVersions(1)\r\n .add(\"info\", \"name\")\r\n .add(\"info\", \"blahblah\");\r\n KijiDataRequest request = builder.build();\r\n\r\n try {\r\n mValidator.validate(request);\r\n } catch (KijiDataRequestException kdre) {\r\n assertEquals(\"Table 'user' has no column 'info:blahblah'.\", kdre.getMessage());\r\n }\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public boolean equals(Object obj) {\r\n if (obj == null) {\r\n return false;\r\n }\r\n if (!getClass().equals(obj.getClass())) {\r\n return false;\r\n }\r\n final KijiRowKeyComponents krkc = (KijiRowKeyComponents)obj;\r\n\r\n return Arrays.deepEquals(mComponents, krkc.mComponents);\r\n }", "test_case": "@Test\r\n public void testEquals() throws Exception {\r\n KijiRowKeyComponents krkc1 = KijiRowKeyComponents.fromComponents(\r\n \"jennyanydots\",\r\n 1,\r\n null,\r\n null);\r\n KijiRowKeyComponents krkc2 = KijiRowKeyComponents.fromComponents(\r\n \"jennyanydots\",\r\n 1,\r\n null,\r\n null);\r\n KijiRowKeyComponents krkc3 = KijiRowKeyComponents.fromComponents(\r\n \"jennyanydots\",\r\n 1,\r\n null);\r\n assertFalse(krkc1 == krkc2);\r\n assertEquals(krkc1, krkc2);\r\n assertFalse(krkc1.equals(krkc3));\r\n\r\n // byte[] use a different code path.\r\n byte[] bytes1 = new byte[]{47};\r\n byte[] bytes2 = new byte[]{47};\r\n assertFalse(bytes1.equals(bytes2));\r\n KijiRowKeyComponents krkc4 = KijiRowKeyComponents.fromComponents(bytes1);\r\n KijiRowKeyComponents krkc5 = KijiRowKeyComponents.fromComponents(bytes2);\r\n assertEquals(krkc4, krkc5);\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public int hashCode() {\r\n return Arrays.deepHashCode(mComponents);\r\n }", "test_case": "@Test\r\n public void testHashCode() throws Exception {\r\n byte[] bytes1 = new byte[]{47};\r\n byte[] bytes2 = new byte[]{47};\r\n assertFalse(bytes1.equals(bytes2));\r\n KijiRowKeyComponents krkc1 = KijiRowKeyComponents.fromComponents(bytes1);\r\n KijiRowKeyComponents krkc2 = KijiRowKeyComponents.fromComponents(bytes2);\r\n assertEquals(krkc1.hashCode(), krkc2.hashCode());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a KijiRowKeyComponents from components.\\\\\\\\n *\\\\\\\\n * @param components the components of the row key.\\\\\\\\n * @return a KijiRowKeyComponents\\\\\\\\n */', '')\", \"('', '// Some of these checks will be redundant when the KijiRowKeyComponents is converted\\\\n')\", \"('', '// into an EntityId, but putting them here helps the user see them at the time of creation.\\\\n')\", \"('', '// We need to make a deep copy of the byte[] to ensure that a later mutation to the original\\\\n')\", '(\\'\\', \"// byte[] doesn\\'t confuse hash codes, etc.\\\\n\")', \"('', '// Pass in a copy rather than the actual array, just in case the user called us with an\\\\n')\", \"('', '// Object[], which would make components mutable.\\\\n')\"]", "focal_method": "b'/**\\n * Creates a KijiRowKeyComponents from components.\\n *\\n * @param components the components of the row key.\\n * @return a KijiRowKeyComponents\\n */'public static KijiRowKeyComponents fromComponents(Object... components) {\r\n Preconditions.checkNotNull(components);\r\n Preconditions.checkArgument(components.length > 0);\r\n Preconditions.checkNotNull(components[0], \"First component cannot be null.\");\r\n\r\n // Some of these checks will be redundant when the KijiRowKeyComponents is converted\r\n // into an EntityId, but putting them here helps the user see them at the time of creation.\r\n if (components[0] instanceof byte[]) {\r\n Preconditions.checkArgument(components.length == 1, \"byte[] only valid as sole component.\");\r\n // We need to make a deep copy of the byte[] to ensure that a later mutation to the original\r\n // byte[] doesn't confuse hash codes, etc.\r\n byte[] original = (byte[])components[0];\r\n return new KijiRowKeyComponents(new Object[]{Arrays.copyOf(original, original.length)});\r\n } else {\r\n boolean seenNull = false;\r\n for (int i = 0; i < components.length; i++) {\r\n if (seenNull) {\r\n Preconditions.checkArgument(\r\n components[i] == null,\r\n \"Kiji Row Keys cannot contain have a non-null component after a null component\");\r\n } else {\r\n Object part = components[i];\r\n if (part == null) {\r\n seenNull = true;\r\n } else {\r\n Preconditions.checkArgument(\r\n (part instanceof String) || (part instanceof Integer) || (part instanceof Long),\r\n \"Components must be of type String, Integer, or Long.\");\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Pass in a copy rather than the actual array, just in case the user called us with an\r\n // Object[], which would make components mutable.\r\n return new KijiRowKeyComponents(Arrays.copyOf(components, components.length));\r\n }", "test_case": "@Test\r\n public void testFormattedCompare() {\r\n List sorted = ImmutableList.of(\r\n KijiRowKeyComponents.fromComponents(\"a\", null, null),\r\n KijiRowKeyComponents.fromComponents(\"a\", 123, 456L),\r\n KijiRowKeyComponents.fromComponents(\"a\", 456, null));\r\n\r\n List shuffled = Lists.newArrayList(sorted);\r\n Collections.shuffle(shuffled);\r\n Collections.sort(shuffled);\r\n\r\n Assert.assertEquals(sorted, shuffled);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Creates a KijiRowKeyComponents from components.\\\\\\\\n *\\\\\\\\n * @param components the components of the row key.\\\\\\\\n * @return a KijiRowKeyComponents\\\\\\\\n */', '')\", \"('', '// Some of these checks will be redundant when the KijiRowKeyComponents is converted\\\\n')\", \"('', '// into an EntityId, but putting them here helps the user see them at the time of creation.\\\\n')\", \"('', '// We need to make a deep copy of the byte[] to ensure that a later mutation to the original\\\\n')\", '(\\'\\', \"// byte[] doesn\\'t confuse hash codes, etc.\\\\n\")', \"('', '// Pass in a copy rather than the actual array, just in case the user called us with an\\\\n')\", \"('', '// Object[], which would make components mutable.\\\\n')\"]", "focal_method": "b'/**\\n * Creates a KijiRowKeyComponents from components.\\n *\\n * @param components the components of the row key.\\n * @return a KijiRowKeyComponents\\n */'public static KijiRowKeyComponents fromComponents(Object... components) {\r\n Preconditions.checkNotNull(components);\r\n Preconditions.checkArgument(components.length > 0);\r\n Preconditions.checkNotNull(components[0], \"First component cannot be null.\");\r\n\r\n // Some of these checks will be redundant when the KijiRowKeyComponents is converted\r\n // into an EntityId, but putting them here helps the user see them at the time of creation.\r\n if (components[0] instanceof byte[]) {\r\n Preconditions.checkArgument(components.length == 1, \"byte[] only valid as sole component.\");\r\n // We need to make a deep copy of the byte[] to ensure that a later mutation to the original\r\n // byte[] doesn't confuse hash codes, etc.\r\n byte[] original = (byte[])components[0];\r\n return new KijiRowKeyComponents(new Object[]{Arrays.copyOf(original, original.length)});\r\n } else {\r\n boolean seenNull = false;\r\n for (int i = 0; i < components.length; i++) {\r\n if (seenNull) {\r\n Preconditions.checkArgument(\r\n components[i] == null,\r\n \"Kiji Row Keys cannot contain have a non-null component after a null component\");\r\n } else {\r\n Object part = components[i];\r\n if (part == null) {\r\n seenNull = true;\r\n } else {\r\n Preconditions.checkArgument(\r\n (part instanceof String) || (part instanceof Integer) || (part instanceof Long),\r\n \"Components must be of type String, Integer, or Long.\");\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Pass in a copy rather than the actual array, just in case the user called us with an\r\n // Object[], which would make components mutable.\r\n return new KijiRowKeyComponents(Arrays.copyOf(components, components.length));\r\n }", "test_case": "@Test\r\n public void testRawCompare() {\r\n final List sorted = ImmutableList.of(\r\n KijiRowKeyComponents.fromComponents(new Object[] {new byte[] {0x00, 0x00}}),\r\n KijiRowKeyComponents.fromComponents(new Object[] {new byte[] {0x00, 0x01}}),\r\n KijiRowKeyComponents.fromComponents(new Object[] {new byte[] {0x01, 0x00}}));\r\n\r\n List shuffled = Lists.newArrayList(sorted);\r\n Collections.shuffle(shuffled);\r\n Collections.sort(shuffled);\r\n\r\n Assert.assertEquals(sorted, shuffled);\r\n }"} {"description": "Resolution in number of bytes when generating evenly spaced HBase row keys @return the number of bytes required by an md5 hash", "focal_method": "b'/**\\n * Resolution (in number of bytes) when generating evenly spaced HBase row keys.\\n *\\n * @return the number of bytes required by an md5 hash.\\n */'@Deprecated\r\n public int getRowKeyResolution() {\r\n return 16;\r\n }", "test_case": "@Test\r\n public void testGetRowKeyResolution() throws IOException {\r\n assertEquals(2, KijiRowKeySplitter\r\n .getRowKeyResolution(KijiTableLayouts.getLayout(KijiTableLayouts.FORMATTED_RKF)));\r\n assertEquals(16, KijiRowKeySplitter\r\n .getRowKeyResolution(KijiTableLayouts.getLayout(KijiTableLayouts.FULL_FEATURED)));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testIllegalScheme() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-foo:///\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertTrue(kurie.getMessage().contains(\"No parser available for\"));\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNoAuthority() {\r\n try {\r\n KijiURI.newBuilder(\"kiji:///\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji:///' : ZooKeeper ensemble missing.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHosts() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsNoParen() {\r\n try {\r\n KijiURI.newBuilder(\"kiji://zkhost1,zkhost2:1234/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji://zkhost1,zkhost2:1234/instance/table/col' : Multiple \"\r\n + \"ZooKeeper hosts must be parenthesized.\", kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsMultiplePorts() {\r\n try {\r\n KijiURI.newBuilder(\"kiji://zkhost1:1234,zkhost2:2345/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji://zkhost1:1234,zkhost2:2345/instance/table/col' : \"\r\n + \"Invalid ZooKeeper ensemble cluster identifier.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testExtraPath() {\r\n try {\r\n KijiURI.newBuilder(\"kiji://(zkhost1,zkhost2):1234/instance/table/col/extra\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji://(zkhost1,zkhost2):1234/instance/table/col/extra' : \"\r\n + \"Too many path segments.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String toString() {\r\n return toString(false);\r\n }", "test_case": "@Test\r\n public void testToString() {\r\n String uri = \"kiji://(zkhost1,zkhost2):1234/instance/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji://zkhost1:1234/instance/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji://zkhost:1234/instance/table/col1,col2/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji://zkhost:1234/.unset/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with defaults for an HBase cluster.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields for an HBase cluster.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with defaults for an HBase cluster.\\n */'public static KijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testKijiURIBuilderFromInstance() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji://zkhost:1234/.unset/table\").build();\r\n KijiURI built = KijiURI.newBuilder(uri).build();\r\n assertEquals(uri, built);\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public void close() throws IOException {\r\n mQualifierPager.close();\r\n }", "test_case": "@Test\r\n public void testQualifiersIterator() throws IOException {\r\n final EntityId eid = mTable.getEntityId(\"me\");\r\n\r\n final KijiDataRequest dataRequest = KijiDataRequest.builder()\r\n .addColumns(ColumnsDef.create()\r\n .withMaxVersions(HConstants.ALL_VERSIONS).withPageSize(1).addFamily(\"jobs\"))\r\n .build();\r\n\r\n final KijiRowData row = mReader.get(eid, dataRequest);\r\n final MapFamilyQualifierIterator it = new MapFamilyQualifierIterator(row, \"jobs\", 3);\r\n try {\r\n final List qualifiers = Lists.newArrayList((Iterator) it);\r\n Assert.assertEquals(Lists.newArrayList(\"j0\", \"j1\", \"j2\", \"j3\", \"j4\"), qualifiers);\r\n } finally {\r\n it.close();\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public void close() throws IOException {\r\n mQualifierIterator.close();\r\n if (mVersionIterator != null) {\r\n mVersionIterator.close();\r\n }\r\n }", "test_case": "@Test\r\n public void testQualifiersIterator() throws IOException {\r\n final EntityId eid = mTable.getEntityId(\"me\");\r\n\r\n final KijiDataRequest dataRequest = KijiDataRequest.builder()\r\n .addColumns(ColumnsDef.create()\r\n .withMaxVersions(HConstants.ALL_VERSIONS).withPageSize(1).addFamily(\"jobs\"))\r\n .build();\r\n\r\n final KijiRowData row = mReader.get(eid, dataRequest);\r\n final MapFamilyVersionIterator it =\r\n new MapFamilyVersionIterator(row, \"jobs\", 3, 2);\r\n try {\r\n int ncells = 0;\r\n int ijob = 0;\r\n int timestamp = 5;\r\n for (Entry entry : it) {\r\n assertEquals(String.format(\"j%d\", ijob), entry.getQualifier());\r\n assertEquals(timestamp, entry.getTimestamp());\r\n assertEquals(String.format(\"j%d-t%d\", ijob, timestamp), entry.getValue().toString());\r\n timestamp -= 1;\r\n if (timestamp == 0) {\r\n timestamp = 5;\r\n ijob += 1;\r\n }\r\n ncells += 1;\r\n }\r\n assertEquals(NJOBS * NTIMESTAMPS, ncells);\r\n } finally {\r\n it.close();\r\n }\r\n }"} {"description": "Creates a raw entity ID @param rowKey KijiHBase row key both row keys are identical", "focal_method": "b'/**\\n * Creates a raw entity ID.\\n *\\n * @param rowKey Kiji/HBase row key (both row keys are identical).\\n */'private RawEntityId(byte[] rowKey) {\r\n mBytes = Preconditions.checkNotNull(rowKey);\r\n }", "test_case": "@Test\r\n public void testRawEntityId() {\r\n final byte[] bytes = new byte[] {0x11, 0x22};\r\n final RawEntityId eid = RawEntityId.getEntityId(bytes);\r\n assertArrayEquals(bytes, (byte[])eid.getComponentByIndex(0));\r\n assertArrayEquals(bytes, eid.getHBaseRowKey());\r\n assertEquals(1, eid.getComponents().size());\r\n assertEquals(bytes, eid.getComponents().get(0));\r\n }"} {"description": "Loads the dictionary from a file @param filename The path to a file of words one per line @return The list of words from the file @throws IOException If there is an error reading the words from the file", "focal_method": "b'/**\\n * Loads the dictionary from a file.\\n *\\n * @param filename The path to a file of words, one per line.\\n * @return The list of words from the file.\\n * @throws IOException If there is an error reading the words from the file.\\n */'public List load(String filename) throws IOException {\r\n FileInputStream fileStream = new FileInputStream(filename);\r\n try {\r\n return load(fileStream);\r\n } finally {\r\n fileStream.close();\r\n }\r\n }", "test_case": "@Test\r\n public void testLoad() throws IOException {\r\n DictionaryLoader loader = new DictionaryLoader();\r\n List dictionary = loader.load(getClass().getClassLoader().getResourceAsStream(\r\n \"org/kiji/schema/tools/synth/dictionary.txt\"));\r\n assertEquals(3, dictionary.size());\r\n assertEquals(\"apple\", dictionary.get(0));\r\n assertEquals(\"banana\", dictionary.get(1));\r\n assertEquals(\"carrot\", dictionary.get(2));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsDefaultPort() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost1,zkhost2/instance/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(KijiURI.DEFAULT_ZOOKEEPER_CLIENT_PORT, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "Construct an email address string @param username The part before the @ symbol @param domain The part after the @ symbol @return An email address ltusernamegt@ltdomaingt", "focal_method": "b\"/**\\n * Construct an email address string.\\n *\\n * @param username The part before the '@' symbol.\\n * @param domain The part after the '@' symbol.\\n * @return An email address (<username>@<domain>).\\n */\"public static String formatEmail(String username, String domain) {\r\n return username + \"@\" + domain;\r\n }", "test_case": "@Test\r\n public void testFormatEmail() {\r\n assertEquals(\"a@b.com\", EmailSynthesizer.formatEmail(\"a\", \"b.com\"));\r\n }"} {"description": "[\"('', '// Pick n words from the dictionary.\\\\n')\"]", "focal_method": "@Override\r\n public String synthesize() {\r\n // Pick n words from the dictionary.\r\n List grams = new ArrayList(mN);\r\n for (int i = 0; i < mN; i++) {\r\n grams.add(mWordSynthesizer.synthesize());\r\n }\r\n return StringUtils.join(grams, \" \");\r\n }", "test_case": "@Test\r\n public void testWordSynth() {\r\n WordSynthesizer wordSynthesizer = createStrictMock(WordSynthesizer.class);\r\n expect(wordSynthesizer.synthesize()).andReturn(\"a\");\r\n expect(wordSynthesizer.synthesize()).andReturn(\"b\");\r\n expect(wordSynthesizer.synthesize()).andReturn(\"c\");\r\n expect(wordSynthesizer.synthesize()).andReturn(\"d\");\r\n\r\n replay(wordSynthesizer);\r\n NGramSynthesizer synth = new NGramSynthesizer(wordSynthesizer, 2);\r\n assertEquals(\"a b\", synth.synthesize());\r\n assertEquals(\"c d\", synth.synthesize());\r\n verify(wordSynthesizer);\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"create-table\";\r\n }", "test_case": "@Test\r\n public void testCreateHashedTableWithNumRegions() throws Exception {\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);\r\n final File layoutFile = getTempLayoutFile(layout);\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n assertEquals(BaseTool.SUCCESS, runTool(new CreateTableTool(),\r\n \"--table=\" + tableURI,\r\n \"--layout=\" + layoutFile,\r\n \"--num-regions=\" + 2,\r\n \"--debug\"\r\n ));\r\n assertEquals(2, mToolOutputLines.length);\r\n assertTrue(mToolOutputLines[0].startsWith(\"Parsing table layout: \"));\r\n assertTrue(mToolOutputLines[1].startsWith(\"Creating Kiji table\"));\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"create-table\";\r\n }", "test_case": "@Test\r\n public void testCreateUnhashedTableWithSplitKeys() throws Exception {\r\n final KijiTableLayout layout =\r\n KijiTableLayout.newLayout(KijiTableLayouts.getFooUnhashedTestLayout());\r\n final File layoutFile = getTempLayoutFile(layout);\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n final String splitKeyFile =\r\n getClass().getClassLoader().getResource(REGION_SPLIT_KEY_FILE).getPath();\r\n\r\n assertEquals(BaseTool.SUCCESS, runTool(new CreateTableTool(),\r\n \"--table=\" + tableURI,\r\n \"--layout=\" + layoutFile,\r\n \"--split-key-file=file://\" + splitKeyFile,\r\n \"--debug\"\r\n ));\r\n assertEquals(2, mToolOutputLines.length);\r\n assertTrue(mToolOutputLines[0].startsWith(\"Parsing table layout: \"));\r\n assertTrue(mToolOutputLines[1].startsWith(\"Creating Kiji table\"));\r\n\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"create-table\";\r\n }", "test_case": "@Test\r\n public void testCreateHashedTableWithSplitKeys() throws Exception {\r\n final KijiTableLayout layout =\r\n KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST_LEGACY);\r\n final File layoutFile = getTempLayoutFile(layout);\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n final String splitKeyFile =\r\n getClass().getClassLoader().getResource(REGION_SPLIT_KEY_FILE).getPath();\r\n\r\n try {\r\n runTool(new CreateTableTool(),\r\n \"--table=\" + tableURI,\r\n \"--layout=\" + layoutFile,\r\n \"--split-key-file=file://\" + splitKeyFile\r\n );\r\n fail(\"Should throw IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertTrue(iae.getMessage().startsWith(\r\n \"Row key hashing is enabled for the table. Use --num-regions=N instead.\"));\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"create-table\";\r\n }", "test_case": "@Test\r\n public void testCreateUnhashedTableWithNumRegions() throws Exception {\r\n final KijiTableLayout layout =\r\n KijiTableLayout.newLayout(KijiTableLayouts.getFooUnhashedTestLayout());\r\n final File layoutFile = getTempLayoutFile(layout);\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n try {\r\n runTool(new CreateTableTool(),\r\n \"--table=\" + tableURI,\r\n \"--layout=\" + layoutFile,\r\n \"--num-regions=4\"\r\n );\r\n fail(\"Should throw InvalidLayoutException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertTrue(iae.getMessage().startsWith(\r\n \"May not use numRegions > 1 if row key hashing is disabled in the layout\"));\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"create-table\";\r\n }", "test_case": "@Test\r\n public void testCreateTableWithInvalidSchemaClassInLayout() throws Exception {\r\n final TableLayoutDesc layout = KijiTableLayouts.getLayout(KijiTableLayouts.INVALID_SCHEMA);\r\n final File layoutFile = getTempLayoutFile(layout);\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n try {\r\n runTool(new CreateTableTool(),\r\n \"--table=\" + tableURI,\r\n \"--layout=\" + layoutFile\r\n );\r\n fail(\"Should throw InvalidLayoutException\");\r\n } catch (InvalidLayoutException ile) {\r\n assertTrue(ile.getMessage(), ile.getMessage().startsWith(\r\n \"Invalid cell specification with Avro class type has invalid class name: '\\\"string\\\"'.\"));\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"get\";\r\n }", "test_case": "@Test\r\n public void testGetFromTable() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);\r\n kiji.createTable(layout.getName(), layout);\r\n\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"hashed\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(314L, \"value\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),\r\n \"--entity-id=hashed\"));\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"get\";\r\n }", "test_case": "@Test\r\n public void testGetFromTableMore() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);\r\n final long timestamp = 10L;\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"gwu@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"gwu@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Garrett Wu\")\r\n .withRow(\"aaron@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"aaron@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Aaron Kimball\")\r\n .withRow(\"christophe@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\")\r\n .withValue(timestamp, \"christophe@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Christophe Bisciglia\")\r\n .withRow(\"kiyan@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"kiyan@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Kiyan Ahmadizadeh\")\r\n .withRow(\"john.doe@gmail.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"john.doe@gmail.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"John Doe\")\r\n .withRow(\"jane.doe@gmail.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"jane.doe@gmail.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Jane Doe\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),\r\n \"--entity-id=[\\\"jane.doe@gmail.com\\\"]\"));\r\n assertEquals(5, mToolOutputLines.length);\r\n EntityId eid = EntityIdFactory.getFactory(layout).getEntityId(\"gwu@usermail.example.com\");\r\n String hbaseRowKey = Hex.encodeHexString(eid.getHBaseRowKey());\r\n assertEquals(BaseTool.SUCCESS, runTool(new GetTool(),\r\n table.getURI() + \"info:name\",\r\n \"--entity-id=hbase=hex:\" + hbaseRowKey\r\n ));\r\n assertEquals(3, mToolOutputLines.length);\r\n // TODO: Validate GetTool output\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsDefaultPortDefaultInstance() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost1,zkhost2/default/table/col\").build();\r\n assertEquals(\"kiji-hbase\", uri.getScheme());\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(KijiURI.DEFAULT_ZOOKEEPER_CLIENT_PORT, uri.getZookeeperClientPort());\r\n assertEquals(\"default\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"get\";\r\n }", "test_case": "@Test\r\n public void testGetFormattedRKF() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"NYC\", \"Technology\", \"widget\", 1, 2)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Candaules\")\r\n .withRow(\"NYC\", \"Technology\", \"widget\", 1, 20)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Croesus\")\r\n .withRow(\"NYC\", \"Technology\", \"thingie\", 2)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Gyges\")\r\n .withRow(\"DC\", \"Technology\", \"stuff\", 123)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Glaucon\")\r\n .withRow(\"DC\", \"Technology\", \"stuff\", 124, 1)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Lydia\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),\r\n \"--entity-id=['NYC','Technology','widget',1,2]\"\r\n ));\r\n assertEquals(3, mToolOutputLines.length);\r\n assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),\r\n \"--entity-id=['NYC','Technology','thingie',2,null]\"\r\n ));\r\n assertEquals(3, mToolOutputLines.length);\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "['(\"/**\\\\\\\\n * Return the tool specified by the \\'toolName\\' argument.\\\\\\\\n * (package-protected for use by the HelpTool, and for testing.)\\\\\\\\n *\\\\\\\\n * @param toolName the name of the tool to instantiate.\\\\\\\\n * @return the KijiTool that provides for that name, or null if none does.\\\\\\\\n */\", \\'\\')', \"('', '// Iterate over available tools, searching for the one with\\\\n')\", \"('', '// the same name as the supplied tool name argument.\\\\n')\"]", "focal_method": "b\"/**\\n * Return the tool specified by the 'toolName' argument.\\n * (package-protected for use by the HelpTool, and for testing.)\\n *\\n * @param toolName the name of the tool to instantiate.\\n * @return the KijiTool that provides for that name, or null if none does.\\n */\"KijiTool getToolForName(String toolName) {\r\n KijiTool tool = null;\r\n\r\n // Iterate over available tools, searching for the one with\r\n // the same name as the supplied tool name argument.\r\n for (KijiTool candidate : Lookups.get(KijiTool.class)) {\r\n if (toolName.equals(candidate.getName())) {\r\n tool = candidate;\r\n break;\r\n }\r\n }\r\n\r\n return tool;\r\n }", "test_case": "@Test\r\n public void testGetToolName() {\r\n KijiTool tool = new KijiToolLauncher().getToolForName(\"ls\");\r\n assertNotNull(\"Got a null tool back, should have gotten a real one.\", tool);\r\n assertEquals(\"Tool does not advertise it responds to 'ls'.\", \"ls\", tool.getName());\r\n assertTrue(\"Didn't get the LsTool we expected!\", tool instanceof LsTool);\r\n }"} {"description": "['(\"/**\\\\\\\\n * Return the tool specified by the \\'toolName\\' argument.\\\\\\\\n * (package-protected for use by the HelpTool, and for testing.)\\\\\\\\n *\\\\\\\\n * @param toolName the name of the tool to instantiate.\\\\\\\\n * @return the KijiTool that provides for that name, or null if none does.\\\\\\\\n */\", \\'\\')', \"('', '// Iterate over available tools, searching for the one with\\\\n')\", \"('', '// the same name as the supplied tool name argument.\\\\n')\"]", "focal_method": "b\"/**\\n * Return the tool specified by the 'toolName' argument.\\n * (package-protected for use by the HelpTool, and for testing.)\\n *\\n * @param toolName the name of the tool to instantiate.\\n * @return the KijiTool that provides for that name, or null if none does.\\n */\"KijiTool getToolForName(String toolName) {\r\n KijiTool tool = null;\r\n\r\n // Iterate over available tools, searching for the one with\r\n // the same name as the supplied tool name argument.\r\n for (KijiTool candidate : Lookups.get(KijiTool.class)) {\r\n if (toolName.equals(candidate.getName())) {\r\n tool = candidate;\r\n break;\r\n }\r\n }\r\n\r\n return tool;\r\n }", "test_case": "@Test\r\n public void testGetMissingTool() {\r\n KijiTool tool = new KijiToolLauncher().getToolForName(\"this-tool/can't1`exist\");\r\n assertNull(tool);\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"layout\";\r\n }", "test_case": "@Test\r\n public void testChangeRowKeyHashing() throws Exception {\r\n final KijiTableLayout layout =\r\n KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST_LEGACY);\r\n getKiji().createTable(layout.getDesc());\r\n\r\n final File newLayoutFile = getTempLayoutFile(KijiTableLayouts.getFooChangeHashingTestLayout());\r\n final KijiURI tableURI =\r\n KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();\r\n\r\n try {\r\n runTool(new LayoutTool(),\r\n \"--table=\" + tableURI,\r\n \"--do=set\",\r\n \"--layout=\" + newLayoutFile\r\n );\r\n fail(\"Should throw InvalidLayoutException\");\r\n } catch (InvalidLayoutException ile) {\r\n assertTrue(ile.getMessage().startsWith(\r\n \"Invalid layout update from reference row keys format\"));\r\n }\r\n }"} {"description": "Parses a table name for a kiji instance name @param kijiTableName The table name to parse @return instance name or null if none found", "focal_method": "b'/**\\n * Parses a table name for a kiji instance name.\\n *\\n * @param kijiTableName The table name to parse\\n * @return instance name (or null if none found)\\n */'protected static String parseInstanceName(String kijiTableName) {\r\n final String[] parts = StringUtils.split(kijiTableName, '\\u0000', '.');\r\n if (parts.length < 3 || !KijiURI.KIJI_SCHEME.equals(parts[0])) {\r\n return null;\r\n }\r\n return parts[1];\r\n }", "test_case": "@Test\r\n public void testParseInstanceName() {\r\n assertEquals(\"default\", LsTool.parseInstanceName(\"kiji.default.meta\"));\r\n assertEquals(\"default\", LsTool.parseInstanceName(\"kiji.default.schema_hash\"));\r\n assertEquals(\"default\", LsTool.parseInstanceName(\"kiji.default.schema_id\"));\r\n assertEquals(\"default\", LsTool.parseInstanceName(\"kiji.default.system\"));\r\n assertEquals(\"default\", LsTool.parseInstanceName(\"kiji.default.table.job_history\"));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a table name for a kiji instance name.\\\\\\\\n *\\\\\\\\n * @param kijiTableName The table name to parse\\\\\\\\n * @return instance name (or null if none found)\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a table name for a kiji instance name.\\n *\\n * @param kijiTableName The table name to parse\\n * @return instance name (or null if none found)\\n */'protected static String parseInstanceName(String kijiTableName) {\r\n final String[] parts = StringUtils.split(kijiTableName, '\\u0000', '.');\r\n if (parts.length < 3 || !KijiURI.KIJI_SCHEME.equals(parts[0])) {\r\n return null;\r\n }\r\n return parts[1];\r\n }", "test_case": "@Test\r\n public void testParseNonKijiTable() {\r\n String tableName = \"hbase_table\";\r\n assertEquals(null, LsTool.parseInstanceName(tableName));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a table name for a kiji instance name.\\\\\\\\n *\\\\\\\\n * @param kijiTableName The table name to parse\\\\\\\\n * @return instance name (or null if none found)\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a table name for a kiji instance name.\\n *\\n * @param kijiTableName The table name to parse\\n * @return instance name (or null if none found)\\n */'protected static String parseInstanceName(String kijiTableName) {\r\n final String[] parts = StringUtils.split(kijiTableName, '\\u0000', '.');\r\n if (parts.length < 3 || !KijiURI.KIJI_SCHEME.equals(parts[0])) {\r\n return null;\r\n }\r\n return parts[1];\r\n }", "test_case": "@Test\r\n public void testParseMalformedKijiTableName() {\r\n assertEquals(null, LsTool.parseInstanceName(\"kiji.default\"));\r\n assertEquals(null, LsTool.parseInstanceName(\"kiji.\"));\r\n assertEquals(null, LsTool.parseInstanceName(\"kiji\"));\r\n }"} {"description": "Lists all kiji instances @param hbaseURI URI of the HBase instance to list the content of @return A program exit code zero on success @throws IOException If there is an error", "focal_method": "b'/**\\n * Lists all kiji instances.\\n *\\n * @param hbaseURI URI of the HBase instance to list the content of.\\n * @return A program exit code (zero on success).\\n * @throws IOException If there is an error.\\n */'private int listInstances(KijiURI hbaseURI) throws IOException {\r\n for (String instanceName : getInstanceNames(hbaseURI)) {\r\n getPrintStream().println(KijiURI.newBuilder(hbaseURI).withInstanceName(instanceName).build());\r\n }\r\n return SUCCESS;\r\n }", "test_case": "@Test\r\n public void testListInstances() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiURI hbaseURI = KijiURI.newBuilder(kiji.getURI()).withInstanceName(null).build();\r\n\r\n final LsTool ls = new LsTool();\r\n assertEquals(BaseTool.SUCCESS, runTool(ls, hbaseURI.toString()));\r\n final Set instances = Sets.newHashSet(mToolOutputLines);\r\n assertTrue(instances.contains(kiji.getURI().toString()));\r\n }"} {"description": "Lists all the tables in a kiji instance @param kiji Kiji instance to list the tables of @return A program exit code zero on success @throws IOException If there is an error", "focal_method": "b'/**\\n * Lists all the tables in a kiji instance.\\n *\\n * @param kiji Kiji instance to list the tables of.\\n * @return A program exit code (zero on success).\\n * @throws IOException If there is an error.\\n */'private int listTables(Kiji kiji) throws IOException {\r\n for (String name : kiji.getTableNames()) {\r\n getPrintStream().println(kiji.getURI() + name);\r\n }\r\n return SUCCESS;\r\n }", "test_case": "@Test\r\n public void testListTables() throws Exception {\r\n final Kiji kiji = getKiji();\r\n\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), kiji.getURI().toString()));\r\n assertEquals(1, mToolOutputLines.length);\r\n\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);\r\n kiji.createTable(layout.getDesc());\r\n\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), kiji.getURI().toString()));\r\n assertEquals(1, mToolOutputLines.length);\r\n assertEquals(kiji.getURI() + layout.getName(), mToolOutputLines[0]);\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"ls\";\r\n }", "test_case": "@Test\r\n public void testTableColumns() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);\r\n kiji.createTable(layout.getDesc());\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n // Table is empty:\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));\r\n assertEquals(1, mToolOutputLines.length);\r\n assertTrue(mToolOutputLines[0].contains(\"family:column\"));\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testIllegalScheme() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-foo:///\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertTrue(kurie.getMessage().contains(\"No parser available for\"));\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"ls\";\r\n }", "test_case": "@Test\r\n public void testFormattedRowKey() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1, 2L)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(1L, \"string-value\")\r\n .withValue(2L, \"string-value2\")\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1)\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\", \"str2\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"ls\";\r\n }", "test_case": "@Test\r\n public void testKijiLsStartAndLimitRow() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);\r\n kiji.createTable(layout.getDesc());\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));\r\n // TODO: Validate output\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"ls\";\r\n }", "test_case": "@Test\r\n public void testMultipleArguments() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1, 2L)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(1L, \"string-value\")\r\n .withValue(2L, \"string-value2\")\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1)\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\", \"str2\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .build();\r\n\r\n final KijiTableLayout layoutTwo = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);\r\n kiji.createTable(layoutTwo.getDesc());\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n final KijiTable tableTwo = kiji.openTable(layoutTwo.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString(),\r\n tableTwo.getURI().toString()));\r\n assertEquals(9, mToolOutputLines.length);\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), kiji.getURI().toString()));\r\n assertEquals(2, mToolOutputLines.length);\r\n assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), kiji.getURI().toString(),\r\n table.getURI().toString()));\r\n assertEquals(3, mToolOutputLines.length);\r\n } finally {\r\n tableTwo.release();\r\n }\r\n } finally {\r\n table.release();\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"scan\";\r\n }", "test_case": "@Test\r\n public void testFormattedRowKey() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1, 2L)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(1L, \"string-value\")\r\n .withValue(2L, \"string-value2\")\r\n .withRow(\"dummy\", \"str1\", \"str2\", 1)\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\", \"str2\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\", \"str1\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .withRow(\"dummy\")\r\n .withFamily(\"family\").withQualifier(\"column\").withValue(1L, \"string-value\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(), table.getURI().toString()));\r\n assertEquals(15, mToolOutputLines.length);\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"scan\";\r\n }", "test_case": "@Test\r\n public void testKijiScanStartAndLimitRow() throws Exception {\r\n final Kiji kiji = getKiji();\r\n\r\n TableLayoutDesc desc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);\r\n ((RowKeyFormat2)desc.getKeysFormat()).setEncoding(RowKeyEncoding.RAW);\r\n\r\n final KijiTableLayout layout = KijiTableLayout.newLayout(desc);\r\n final long timestamp = 10L;\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"gwu@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"gwu@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Garrett Wu\")\r\n .withRow(\"aaron@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"aaron@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Aaron Kimball\")\r\n .withRow(\"christophe@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\")\r\n .withValue(timestamp, \"christophe@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Christophe Bisciglia\")\r\n .withRow(\"kiyan@usermail.example.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"kiyan@usermail.example.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Kiyan Ahmadizadeh\")\r\n .withRow(\"john.doe@gmail.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"john.doe@gmail.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"John Doe\")\r\n .withRow(\"jane.doe@gmail.com\")\r\n .withFamily(\"info\")\r\n .withQualifier(\"email\").withValue(timestamp, \"jane.doe@gmail.com\")\r\n .withQualifier(\"name\").withValue(timestamp, \"Jane Doe\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(),\r\n table.getURI().toString() + \"info:name\"\r\n ));\r\n assertEquals(18, mToolOutputLines.length);\r\n\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(),\r\n table.getURI().toString() + \"info:name,info:email\"\r\n ));\r\n assertEquals(30, mToolOutputLines.length);\r\n\r\n EntityIdFactory eif = EntityIdFactory.getFactory(layout);\r\n EntityId startEid = eif.getEntityId(\"christophe@usermail.example.com\"); //second row\r\n EntityId limitEid = eif.getEntityId(\"john.doe@gmail.com\"); //second to last row\r\n String startHbaseRowKey = Hex.encodeHexString(startEid.getHBaseRowKey());\r\n String limitHbaseRowKey = Hex.encodeHexString(limitEid.getHBaseRowKey());\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(),\r\n table.getURI().toString() + \"info:name\",\r\n \"--start-row=hbase=hex:\" + startHbaseRowKey, // start at the second row.\r\n \"--limit-row=hbase=hex:\" + limitHbaseRowKey // end at the 2nd to last row (exclusive).\r\n ));\r\n assertEquals(9, mToolOutputLines.length);\r\n\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "[\"('/** {@inheritDoc} */', '')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public String getName() {\r\n return \"scan\";\r\n }", "test_case": "@Test\r\n public void testRangeScanFormattedRKF() throws Exception {\r\n final Kiji kiji = getKiji();\r\n final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);\r\n new InstanceBuilder(kiji)\r\n .withTable(layout.getName(), layout)\r\n .withRow(\"NYC\", \"Technology\", \"widget\", 1, 2)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Candaules\")\r\n .withRow(\"NYC\", \"Technology\", \"widget\", 1, 20)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Croesus\")\r\n .withRow(\"NYC\", \"Technology\", \"thingie\", 2)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Gyges\")\r\n .withRow(\"DC\", \"Technology\", \"stuff\", 123)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Glaucon\")\r\n .withRow(\"DC\", \"Technology\", \"stuff\", 124, 1)\r\n .withFamily(\"family\").withQualifier(\"column\")\r\n .withValue(\"Lydia\")\r\n .build();\r\n\r\n final KijiTable table = kiji.openTable(layout.getName());\r\n try {\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(), table.getURI().toString(),\r\n \"--start-row=['NYC','Technology','widget',1,2]\",\r\n \"--limit-row=['NYC','Technology','widget',1,30]\",\r\n \"--debug\"\r\n ));\r\n assertEquals(10, mToolOutputLines.length);\r\n assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(), table.getURI().toString(),\r\n \"--start-row=['NYC','Technology','widget']\",\r\n \"--limit-row=['NYC','Technology','widget',1,20]\",\r\n \"--debug\"\r\n ));\r\n } finally {\r\n ResourceUtils.releaseOrLog(table);\r\n }\r\n }"} {"description": "Register a schema @return Tool exit code @throws IOException in case of an error", "focal_method": "b'/**\\n * Register a schema.\\n *\\n * @return Tool exit code.\\n * @throws IOException in case of an error.\\n */'private int registerSchema() throws IOException {\r\n final KijiSchemaTable table = mKiji.getSchemaTable();\r\n final File file = new File(mRegisterFlag);\r\n final Schema schema = new Schema.Parser().parse(file);\r\n final long id = table.getOrCreateSchemaId(schema);\r\n final String hash = table.getSchemaHash(schema).toString();\r\n if (isInteractive()) {\r\n getPrintStream().print(\"Schema ID for the given schema is: \");\r\n }\r\n getPrintStream().println(id);\r\n if (isInteractive()) {\r\n getPrintStream().print(\"Schema hash for the given schema is: \");\r\n }\r\n getPrintStream().println(hash);\r\n return SUCCESS;\r\n }", "test_case": "@Test\r\n public void testRegisterSchema() throws Exception {\r\n assertEquals(BaseTool.SUCCESS, runTool(new SchemaTableTool(),\r\n getKiji().getURI().toString(),\r\n \"--register=\" + mFile.toString(),\r\n \"--interactive=false\"\r\n ));\r\n assertEquals(mSimpleSchema, mTable.getSchema(Long.parseLong(mToolOutputLines[0])));\r\n }"} {"description": "List all schemas in the table @return The Tool exit code @throws IOException in case of an error", "focal_method": "b'/**\\n * List all schemas in the table.\\n *\\n * @return The Tool exit code.\\n * @throws IOException in case of an error.\\n */'private int list() throws IOException {\r\n final KijiSchemaTable schemaTable = mKiji.getSchemaTable();\r\n long id = 0;\r\n Schema schema = schemaTable.getSchema(id);\r\n while (null != schema) {\r\n getPrintStream().printf(\"%d: %s%n\", id, schema.toString());\r\n schema = schemaTable.getSchema(++id);\r\n }\r\n\r\n return SUCCESS;\r\n }", "test_case": "@Test\r\n public void testList() throws Exception {\r\n final long simpleSchemaId = getKiji().getSchemaTable().getOrCreateSchemaId(mSimpleSchema);\r\n assertEquals(BaseTool.SUCCESS, runTool(new SchemaTableTool(),\r\n getKiji().getURI().toString(),\r\n \"--list\"));\r\n assertTrue(mToolOutputStr.contains(\r\n String.format(\"%d: %s%n\", simpleSchemaId, mSimpleSchema.toString())));\r\n }"} {"description": "Lookup a schema @return Tool exit code @throws IOException in case of an error", "focal_method": "b'/**\\n * Lookup a schema.\\n *\\n * @return Tool exit code.\\n * @throws IOException in case of an error.\\n */'private int lookupSchema() throws IOException {\r\n final KijiSchemaTable table = mKiji.getSchemaTable();\r\n final File file = new File(mLookupFlag);\r\n final Schema schema = new Schema.Parser().parse(file);\r\n final SchemaEntry sEntry = table.getSchemaEntry(schema);\r\n final long id = sEntry.getId();\r\n final BytesKey hash = sEntry.getHash();\r\n if (isInteractive()) {\r\n getPrintStream().print(\"Schema ID for the given schema is: \");\r\n }\r\n getPrintStream().println(id);\r\n if (isInteractive()) {\r\n getPrintStream().print(\"Schema hash for the given schema is: \");\r\n }\r\n getPrintStream().println(hash);\r\n return SUCCESS;\r\n }", "test_case": "@Test\r\n public void lookupSchema() throws Exception {\r\n final BytesKey hash = mTable.getSchemaHash(mSimpleSchema);\r\n final long id = mTable.getOrCreateSchemaId(mSimpleSchema);\r\n assertEquals(BaseTool.SUCCESS, runTool(new SchemaTableTool(),\r\n getKiji().getURI().toString(),\r\n \"--lookup=\" + mFile.toString(),\r\n \"--interactive=false\"\r\n ));\r\n assertEquals(id, Long.parseLong(mToolOutputLines[0]));\r\n assertEquals(hash, new BytesKey(ByteArrayFormatter.parseHex(mToolOutputLines[1], ':')));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseValidMapEmpty() throws Exception {\r\n final Map kvs = mParser.parse(\"\");\r\n final Map expected = ImmutableMap.builder().build();\r\n assertEquals(expected, kvs);\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
    \\\\\\\\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\\\\\\\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
  • \\\\\\\\n *
  • The table name and column names are explicitly left unset.
  • \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
    \\n *
  • The Zookeeper quorum and client port is taken from the Hadoop Configuration
  • \\n *
  • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
  • \\n *
  • The table name and column names are explicitly left unset.
  • \\n *
\\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNoAuthority() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-hbase:///\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji-hbase:///' : ZooKeeper ensemble missing.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseValidMapOneEntry() throws Exception {\r\n final Map kvs = mParser.parse(\"key1=value1\");\r\n final Map expected =\r\n ImmutableMap.builder().put(\"key1\", \"value1\").build();\r\n assertEquals(expected, kvs);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseValidMapManyEntries() throws Exception {\r\n final Map kvs = mParser.parse(\"key1=value1 key2=value2 key3=value3\");\r\n final Map expected = ImmutableMap.builder()\r\n .put(\"key1\", \"value1\")\r\n .put(\"key2\", \"value2\")\r\n .put(\"key3\", \"value3\")\r\n .build();\r\n assertEquals(expected, kvs);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseValidMapEmptySpaces() throws Exception {\r\n final Map kvs = mParser.parse(\" \");\r\n final Map expected = ImmutableMap.builder().build();\r\n assertEquals(expected, kvs);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseValidMapManySpaces() throws Exception {\r\n final Map kvs = mParser.parse(\" key1=value1 key2=value2 key3=value3 \");\r\n final Map expected = ImmutableMap.builder()\r\n .put(\"key1\", \"value1\")\r\n .put(\"key2\", \"value2\")\r\n .put(\"key3\", \"value3\")\r\n .build();\r\n assertEquals(expected, kvs);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseInvalidMapNoEquals() throws Exception {\r\n try {\r\n final String input = \"key1=value1 invalid key3=value3\";\r\n mParser.parse(input);\r\n fail(String.format(\"Space-separated parser should have caught an error in '%s'\", input));\r\n } catch (IOException ioe) {\r\n LOG.debug(\"Expected error: {}\", ioe);\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Parses a space-separated map into a Java map.\\\\\\\\n *\\\\\\\\n * @param input Space-separated map.\\\\\\\\n * @return the parsed Java map.\\\\\\\\n * @throws IOException on parse error.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Parses a space-separated map into a Java map.\\n *\\n * @param input Space-separated map.\\n * @return the parsed Java map.\\n * @throws IOException on parse error.\\n */'public Map parse(String input) throws IOException {\r\n final Map kvs = Maps.newHashMap();\r\n\r\n for (String pair: input.split(\" \")) {\r\n if (pair.isEmpty()) {\r\n continue;\r\n }\r\n final String[] kvSplit = pair.split(\"=\", 2);\r\n if (kvSplit.length != 2) {\r\n throw new IOException(String.format(\r\n \"Invalid argument '%s' in space-separated map '%s'.\", pair, input));\r\n }\r\n\r\n final String key = kvSplit[0];\r\n final String value = kvSplit[1];\r\n\r\n final String existing = kvs.put(key, value);\r\n if (existing != null) {\r\n throw new IOException(String.format(\r\n \"Duplicate key '%s' in space-separated map.'%s'.\", key, input));\r\n }\r\n }\r\n\r\n return kvs;\r\n }", "test_case": "@Test\r\n public void testParseInvalidMapDuplicateKey() throws Exception {\r\n try {\r\n final String input = \"key1=value1 key1=value2\";\r\n mParser.parse(input);\r\n fail(String.format(\"Space-separated parser should have caught an error in '%s'\", input));\r\n } catch (IOException ioe) {\r\n LOG.debug(\"Expected error: {}\", ioe);\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testTooLargeInt() throws Exception {\r\n try {\r\n ToolUtils.createEntityIdFromUserInputs(\"['dummy', 'str1', 'str2', 2147483648, 10]\",\r\n mFormattedLayout);\r\n fail(\"Should fail with EntityIdException.\");\r\n } catch (EntityIdException eie) {\r\n assertEquals(\"Invalid type for component 2147483648 at index 3 in kijiRowKey\",\r\n eie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testTooLargeLong() throws Exception {\r\n\r\n try {\r\n ToolUtils.createEntityIdFromUserInputs(\"['dummy', 'str1', 'str2', 5, 9223372036854775808]\",\r\n mFormattedLayout);\r\n fail(\"Should fail with EntityIdException.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid JSON value: '9223372036854775808', expecting string, \"\r\n + \"int, long, or null.\", ioe.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testIntForLong() throws Exception {\r\n final EntityIdFactory factory = EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout\r\n .getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityId(\"dummy\", \"str1\", \"str2\", 5, 10);\r\n\r\n assertEquals(eid, ToolUtils.createEntityIdFromUserInputs(\"['dummy', 'str1', 'str2', 5, 10]\",\r\n mFormattedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testTooFewComponents() throws IOException {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityId(\"dummy\", \"str1\", \"str2\", 5, null);\r\n\r\n assertEquals(eid,\r\n ToolUtils.createEntityIdFromUserInputs(\"['dummy', 'str1', 'str2', 5]\", mFormattedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsNoParen() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost1,zkhost2:1234/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji-hbase://zkhost1,zkhost2:1234/instance/table/col' : \"\r\n + \"Multiple ZooKeeper hosts must be parenthesized.\", kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testNonNullFollowsNull() throws IOException {\r\n\r\n try {\r\n ToolUtils\r\n .createEntityIdFromUserInputs(\"['dummy', 'str1', 'str2', null, 5]\", mFormattedLayout);\r\n fail(\"Should fail with EntityIdException.\");\r\n } catch (EntityIdException eie) {\r\n assertEquals(\"Non null component follows null component\", eie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testEmptyString() throws IOException {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityId(\"\", \"\", \"\", null, null);\r\n\r\n assertEquals(eid,\r\n ToolUtils.createEntityIdFromUserInputs(\"['', '', '', null, null]\", mFormattedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testASCIIChars() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());\r\n\r\n for (byte b = 32; b < 127; b++) {\r\n for (byte b2 = 32; b2 < 127; b2++) {\r\n final EntityId eid = factory.getEntityId(String.format(\r\n \"dumm%sy\", new String(new byte[]{b, b2}, \"Utf-8\")), \"str1\", \"str2\", 5, 10L);\r\n\r\n assertEquals(eid,\r\n ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mFormattedLayout));\r\n }\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testRawParserLoop() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mRawLayout.getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityIdFromHBaseRowKey(Bytes.toBytes(\"rawRowKey\"));\r\n\r\n assertEquals(eid,\r\n ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mRawLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHashedParserLoop() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mHashedLayout.getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityId(\"hashedRowKey\");\r\n\r\n assertEquals(eid,\r\n ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mHashedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHashPrefixedParserLoop() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mHashPrefixedLayout.getDesc().getKeysFormat());\r\n final EntityId eid = factory.getEntityId(\"hashPrefixedRowKey\");\r\n\r\n assertEquals(\r\n eid, ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mHashPrefixedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHBaseEIDtoRawEID() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mRawLayout.getDesc().getKeysFormat());\r\n final EntityId reid = factory.getEntityId(\"rawEID\");\r\n final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(reid.getHBaseRowKey());\r\n\r\n assertEquals(reid,\r\n ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mRawLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHBaseEIDtoHashedEID() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mHashedLayout.getDesc().getKeysFormat());\r\n final EntityId heid = factory.getEntityId(\"hashedEID\");\r\n final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(heid.getHBaseRowKey());\r\n\r\n assertEquals(heid,\r\n ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mHashedLayout));\r\n\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHBaseEIDtoHashPrefixedEID() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat) mHashPrefixedLayout.getDesc().getKeysFormat());\r\n final EntityId hpeid = factory.getEntityId(\"hashPrefixedEID\");\r\n final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(hpeid.getHBaseRowKey());\r\n\r\n assertEquals(hpeid,\r\n ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mHashPrefixedLayout));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Parses a command-line flag specifying an entity ID.\\\\\\\\n *\\\\\\\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\\\\\\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\\\\\\\n * necessary. The prefix is not always necessary.\\\\\\\\n *\\\\\\\\n * @param entityFlag Command-line flag specifying an entity ID.\\\\\\\\n * @param layout Layout of the table describing the entity ID format.\\\\\\\\n * @return the entity ID as specified in the flags.\\\\\\\\n * @throws IOException on I/O error.\\\\\\\\n */\\', \\'\\')', \"('', '// HBase row key specification\\\\n')\", \"('', '// Kiji row key specification\\\\n')\"]", "focal_method": "b'/**\\n * Parses a command-line flag specifying an entity ID.\\n *\\n *
  • HBase row key specifications must be prefixed with \"hbase=...\"\\n *
  • Kiji row key specifications may be explicitly prefixed with \"kiji=...\" if\\n * necessary. The prefix is not always necessary.\\n *\\n * @param entityFlag Command-line flag specifying an entity ID.\\n * @param layout Layout of the table describing the entity ID format.\\n * @return the entity ID as specified in the flags.\\n * @throws IOException on I/O error.\\n */'public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)\r\n throws IOException {\r\n Preconditions.checkNotNull(entityFlag);\r\n\r\n final EntityIdFactory factory = EntityIdFactory.getFactory(layout);\r\n\r\n if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {\r\n // HBase row key specification\r\n final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());\r\n final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);\r\n return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);\r\n\r\n } else {\r\n // Kiji row key specification\r\n final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)\r\n ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())\r\n : entityFlag;\r\n\r\n return parseKijiRowKey(kijiSpec, factory, layout);\r\n }\r\n }", "test_case": "@Test\r\n public void testHBaseEIDtoFormattedEID() throws Exception {\r\n final EntityIdFactory factory =\r\n EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());\r\n final EntityId feid = factory.getEntityId(\"dummy\", \"str1\", \"str2\", 5, 10);\r\n final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(feid.getHBaseRowKey());\r\n\r\n assertEquals(feid,\r\n ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mFormattedLayout));\r\n }"} {"description": "[\"('/** {@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')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public Filter toHBaseFilter(Context context) throws IOException {\r\n // In the case that we have enough information to generate a prefix, we will\r\n // construct a PrefixFilter that is AND'ed with the RowFilter. This way,\r\n // when the scan passes the end of the prefix, it can end the filtering\r\n // process quickly.\r\n boolean addPrefixFilter = false;\r\n ByteArrayOutputStream prefixBytes = new ByteArrayOutputStream();\r\n\r\n // Define a regular expression that effectively creates a mask for the row\r\n // key based on the key format and the components passed in. Prefix hashes\r\n // are skipped over, and null components match any value.\r\n // ISO-8859-1 is used so that numerals map to valid characters\r\n // see http://stackoverflow.com/a/1387184\r\n\r\n // Use the embedded flag (?s) to turn on single-line mode; this makes the\r\n // '.' match on line terminators. The RegexStringComparator uses the DOTALL\r\n // flag during construction, but it does not use that flag upon\r\n // deserialization. This bug has been fixed in HBASE-5667, part of the 0.95\r\n // release.\r\n StringBuilder regex = new StringBuilder(\"(?s)^\"); // ^ matches the beginning of the string\r\n if (null != mRowKeyFormat.getSalt()) {\r\n if (mRowKeyFormat.getSalt().getHashSize() > 0) {\r\n // If all of the components included in the hash have been specified,\r\n // then match on the value of the hash\r\n Object[] prefixComponents =\r\n getNonNullPrefixComponents(mComponents, mRowKeyFormat.getRangeScanStartIndex());\r\n if (prefixComponents.length == mRowKeyFormat.getRangeScanStartIndex()) {\r\n ByteArrayOutputStream tohash = new ByteArrayOutputStream();\r\n for (Object component : prefixComponents) {\r\n byte[] componentBytes = toBytes(component);\r\n tohash.write(componentBytes, 0, componentBytes.length);\r\n }\r\n byte[] hashed = Arrays.copyOfRange(Hasher.hash(tohash.toByteArray()), 0,\r\n mRowKeyFormat.getSalt().getHashSize());\r\n for (byte hashedByte : hashed) {\r\n regex.append(String.format(\"\\\\x%02x\", hashedByte & 0xFF));\r\n }\r\n\r\n addPrefixFilter = true;\r\n // Write the hashed bytes to the prefix buffer\r\n prefixBytes.write(hashed, 0, hashed.length);\r\n } else {\r\n // match any character exactly 'hash size' number of times\r\n regex.append(\".{\").append(mRowKeyFormat.getSalt().getHashSize()).append(\"}\");\r\n }\r\n }\r\n }\r\n // Only add to the prefix buffer until we hit a null component. We do this\r\n // here, because the prefix is going to expect to have 0x00 component\r\n // terminators, which we put in during this loop but not in the loop above.\r\n boolean hitNullComponent = false;\r\n for (int i = 0; i < mComponents.length; i++) {\r\n final Object component = mComponents[i];\r\n switch (mRowKeyFormat.getComponents().get(i).getType()) {\r\n case INTEGER:\r\n if (null == component) {\r\n // null integers can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_INT).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Integer) component);\r\n // match each byte in the integer using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case LONG:\r\n if (null == component) {\r\n // null longs can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_LONG).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Long) component);\r\n // match each byte in the long using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case STRING:\r\n if (null == component) {\r\n // match any non-zero character at least once, followed by a zero\r\n // delimiter, or match nothing at all in case the component was at\r\n // the end of the EntityId and skipped entirely\r\n regex.append(\"([^\\\\x00]+\\\\x00)?\");\r\n hitNullComponent = true;\r\n } else {\r\n // FormattedEntityId converts a string component to UTF-8 bytes to\r\n // create the HBase key. RegexStringComparator will convert the\r\n // value it sees (ie, the HBase key) to a string using ISO-8859-1.\r\n // Therefore, we need to write ISO-8859-1 characters to our regex so\r\n // that the comparison happens correctly.\r\n byte[] utfBytes = toBytes((String) component);\r\n String isoString = new String(utfBytes, Charsets.ISO_8859_1);\r\n regex.append(isoString).append(\"\\\\x00\");\r\n if (!hitNullComponent) {\r\n prefixBytes.write(utfBytes, 0, utfBytes.length);\r\n prefixBytes.write((byte) 0);\r\n }\r\n }\r\n break;\r\n default:\r\n throw new IllegalStateException(\"Unknown component type: \"\r\n + mRowKeyFormat.getComponents().get(i).getType());\r\n }\r\n }\r\n regex.append(\"$\"); // $ matches the end of the string\r\n\r\n final RowFilter regexRowFilter =\r\n SchemaPlatformBridge.get().createRowFilterFromRegex(CompareOp.EQUAL, regex.toString());\r\n if (addPrefixFilter) {\r\n return new FilterList(new PrefixFilter(prefixBytes.toByteArray()), regexRowFilter);\r\n }\r\n return regexRowFilter;\r\n }", "test_case": "@Test\r\n public void testHashIsCalculatedWhenAllHashComponentsAreSpecified() throws Exception {\r\n final int hashLength = 2;\r\n RowKeyFormat2.Builder builder = RowKeyFormat2.newBuilder()\r\n .setEncoding(RowKeyEncoding.FORMATTED)\r\n .setSalt(new HashSpec(HashType.MD5, hashLength, false))\r\n .setRangeScanStartIndex(1);\r\n\r\n List components = ImmutableList.of(\r\n new RowKeyComponent(\"id\", INTEGER), // this one is included in the hash\r\n new RowKeyComponent(\"ts\", LONG)); // this one is not\r\n builder.setComponents(components);\r\n RowKeyFormat2 rowKeyFormat = builder.build();\r\n\r\n EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);\r\n FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100);\r\n Object[] componentValues = new Object[] { Integer.valueOf(100), Long.valueOf(900000L) };\r\n runTest(rowKeyFormat, filter, factory, INCLUDE, componentValues);\r\n\r\n EntityId entityId = factory.getEntityId(componentValues);\r\n byte[] hbaseKey = entityId.getHBaseRowKey();\r\n Filter hbaseFilter = filter.toHBaseFilter(null);\r\n\r\n // A row key with a different hash but the same first component should be\r\n // excluded by the filter. The hash is 0x9f0f\r\n hbaseKey[0] = (byte) 0x7F;\r\n hbaseKey[1] = (byte) 0xFF;\r\n boolean filtered = hbaseFilter.filterRowKey(hbaseKey, 0, hbaseKey.length);\r\n doInclusionAssert(rowKeyFormat, filter, entityId, hbaseFilter, hbaseKey, EXCLUDE);\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsMultiplePorts() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost1:1234,zkhost2:2345/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji-hbase://zkhost1:1234,zkhost2:2345/instance/table/col'\"\r\n + \" : Invalid ZooKeeper ensemble cluster identifier.\", kurie.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\\\\\\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\\\\\\\n * the JVM to no longer be reachable.\\\\\\\\n *\\\\\\\\n * @param autoReferenceCountable to be registered to this reaper.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\n * the JVM to no longer be reachable.\\n *\\n * @param autoReferenceCountable to be registered to this reaper.\\n */'public void registerAutoReferenceCounted(AutoReferenceCounted autoReferenceCountable) {\r\n Preconditions.checkState(mIsOpen,\r\n \"cannot register an AutoReferenceCounted to a closed AutoReferenceCountedReaper.\");\r\n LOG.debug(\"Registering AutoReferenceCounted {}.\", autoReferenceCountable);\r\n mReferences.add(\r\n new CloseablePhantomRef(\r\n autoReferenceCountable,\r\n mReferenceQueue,\r\n autoReferenceCountable.getCloseableResources())\r\n );\r\n }", "test_case": "@Test\r\n public void testReaperWillReapAutoReferenceCounted() throws Exception {\r\n CountDownLatch latch = new CountDownLatch(1);\r\n mReaper.registerAutoReferenceCounted(new LatchAutoReferenceCountable(latch));\r\n System.gc(); // Force the phantom ref to be enqueued\r\n\r\n Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\\\\\\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\\\\\\\n * the JVM to no longer be reachable.\\\\\\\\n *\\\\\\\\n * @param autoReferenceCountable to be registered to this reaper.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\n * the JVM to no longer be reachable.\\n *\\n * @param autoReferenceCountable to be registered to this reaper.\\n */'public void registerAutoReferenceCounted(AutoReferenceCounted autoReferenceCountable) {\r\n Preconditions.checkState(mIsOpen,\r\n \"cannot register an AutoReferenceCounted to a closed AutoReferenceCountedReaper.\");\r\n LOG.debug(\"Registering AutoReferenceCounted {}.\", autoReferenceCountable);\r\n mReferences.add(\r\n new CloseablePhantomRef(\r\n autoReferenceCountable,\r\n mReferenceQueue,\r\n autoReferenceCountable.getCloseableResources())\r\n );\r\n }", "test_case": "@Test\r\n public void testCloserWillCloseAutoReferenceCountedInWeakSet() throws Exception {\r\n Set set =\r\n Collections.newSetFromMap(\r\n new MapMaker().weakKeys().makeMap());\r\n\r\n final CountDownLatch latch = new CountDownLatch(1);\r\n AutoReferenceCounted closeable = new LatchAutoReferenceCountable(latch);\r\n\r\n set.add(closeable);\r\n mReaper.registerAutoReferenceCounted(closeable);\r\n closeable = null;\r\n\r\n System.gc();\r\n Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\\\\\\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\\\\\\\n * the JVM to no longer be reachable.\\\\\\\\n *\\\\\\\\n * @param autoReferenceCountable to be registered to this reaper.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\n * the JVM to no longer be reachable.\\n *\\n * @param autoReferenceCountable to be registered to this reaper.\\n */'public void registerAutoReferenceCounted(AutoReferenceCounted autoReferenceCountable) {\r\n Preconditions.checkState(mIsOpen,\r\n \"cannot register an AutoReferenceCounted to a closed AutoReferenceCountedReaper.\");\r\n LOG.debug(\"Registering AutoReferenceCounted {}.\", autoReferenceCountable);\r\n mReferences.add(\r\n new CloseablePhantomRef(\r\n autoReferenceCountable,\r\n mReferenceQueue,\r\n autoReferenceCountable.getCloseableResources())\r\n );\r\n }", "test_case": "@Test\r\n public void testCloserWillCloseAutoReferenceCountedInWeakCache() throws Exception {\r\n CountDownLatch latch = new CountDownLatch(1);\r\n\r\n final LoadingCache cache = CacheBuilder\r\n .newBuilder()\r\n .weakValues()\r\n .build(new CacheLoader() {\r\n @Override\r\n public AutoReferenceCounted load(CountDownLatch latch) throws Exception {\r\n AutoReferenceCounted closeable = new LatchAutoReferenceCountable(latch);\r\n mReaper.registerAutoReferenceCounted(closeable);\r\n return closeable;\r\n }\r\n });\r\n\r\n cache.get(latch); // force creation\r\n\r\n System.gc();\r\n Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\\\\\\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\\\\\\\n * the JVM to no longer be reachable.\\\\\\\\n *\\\\\\\\n * @param autoReferenceCountable to be registered to this reaper.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Register an {@link AutoReferenceCounted} instance to be cleaned up by this\\n * {@code AutoReferenceCountedReaper} when the {@link AutoReferenceCounted} is determined by\\n * the JVM to no longer be reachable.\\n *\\n * @param autoReferenceCountable to be registered to this reaper.\\n */'public void registerAutoReferenceCounted(AutoReferenceCounted autoReferenceCountable) {\r\n Preconditions.checkState(mIsOpen,\r\n \"cannot register an AutoReferenceCounted to a closed AutoReferenceCountedReaper.\");\r\n LOG.debug(\"Registering AutoReferenceCounted {}.\", autoReferenceCountable);\r\n mReferences.add(\r\n new CloseablePhantomRef(\r\n autoReferenceCountable,\r\n mReferenceQueue,\r\n autoReferenceCountable.getCloseableResources())\r\n );\r\n }", "test_case": "@Test\r\n public void testWeakCacheWillBeCleanedUp() throws Exception {\r\n CountDownLatch latch = new CountDownLatch(2);\r\n\r\n final LoadingCache cache = CacheBuilder\r\n .newBuilder()\r\n .weakValues()\r\n .build(new CacheLoader() {\r\n @Override\r\n public AutoReferenceCounted load(CountDownLatch latch) throws Exception {\r\n AutoReferenceCounted closeable = new LatchAutoReferenceCountable(latch);\r\n mReaper.registerAutoReferenceCounted(closeable);\r\n return closeable;\r\n }\r\n });\r\n\r\n cache.get(latch);\r\n System.gc();\r\n cache.get(latch);\r\n System.gc();\r\n Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));\r\n }"} {"description": "Reports whether the given schema is an optional type ie a union null Type @param schema The schema to test @return the optional type if the specified schema describes an optional type null otherwise", "focal_method": "b'/**\\n * Reports whether the given schema is an optional type (ie. a union { null, Type }).\\n *\\n * @param schema The schema to test.\\n * @return the optional type, if the specified schema describes an optional type, null otherwise.\\n */'public static Schema getOptionalType(Schema schema) {\r\n Preconditions.checkArgument(schema.getType() == Schema.Type.UNION);\r\n final List types = schema.getTypes();\r\n if (types.size() != 2) {\r\n return null;\r\n }\r\n if (types.get(0).getType() == Schema.Type.NULL) {\r\n return types.get(1);\r\n } else if (types.get(1).getType() == Schema.Type.NULL) {\r\n return types.get(0);\r\n } else {\r\n return null;\r\n }\r\n }", "test_case": "@Test\r\n public void testGetOptionalType() throws Exception {\r\n final List unionSchemas = Lists.newArrayList(\r\n INT_SCHEMA,\r\n NULL_SCHEMA);\r\n final Schema optionalSchema = Schema.createUnion(unionSchemas);\r\n final Schema optionalReverseSchema = Schema.createUnion(Lists.reverse(unionSchemas));\r\n\r\n // Ensure that the optional type is retrievable.\r\n assertEquals(INT_SCHEMA, AvroUtils.getOptionalType(optionalSchema));\r\n assertEquals(INT_SCHEMA, AvroUtils.getOptionalType(optionalReverseSchema));\r\n }"} {"description": "[\"('/**\\\\\\\\n * Reports whether the given schema is an optional type (ie. a union { null, Type }).\\\\\\\\n *\\\\\\\\n * @param schema The schema to test.\\\\\\\\n * @return the optional type, if the specified schema describes an optional type, null otherwise.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Reports whether the given schema is an optional type (ie. a union { null, Type }).\\n *\\n * @param schema The schema to test.\\n * @return the optional type, if the specified schema describes an optional type, null otherwise.\\n */'public static Schema getOptionalType(Schema schema) {\r\n Preconditions.checkArgument(schema.getType() == Schema.Type.UNION);\r\n final List types = schema.getTypes();\r\n if (types.size() != 2) {\r\n return null;\r\n }\r\n if (types.get(0).getType() == Schema.Type.NULL) {\r\n return types.get(1);\r\n } else if (types.get(1).getType() == Schema.Type.NULL) {\r\n return types.get(0);\r\n } else {\r\n return null;\r\n }\r\n }", "test_case": "@Test\r\n public void testGetNonOptionalType() throws Exception {\r\n final List unionSchemas = Lists.newArrayList(\r\n INT_SCHEMA,\r\n STRING_SCHEMA,\r\n NULL_SCHEMA);\r\n final Schema nonOptionalSchema = Schema.createUnion(unionSchemas);\r\n\r\n // Ensure that null gets returned when the schema provided isn't an optional type.\r\n assertEquals(null, AvroUtils.getOptionalType(nonOptionalSchema));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateSchemaPairMissingField() throws Exception {\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null));\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final AvroUtils.SchemaPairCompatibility expectedResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n WRITER_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n\r\n // Test omitting a field.\r\n assertEquals(expectedResult, AvroUtils.checkReaderWriterCompatibility(reader, WRITER_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateSchemaPairMissingSecondField() throws Exception {\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final AvroUtils.SchemaPairCompatibility expectedResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n WRITER_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n\r\n // Test omitting other field.\r\n assertEquals(expectedResult, AvroUtils.checkReaderWriterCompatibility(reader, WRITER_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateSchemaPairAllFields() throws Exception {\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final AvroUtils.SchemaPairCompatibility expectedResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n WRITER_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n\r\n // Test with all fields.\r\n assertEquals(expectedResult, AvroUtils.checkReaderWriterCompatibility(reader, WRITER_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateSchemaNewFieldWithDefault() throws Exception {\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, IntNode.valueOf(42)));\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final AvroUtils.SchemaPairCompatibility expectedResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n WRITER_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n\r\n // Test new field with default value.\r\n assertEquals(expectedResult, AvroUtils.checkReaderWriterCompatibility(reader, WRITER_SCHEMA));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleColumns() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://zkhost1,zkhost2/default/table/col1,col2\").build();\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(KijiURI.DEFAULT_ZOOKEEPER_CLIENT_PORT, uri.getZookeeperClientPort());\r\n assertEquals(\"default\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(2, uri.getColumns().size());\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateSchemaNewField() throws Exception {\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, null));\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final AvroUtils.SchemaPairCompatibility expectedResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.INCOMPATIBLE,\r\n reader,\r\n WRITER_SCHEMA,\r\n String.format(\r\n \"Data encoded using writer schema:\\n%s\\n\"\r\n + \"will or may fail to decode using reader schema:\\n%s\\n\",\r\n WRITER_SCHEMA.toString(true),\r\n reader.toString(true)));\r\n\r\n // Test new field without default value.\r\n assertEquals(expectedResult, AvroUtils.checkReaderWriterCompatibility(reader, WRITER_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidateArrayWriterSchema() throws Exception {\r\n final Schema validReader = Schema.createArray(STRING_SCHEMA);\r\n final Schema invalidReader = Schema.createMap(STRING_SCHEMA);\r\n final AvroUtils.SchemaPairCompatibility validResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n validReader,\r\n STRING_ARRAY_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility invalidResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.INCOMPATIBLE,\r\n invalidReader,\r\n STRING_ARRAY_SCHEMA,\r\n String.format(\r\n \"Data encoded using writer schema:\\n%s\\n\"\r\n + \"will or may fail to decode using reader schema:\\n%s\\n\",\r\n STRING_ARRAY_SCHEMA.toString(true),\r\n invalidReader.toString(true)));\r\n\r\n assertEquals(\r\n validResult,\r\n AvroUtils.checkReaderWriterCompatibility(validReader, STRING_ARRAY_SCHEMA));\r\n assertEquals(\r\n invalidResult,\r\n AvroUtils.checkReaderWriterCompatibility(invalidReader, STRING_ARRAY_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testValidatePrimitiveWriterSchema() throws Exception {\r\n final Schema validReader = Schema.create(Schema.Type.STRING);\r\n final AvroUtils.SchemaPairCompatibility validResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n validReader,\r\n STRING_SCHEMA,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility invalidResult =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.INCOMPATIBLE,\r\n INT_SCHEMA,\r\n STRING_SCHEMA,\r\n String.format(\r\n \"Data encoded using writer schema:\\n%s\\n\"\r\n + \"will or may fail to decode using reader schema:\\n%s\\n\",\r\n STRING_SCHEMA.toString(true),\r\n INT_SCHEMA.toString(true)));\r\n\r\n assertEquals(\r\n validResult,\r\n AvroUtils.checkReaderWriterCompatibility(validReader, STRING_SCHEMA));\r\n assertEquals(\r\n invalidResult,\r\n AvroUtils.checkReaderWriterCompatibility(INT_SCHEMA, STRING_SCHEMA));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testUnionReaderWriterSubsetIncompatibility() {\r\n final Schema unionWriter = Schema.createUnion(\r\n Lists.newArrayList(INT_SCHEMA, STRING_SCHEMA));\r\n final Schema unionReader = Schema.createUnion(\r\n Lists.newArrayList(STRING_SCHEMA));\r\n final SchemaPairCompatibility result =\r\n AvroUtils.checkReaderWriterCompatibility(unionReader, unionWriter);\r\n assertEquals(SchemaCompatibilityType.INCOMPATIBLE, result.getType());\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testReaderWriterCompatibility() {\r\n for (ReaderWriter readerWriter : COMPATIBLE_READER_WRITER_TEST_CASES) {\r\n final Schema reader = readerWriter.getReader();\r\n final Schema writer = readerWriter.getWriter();\r\n LOG.debug(\"Testing compatibility of reader {} with writer {}.\", reader, writer);\r\n final SchemaPairCompatibility result =\r\n AvroUtils.checkReaderWriterCompatibility(reader, writer);\r\n assertEquals(String.format(\r\n \"Expecting reader %s to be compatible with writer %s, but tested incompatible.\",\r\n reader, writer),\r\n SchemaCompatibilityType.COMPATIBLE, result.getType());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final Schema reader,\r\n final Schema writer\r\n ) {\r\n final SchemaCompatibilityType compatibility =\r\n new ReaderWriterCompatiblityChecker()\r\n .getCompatibility(reader, writer);\r\n\r\n final String message;\r\n switch (compatibility) {\r\n case INCOMPATIBLE: {\r\n message = String.format(\r\n \"Data encoded using writer schema:%n%s%n\"\r\n + \"will or may fail to decode using reader schema:%n%s%n\",\r\n writer.toString(true),\r\n reader.toString(true));\r\n break;\r\n }\r\n case COMPATIBLE: {\r\n message = READER_WRITER_COMPATIBLE_MESSAGE;\r\n break;\r\n }\r\n default: throw new InternalKijiError(\"Unknown compatibility: \" + compatibility);\r\n }\r\n\r\n return new SchemaPairCompatibility(\r\n compatibility,\r\n reader,\r\n writer,\r\n message);\r\n }", "test_case": "@Test\r\n public void testReaderWriterIncompatibility() {\r\n for (ReaderWriter readerWriter : INCOMPATIBLE_READER_WRITER_TEST_CASES) {\r\n final Schema reader = readerWriter.getReader();\r\n final Schema writer = readerWriter.getWriter();\r\n LOG.debug(\"Testing incompatibility of reader {} with writer {}.\", reader, writer);\r\n final SchemaPairCompatibility result =\r\n AvroUtils.checkReaderWriterCompatibility(reader, writer);\r\n assertEquals(String.format(\r\n \"Expecting reader %s to be incompatible with writer %s, but tested compatible.\",\r\n reader, writer),\r\n SchemaCompatibilityType.INCOMPATIBLE, result.getType());\r\n }\r\n }"} {"description": "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", "focal_method": "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(\r\n Iterator readers,\r\n Schema writer) {\r\n final List results = Lists.newArrayList();\r\n while (readers.hasNext()) {\r\n // Check compatibility between each reader/writer pair.\r\n results.add(checkReaderWriterCompatibility(readers.next(), writer));\r\n }\r\n return new SchemaSetCompatibility(results);\r\n }", "test_case": "@Test\r\n public void testCheckWriterCompatibility() throws Exception {\r\n // Setup schema fields.\r\n final List writerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n final List readerFields1 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, IntNode.valueOf(42)));\r\n final List readerFields2 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, IntNode.valueOf(42)));\r\n final List readerFields3 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n final List readerFields4 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, null));\r\n\r\n // Setup schemas.\r\n final Schema writer = Schema.createRecord(writerFields);\r\n final Schema reader1 = Schema.createRecord(readerFields1);\r\n final Schema reader2 = Schema.createRecord(readerFields2);\r\n final Schema reader3 = Schema.createRecord(readerFields3);\r\n final Schema reader4 = Schema.createRecord(readerFields4);\r\n final Set readers = Sets.newHashSet(\r\n reader1,\r\n reader2,\r\n reader3,\r\n reader4);\r\n\r\n // Setup expectations.\r\n final AvroUtils.SchemaPairCompatibility result1 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader1,\r\n writer,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility result2 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader2,\r\n writer,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility result3 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader3,\r\n writer,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility result4 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.INCOMPATIBLE,\r\n reader4,\r\n writer,\r\n String.format(\r\n \"Data encoded using writer schema:\\n%s\\n\"\r\n + \"will or may fail to decode using reader schema:\\n%s\\n\",\r\n writer.toString(true),\r\n reader4.toString(true)));\r\n\r\n // Perform the check.\r\n final AvroUtils.SchemaSetCompatibility results = AvroUtils\r\n .checkWriterCompatibility(readers.iterator(), writer);\r\n\r\n // Ensure that the results contain the expected values.\r\n assertEquals(AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, results.getType());\r\n assertTrue(results.getCauses().contains(result1));\r\n assertTrue(results.getCauses().contains(result2));\r\n assertTrue(results.getCauses().contains(result3));\r\n assertTrue(results.getCauses().contains(result4));\r\n }"} {"description": "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", "focal_method": "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(\r\n Schema reader,\r\n Iterator writers) {\r\n final List results = Lists.newArrayList();\r\n while (writers.hasNext()) {\r\n // Check compatibility between each reader/writer pair.\r\n results.add(checkReaderWriterCompatibility(reader, writers.next()));\r\n }\r\n return new SchemaSetCompatibility(results);\r\n }", "test_case": "@Test\r\n public void testCheckReaderCompatibility() throws Exception {\r\n // Setup schema fields.\r\n final List writerFields1 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n final List writerFields2 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, null));\r\n final List writerFields3 = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"newfield1\", INT_SCHEMA, null, null));\r\n final List readerFields = Lists.newArrayList(\r\n new Schema.Field(\"oldfield1\", INT_SCHEMA, null, null),\r\n new Schema.Field(\"oldfield2\", STRING_SCHEMA, null, null));\r\n\r\n // Setup schemas.\r\n final Schema writer1 = Schema.createRecord(writerFields1);\r\n final Schema writer2 = Schema.createRecord(writerFields2);\r\n final Schema writer3 = Schema.createRecord(writerFields3);\r\n final Schema reader = Schema.createRecord(readerFields);\r\n final Set written = Sets.newHashSet(writer1);\r\n final Set writers = Sets.newHashSet(writer2, writer3);\r\n\r\n // Setup expectations.\r\n final AvroUtils.SchemaPairCompatibility result1 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n writer1,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility result2 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.COMPATIBLE,\r\n reader,\r\n writer2,\r\n AvroUtils.READER_WRITER_COMPATIBLE_MESSAGE);\r\n final AvroUtils.SchemaPairCompatibility result3 =\r\n new AvroUtils.SchemaPairCompatibility(\r\n AvroUtils.SchemaCompatibilityType.INCOMPATIBLE,\r\n reader,\r\n writer3,\r\n String.format(\r\n \"Data encoded using writer schema:\\n%s\\n\"\r\n + \"will or may fail to decode using reader schema:\\n%s\\n\",\r\n writer3.toString(true),\r\n reader.toString(true)));\r\n\r\n // Perform the check.\r\n final AvroUtils.SchemaSetCompatibility results = AvroUtils\r\n .checkReaderCompatibility(reader, Iterators.concat(written.iterator(), writers.iterator()));\r\n\r\n // Ensure that the results contain the expected values.\r\n assertEquals(AvroUtils.SchemaCompatibilityType.INCOMPATIBLE, results.getType());\r\n assertTrue(results.getCauses().contains(result1));\r\n assertTrue(results.getCauses().contains(result2));\r\n assertTrue(results.getCauses().contains(result3));\r\n }"} {"description": "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", "focal_method": "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(\r\n final KijiSchemaTable schemaTable,\r\n final AvroSchema first,\r\n final AvroSchema second\r\n ) throws IOException {\r\n final AvroSchemaResolver resolver = new SchemaTableAvroResolver(schemaTable);\r\n\r\n return Objects.equal(resolver.apply(first), resolver.apply(second));\r\n }", "test_case": "@Test\r\n public void testAvroSchemaEquals() throws IOException {\r\n final KijiSchemaTable schemaTable = getKiji().getSchemaTable();\r\n\r\n final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA);\r\n final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA);\r\n final String stringJSON = STRING_SCHEMA.toString();\r\n final String intJSON = INT_SCHEMA.toString();\r\n\r\n final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build();\r\n final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build();\r\n final AvroSchema intUIDAS = AvroSchema.newBuilder().setUid(intUID).build();\r\n final AvroSchema intJSONAS = AvroSchema.newBuilder().setJson(intJSON).build();\r\n\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, stringUIDAS));\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, stringJSONAS));\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, stringUIDAS));\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intUIDAS, intUIDAS));\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intUIDAS, intJSONAS));\r\n assertTrue(AvroUtils.avroSchemaEquals(schemaTable, intJSONAS, intUIDAS));\r\n\r\n assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, intUIDAS));\r\n assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringUIDAS, intJSONAS));\r\n assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, intJSONAS));\r\n assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, intUIDAS));\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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(\r\n final KijiSchemaTable schemaTable,\r\n final Collection schemaCollection,\r\n final AvroSchema element\r\n ) throws IOException {\r\n for (AvroSchema schema : schemaCollection) {\r\n if (avroSchemaEquals(schemaTable, schema, element)) {\r\n return true;\r\n }\r\n }\r\n // If none match, return false.\r\n return false;\r\n }", "test_case": "@Test\r\n public void testAvroSchemaListContains() throws IOException {\r\n final KijiSchemaTable schemaTable = getKiji().getSchemaTable();\r\n\r\n final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA);\r\n final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA);\r\n final String stringJSON = STRING_SCHEMA.toString();\r\n final String intJSON = INT_SCHEMA.toString();\r\n\r\n final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build();\r\n final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build();\r\n final AvroSchema intUIDAS = AvroSchema.newBuilder().setUid(intUID).build();\r\n final AvroSchema intJSONAS = AvroSchema.newBuilder().setJson(intJSON).build();\r\n\r\n final List stringList = Lists.newArrayList(stringJSONAS, stringUIDAS);\r\n final List intList = Lists.newArrayList(intJSONAS, intUIDAS);\r\n final List bothList = Lists.newArrayList(stringJSONAS, intUIDAS);\r\n\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, stringJSONAS));\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, stringUIDAS));\r\n assertFalse(AvroUtils.avroSchemaCollectionContains(schemaTable, stringList, intUIDAS));\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, intJSONAS));\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, intUIDAS));\r\n assertFalse(AvroUtils.avroSchemaCollectionContains(schemaTable, intList, stringUIDAS));\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, bothList, stringJSONAS));\r\n assertTrue(AvroUtils.avroSchemaCollectionContains(schemaTable, bothList, intUIDAS));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testExtraPath() {\r\n try {\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/extra\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji-hbase://(zkhost1,zkhost2):1234/\"\r\n + \"instance/table/col/extra' : Too many path segments.\", kurie.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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 {\r\n final ObjectMapper mapper = new ObjectMapper();\r\n final JsonParser parser = new JsonFactory().createJsonParser(json)\r\n .enable(Feature.ALLOW_COMMENTS)\r\n .enable(Feature.ALLOW_SINGLE_QUOTES)\r\n .enable(Feature.ALLOW_UNQUOTED_FIELD_NAMES);\r\n final JsonNode root = mapper.readTree(parser);\r\n return fromJsonNode(root, schema);\r\n }", "test_case": "@Test\r\n public void testPrimitivesFromJson() throws Exception {\r\n assertEquals((Integer) 1, FromJson.fromJsonString(\"1\", Schema.create(Schema.Type.INT)));\r\n assertEquals((Long) 1L, FromJson.fromJsonString(\"1\", Schema.create(Schema.Type.LONG)));\r\n assertEquals((Float) 1.0f, FromJson.fromJsonString(\"1\", Schema.create(Schema.Type.FLOAT)));\r\n assertEquals((Double) 1.0, FromJson.fromJsonString(\"1\", Schema.create(Schema.Type.DOUBLE)));\r\n assertEquals((Float) 1.0f, FromJson.fromJsonString(\"1.0\", Schema.create(Schema.Type.FLOAT)));\r\n assertEquals((Double) 1.0, FromJson.fromJsonString(\"1.0\", Schema.create(Schema.Type.DOUBLE)));\r\n assertEquals(\"Text\", FromJson.fromJsonString(\"'Text'\", Schema.create(Schema.Type.STRING)));\r\n assertEquals(\"Text\", FromJson.fromJsonString(\"\\\"Text\\\"\", Schema.create(Schema.Type.STRING)));\r\n assertEquals(true, FromJson.fromJsonString(\"true\", Schema.create(Schema.Type.BOOLEAN)));\r\n assertEquals(false, FromJson.fromJsonString(\"false\", Schema.create(Schema.Type.BOOLEAN)));\r\n }"} {"description": "Hashes the input string @param input The string to hash @return The 128bit MD5 hash of the input", "focal_method": "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) {\r\n try {\r\n return hash(input.getBytes(\"UTF-8\"));\r\n } catch (UnsupportedEncodingException e) {\r\n throw new RuntimeException(e);\r\n }\r\n }", "test_case": "@Test\r\n public void testHash() {\r\n assertArrayEquals(Hasher.hash(\"foo\"), Hasher.hash(\"foo\"));\r\n\r\n // 16 bytes = 128-bit MD5.\r\n assertEquals(16, Hasher.hash(\"bar\").length);\r\n\r\n assertFalse(Arrays.equals(Hasher.hash(\"foo\"), Hasher.hash(\"bar\")));\r\n }"} {"description": "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", "focal_method": "b'/**\\n * Determines whether a string is a valid Java identifier.\\n *\\n *

    A valid Java identifier may not start with a number, but may contain any\\n * combination of letters, digits, underscores, or dollar signs.

    \\n *\\n *

    See the \\n * Java Language Specification

    \\n *\\n * @param identifier The identifier to test for validity.\\n * @return Whether the identifier was valid.\\n */'public static boolean isValidIdentifier(String identifier) {\r\n if (identifier.isEmpty() || !Character.isJavaIdentifierStart(identifier.charAt(0))) {\r\n return false;\r\n }\r\n for (int i = 1; i < identifier.length(); i++) {\r\n if (!Character.isJavaIdentifierPart(identifier.charAt(i))) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }", "test_case": "@Test\r\n public void testIsValidIdentifier() {\r\n assertFalse(JavaIdentifiers.isValidIdentifier(\"\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"a\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"B\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"_\"));\r\n assertFalse(JavaIdentifiers.isValidIdentifier(\"-\"));\r\n assertFalse(JavaIdentifiers.isValidIdentifier(\".\"));\r\n assertFalse(JavaIdentifiers.isValidIdentifier(\"0\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"_1\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"_c\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"_giw07nf\"));\r\n assertTrue(JavaIdentifiers.isValidIdentifier(\"giw07nf\"));\r\n assertFalse(JavaIdentifiers.isValidIdentifier(\"2giw07nf\"));\r\n }"} {"description": "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", "focal_method": "b'/**\\n * Determines whether a string could be the name of a Java class.\\n *\\n *

    If this method returns true, it does not necessarily mean that the Java class with\\n * className exists; it only means that one could write a Java class with\\n * that fully-qualified name.

    \\n *\\n * @param className A string to test.\\n * @return Whether the class name was valid.\\n */'public static boolean isValidClassName(String className) {\r\n // A valid class name is a bunch of valid Java identifiers separated by dots.\r\n for (String part : StringUtils.splitByWholeSeparatorPreserveAllTokens(className, \".\")) {\r\n if (!isValidIdentifier(part)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }", "test_case": "@Test\r\n public void testIsValidClassName() {\r\n assertTrue(JavaIdentifiers.isValidClassName(\"org.kiji.schema.Foo\"));\r\n assertFalse(JavaIdentifiers.isValidClassName(\"org.kiji.schema..Foo\"));\r\n assertTrue(JavaIdentifiers.isValidClassName(\"org.kiji.schema.Foo$Bar\"));\r\n assertTrue(JavaIdentifiers.isValidClassName(\"Foo\"));\r\n assertFalse(JavaIdentifiers.isValidClassName(\"Foo.\"));\r\n assertFalse(JavaIdentifiers.isValidClassName(\".Foo\"));\r\n assertTrue(JavaIdentifiers.isValidClassName(\"_Foo\"));\r\n assertTrue(JavaIdentifiers.isValidClassName(\"com._Foo\"));\r\n assertFalse(JavaIdentifiers.isValidClassName(\"com.8Foo\"));\r\n assertTrue(JavaIdentifiers.isValidClassName(\"com.Foo8\"));\r\n }"} {"description": "Utility class may not be instantiated", "focal_method": "b'/** Utility class may not be instantiated. */'private JvmId() {\r\n }", "test_case": "@Test\r\n public void testJvmId() throws Exception {\r\n final String jvmId = JvmId.get();\r\n LOG.info(\"JVM ID: {}\", jvmId);\r\n assertEquals(jvmId, JvmId.get());\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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) {\r\n return VALID_LAYOUT_NAME_PATTERN.matcher(name).matches();\r\n }", "test_case": "@Test\r\n public void testIsValidIdentifier() {\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"0123\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"0123abc\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"-asdb\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc-def\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abcdef$\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abcdef-\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abcdef(\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"(bcdef\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"(bcdef)\"));\r\n\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"_\"));\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"foo\"));\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"FOO\"));\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"FooBar\"));\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"foo123\"));\r\n assertTrue(KijiNameValidator.isValidLayoutName(\"foo_bar\"));\r\n\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc:def\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc\\\\def\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc/def\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc=def\"));\r\n assertFalse(KijiNameValidator.isValidLayoutName(\"abc+def\"));\r\n }"} {"description": "@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", "focal_method": "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) {\r\n return VALID_ALIAS_PATTERN.matcher(name).matches();\r\n }", "test_case": "@Test\r\n public void testIsValidAlias() {\r\n assertFalse(KijiNameValidator.isValidAlias(\"\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"0123\")); // Digits are ok in a leading capacity.\r\n assertTrue(KijiNameValidator.isValidAlias(\"0123abc\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"abc-def\")); // Dashes are ok in aliases...\r\n assertTrue(KijiNameValidator.isValidAlias(\"-asdb\")); // Even as the first character.\r\n assertTrue(KijiNameValidator.isValidAlias(\"asdb-\")); // Even as the first character.\r\n assertFalse(KijiNameValidator.isValidAlias(\"abcdef(\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"(bcdef\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"(bcdef)\"));\r\n\r\n assertTrue(KijiNameValidator.isValidAlias(\"_\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"foo\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"FOO\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"FooBar\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"foo123\"));\r\n assertTrue(KijiNameValidator.isValidAlias(\"foo_bar\"));\r\n\r\n assertFalse(KijiNameValidator.isValidAlias(\"abc:def\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"abc\\\\def\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"abc/def\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"abc=def\"));\r\n assertFalse(KijiNameValidator.isValidAlias(\"abc+def\"));\r\n }"} {"description": "[\"('/**\\\\\\\\n * @return true if name is a valid name for a Kiji instance and false otherwise.\\\\\\\\n * @param name the name to check.\\\\\\\\n */', '')\"]", "focal_method": "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) {\r\n return VALID_INSTANCE_PATTERN.matcher(name).matches();\r\n }", "test_case": "@Test\r\n public void testIsValidInstanceName() {\r\n assertFalse(KijiNameValidator.isValidKijiName(\"\")); // empty string is disallowed here.\r\n assertTrue(KijiNameValidator.isValidKijiName(\"0123\")); // leading digits are okay.\r\n assertTrue(KijiNameValidator.isValidKijiName(\"0123abc\")); // leading digits are okay.\r\n assertFalse(KijiNameValidator.isValidKijiName(\"-asdb\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc-def\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abcd-\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abcd$\"));\r\n\r\n assertTrue(KijiNameValidator.isValidKijiName(\"_\"));\r\n assertTrue(KijiNameValidator.isValidKijiName(\"foo\"));\r\n assertTrue(KijiNameValidator.isValidKijiName(\"FOO\"));\r\n assertTrue(KijiNameValidator.isValidKijiName(\"FooBar\"));\r\n assertTrue(KijiNameValidator.isValidKijiName(\"foo123\"));\r\n assertTrue(KijiNameValidator.isValidKijiName(\"foo_bar\"));\r\n\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc:def\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc\\\\def\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc/def\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc=def\"));\r\n assertFalse(KijiNameValidator.isValidKijiName(\"abc+def\"));\r\n }"} {"description": "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", "focal_method": "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\r\n public String toString() {\r\n return mParsedStr;\r\n }", "test_case": "@Test\r\n public void testToString() {\r\n ProtocolVersion pv1 = ProtocolVersion.parse(\"proto-1.2\");\r\n ProtocolVersion pv2 = ProtocolVersion.parse(\"proto-1.2.0\");\r\n\r\n assertEquals(\"proto-1.2\", pv1.toString());\r\n assertEquals(\"proto-1.2.0\", pv2.toString());\r\n assertTrue(pv1.equals(pv2));\r\n assertEquals(\"proto-1.2.0\", pv1.toCanonicalString());\r\n assertEquals(\"proto-1.2.0\", pv2.toCanonicalString());\r\n }"} {"description": "@inheritDoc", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public boolean equals(Object other) {\r\n if (null == other) {\r\n return false;\r\n } else if (this == other) {\r\n return true;\r\n } else if (!(other instanceof ProtocolVersion)) {\r\n return false;\r\n }\r\n\r\n ProtocolVersion otherVer = (ProtocolVersion) other;\r\n\r\n if (!checkEquality(mProtocol, otherVer.mProtocol)) {\r\n return false;\r\n }\r\n\r\n return getMajorVersion() == otherVer.getMajorVersion()\r\n && getMinorVersion() == otherVer.getMinorVersion()\r\n && getRevision() == otherVer.getRevision();\r\n }", "test_case": "@Test\r\n public void testEquals() {\r\n ProtocolVersion pv1 = ProtocolVersion.parse(\"proto-1.2.3\");\r\n ProtocolVersion pv2 = ProtocolVersion.parse(\"proto-1.2.3\");\r\n assertTrue(pv1.equals(pv2));\r\n assertTrue(pv2.equals(pv1));\r\n assertEquals(pv1.hashCode(), pv2.hashCode());\r\n assertEquals(0, pv1.compareTo(pv2));\r\n assertEquals(0, pv2.compareTo(pv1));\r\n\r\n // Required for our equals() method to imply the same hash code.\r\n assertEquals(0, Integer.valueOf(0).hashCode());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testURIWithQuery() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col?query\").build();\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testCompare() {\r\n List list = Arrays.asList(\r\n ProtocolVersion.parse(\"proto-1.10.0\"),\r\n ProtocolVersion.parse(\"proto-1.3.1\"),\r\n ProtocolVersion.parse(\"proto-2.1\"),\r\n ProtocolVersion.parse(\"proto-0.4\"),\r\n ProtocolVersion.parse(\"proto-2.0.0\"),\r\n ProtocolVersion.parse(\"proto-1\"),\r\n ProtocolVersion.parse(\"proto-1.1\"),\r\n ProtocolVersion.parse(\"other-0.9\"));\r\n\r\n List expected = Arrays.asList(\r\n ProtocolVersion.parse(\"other-0.9\"),\r\n ProtocolVersion.parse(\"proto-0.4\"),\r\n ProtocolVersion.parse(\"proto-1\"),\r\n ProtocolVersion.parse(\"proto-1.1\"),\r\n ProtocolVersion.parse(\"proto-1.3.1\"),\r\n ProtocolVersion.parse(\"proto-1.10.0\"),\r\n ProtocolVersion.parse(\"proto-2.0.0\"),\r\n ProtocolVersion.parse(\"proto-2.1\"));\r\n\r\n Collections.sort(list);\r\n assertEquals(expected, list);\r\n }"} {"description": "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", "focal_method": "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) {\r\n if (null == thing1 && null != thing2) {\r\n return false;\r\n }\r\n\r\n if (null != thing1 && null == thing2) {\r\n return false;\r\n }\r\n\r\n if (thing1 != null) {\r\n return thing1.equals(thing2);\r\n } else {\r\n assert null == thing2;\r\n return true; // they're both null.\r\n }\r\n }", "test_case": "@Test\r\n public void testCheckEquality() {\r\n assertTrue(ProtocolVersion.checkEquality(null, null));\r\n assertTrue(ProtocolVersion.checkEquality(\"hi\", \"hi\"));\r\n assertFalse(ProtocolVersion.checkEquality(\"hi\", null));\r\n assertFalse(ProtocolVersion.checkEquality(null, \"hi\"));\r\n assertTrue(ProtocolVersion.checkEquality(Integer.valueOf(32), Integer.valueOf(32)));\r\n assertFalse(ProtocolVersion.checkEquality(Integer.valueOf(32), Integer.valueOf(7)));\r\n assertFalse(ProtocolVersion.checkEquality(Integer.valueOf(32), \"ohai\"));\r\n assertFalse(ProtocolVersion.checkEquality(\"meep\", \"ohai\"));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoJustProto() {\r\n try {\r\n ProtocolVersion.parse(\"proto\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may contain at most one dash character, separating the protocol \"\r\n + \"name from the version number.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoJustProto2() {\r\n try {\r\n ProtocolVersion.parse(\"proto-\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may contain at most one dash character, separating the protocol \"\r\n + \"name from the version number.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testDashRequired() {\r\n try {\r\n ProtocolVersion.parse(\"foo1.4\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may contain at most one dash character, separating the protocol \"\r\n + \"name from the version number.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoLeadingDash() {\r\n try {\r\n ProtocolVersion.parse(\"-foo-1.4\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may not start with a dash\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoMoreThan3() {\r\n try {\r\n ProtocolVersion.parse(\"1.2.3.4\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Version numbers may have at most three components.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoMoreThan3withProto() {\r\n try {\r\n ProtocolVersion.parse(\"proto-1.2.3.4\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Version numbers may have at most three components.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoLeadingDashWithoutProto() {\r\n try {\r\n ProtocolVersion.parse(\"-1.2.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may not start with a dash\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoLeadingDashes() {\r\n try {\r\n ProtocolVersion.parse(\"--1.2.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may not start with a dash\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testURIWithFragment() {\r\n final KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col#frag\").build();\r\n assertEquals(\"zkhost1\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", uri.getZookeeperQuorum().get(1));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(\"instance\", uri.getInstance());\r\n assertEquals(\"table\", uri.getTable());\r\n assertEquals(\"col\", uri.getColumns().get(0).getName());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoMultiDash() {\r\n try {\r\n ProtocolVersion.parse(\"proto--1.2.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may contain at most one dash character, separating the protocol \"\r\n + \"name from the version number.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoDashInProto() {\r\n try {\r\n ProtocolVersion.parse(\"proto-col-1.2.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may contain at most one dash character, separating the protocol \"\r\n + \"name from the version number.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoNegativeMinor() {\r\n try {\r\n ProtocolVersion.parse(\"1.-2\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Minor version number must be non-negative.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoNegativeRev() {\r\n try {\r\n ProtocolVersion.parse(\"1.2.-3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Revision number must be non-negative.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoMultiDots() {\r\n try {\r\n ProtocolVersion.parse(\"1..2\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Could not parse numeric version info in 1..2\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoMultiDots2() {\r\n try {\r\n ProtocolVersion.parse(\"1..2.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Version numbers may have at most three components.\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoNamedMinor() {\r\n try {\r\n ProtocolVersion.parse(\"1.x\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Could not parse numeric version info in 1.x\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoNamedMinorWithProto() {\r\n try {\r\n ProtocolVersion.parse(\"proto-1.x\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Could not parse numeric version info in proto-1.x\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoLeadingNumber() {\r\n try {\r\n ProtocolVersion.parse(\"2foo-1.3\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"Could not parse numeric version info in 2foo-1.3\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoEmptyString() {\r\n try {\r\n ProtocolVersion.parse(\"\");\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may not be empty\", iae.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testPartialURIZookeeper() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234\").build();\r\n assertEquals(\"zkhost\", uri.getZookeeperQuorum().get(0));\r\n assertEquals(1234, uri.getZookeeperClientPort());\r\n assertEquals(null, uri.getInstance());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Static factory method that creates new ProtocolVersion instances.\\\\\\\\n *\\\\\\\\n *

    This method parses its argument as a string of the form:\\\\\\\\n * protocol-maj.min.rev. 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.

    \\\\\\\\n *\\\\\\\\n *

    The following are examples of legal protocol versions:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"data-1.0\"
    • \\\\\\\\n *
    • \"kiji-1.2.3\"
    • \\\\\\\\n *
    • \"1.3.1\"
    • \\\\\\\\n *
    • \"76\"
    • \\\\\\\\n *
    • \"2.3\"
    • \\\\\\\\n *
    • \"spec-1\"
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n *

    The following are illegal:

    \\\\\\\\n *
      \\\\\\\\n *
    • \"foo\" (no version number)
    • \\\\\\\\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\\\\\\\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\\\\\\\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\\\\\\\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\\\\\\\n *
    • \"1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\\\\\\\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\\\\\\\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\\\\\\\n *
    • \"\" (the empty string is not allowed as a version)
    • \\\\\\\\n *
    • null
    • \\\\\\\\n *
    \\\\\\\\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\")']", "focal_method": "b'/**\\n * Static factory method that creates new ProtocolVersion instances.\\n *\\n *

    This method parses its argument as a string of the form:\\n * protocol-maj.min.rev. 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.

    \\n *\\n *

    The following are examples of legal protocol versions:

    \\n *
      \\n *
    • \"data-1.0\"
    • \\n *
    • \"kiji-1.2.3\"
    • \\n *
    • \"1.3.1\"
    • \\n *
    • \"76\"
    • \\n *
    • \"2.3\"
    • \\n *
    • \"spec-1\"
    • \\n *
    \\n *\\n *

    The following are illegal:

    \\n *
      \\n *
    • \"foo\" (no version number)
    • \\n *
    • \"foo1.2\" (no dash after the protocol name)
    • \\n *
    • \"-foo-1.2\" (protocol may not start with a dash)
    • \\n *
    • \"1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"bar-1.2.3.4\" (only 3-component version numbers are supported)
    • \\n *
    • \"-1.2.3\" (version numbers may not be negative)
    • \\n *
    • \"1.-2\" (version numbers may not be negative)
    • \\n *
    • \"1.x\" (version numbers must be integers)
    • \\n *
    • \"foo-1.x\" (version numbers must be integers)
    • \\n *
    • \"2foo-1.3\" (protocol names may not start with a digit)
    • \\n *
    • \"foo-bar-1.x\" (protocol names may not contain a dash)
    • \\n *
    • \"\" (the empty string is not allowed as a version)
    • \\n *
    • null
    • \\n *
    \\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) {\r\n Preconditions.checkArgument(null != verString, \"verString may not be null\");\r\n Preconditions.checkArgument(!verString.isEmpty(), \"verString may not be empty\");\r\n Preconditions.checkArgument(verString.charAt(0) != '-', \"verString may not start with a dash\");\r\n\r\n String proto = null;\r\n int major = 0;\r\n int minor = 0;\r\n int rev = 0;\r\n\r\n int pos = 0;\r\n String numericPart = verString;\r\n if (!Character.isDigit(verString.charAt(pos))) {\r\n // Start by parsing a protocol name. Scan forward to the '-'.\r\n String[] nameParts = verString.split(\"-\");\r\n if (nameParts.length != 2) {\r\n throw new IllegalArgumentException(\"verString may contain at most one dash character, \"\r\n + \"separating the protocol name from the version number.\");\r\n }\r\n\r\n proto = nameParts[0];\r\n numericPart = nameParts[1]; // only use the string part after the '-' for ver numbers.\r\n }\r\n\r\n String[] verParts = numericPart.split(\"\\\\.\");\r\n if (verParts.length > 3) {\r\n throw new IllegalArgumentException(\"Version numbers may have at most three components.\");\r\n }\r\n\r\n try {\r\n major = Integer.parseInt(verParts[0]);\r\n if (verParts.length > 1) {\r\n minor = Integer.parseInt(verParts[1]);\r\n }\r\n if (verParts.length > 2) {\r\n rev = Integer.parseInt(verParts[2]);\r\n }\r\n } catch (NumberFormatException nfe) {\r\n throw new IllegalArgumentException(\"Could not parse numeric version info in \" + verString);\r\n }\r\n\r\n if (major < 0) {\r\n throw new IllegalArgumentException(\"Major version number must be non-negative.\");\r\n }\r\n if (minor < 0) {\r\n throw new IllegalArgumentException(\"Minor version number must be non-negative.\");\r\n }\r\n if (rev < 0) {\r\n throw new IllegalArgumentException(\"Revision number must be non-negative.\");\r\n }\r\n\r\n return new ProtocolVersion(verString, proto, major, minor, rev);\r\n }", "test_case": "@Test\r\n public void testNoNull() {\r\n try {\r\n ProtocolVersion.parse(null);\r\n fail(\"Should fail with an IllegalArgumentException\");\r\n } catch (IllegalArgumentException iae) {\r\n assertEquals(\"verString may not be null\", iae.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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\r\n public void close() throws IOException {\r\n mIsOpen = false;\r\n for (Map.Entry> entry : mMap.entrySet()) {\r\n // Attempt to remove the entry from the cache\r\n if (mMap.remove(entry.getKey(), entry.getValue())) {\r\n // If successfull, close the value\r\n CacheEntry cacheEntry = entry.getValue();\r\n synchronized (cacheEntry) {\r\n cacheEntry.getValue().close();\r\n }\r\n }\r\n }\r\n }", "test_case": "@Test(expected = IllegalStateException.class)\r\n public void closeableOnceFailsWhenDoubleClosed() throws Exception {\r\n Closeable closeable = new CloseableOnce(null);\r\n closeable.close();\r\n closeable.close();\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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 decodeRegionSplitList(InputStream inputStream) throws IOException {\r\n try {\r\n final String content =\r\n Bytes.toString(IOUtils.toByteArray(Preconditions.checkNotNull(inputStream)));\r\n final String[] encodedKeys = content.split(\"\\n\");\r\n final List keys = Lists.newArrayListWithCapacity(encodedKeys.length);\r\n for (String encodedKey : encodedKeys) {\r\n keys.add(decodeRowKey(encodedKey));\r\n }\r\n return keys;\r\n } finally {\r\n ResourceUtils.closeOrLog(inputStream);\r\n }\r\n }", "test_case": "@Test\r\n public void testDecodeSplitKeyFile() throws Exception {\r\n final String content =\r\n \"key1\\n\"\r\n + \"key2\\n\";\r\n final List keys =\r\n SplitKeyFile.decodeRegionSplitList(new ByteArrayInputStream(Bytes.toBytes(content)));\r\n assertEquals(2, keys.size());\r\n assertArrayEquals(Bytes.toBytes(\"key1\"), keys.get(0));\r\n assertArrayEquals(Bytes.toBytes(\"key2\"), keys.get(1));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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 decodeRegionSplitList(InputStream inputStream) throws IOException {\r\n try {\r\n final String content =\r\n Bytes.toString(IOUtils.toByteArray(Preconditions.checkNotNull(inputStream)));\r\n final String[] encodedKeys = content.split(\"\\n\");\r\n final List keys = Lists.newArrayListWithCapacity(encodedKeys.length);\r\n for (String encodedKey : encodedKeys) {\r\n keys.add(decodeRowKey(encodedKey));\r\n }\r\n return keys;\r\n } finally {\r\n ResourceUtils.closeOrLog(inputStream);\r\n }\r\n }", "test_case": "@Test\r\n public void testDecodeSplitKeyFileNoEndNewLine() throws Exception {\r\n final String content =\r\n \"key1\\n\"\r\n + \"key2\";\r\n final List keys =\r\n SplitKeyFile.decodeRegionSplitList(new ByteArrayInputStream(Bytes.toBytes(content)));\r\n assertEquals(2, keys.size());\r\n assertArrayEquals(Bytes.toBytes(\"key1\"), keys.get(0));\r\n assertArrayEquals(Bytes.toBytes(\"key2\"), keys.get(1));\r\n }"} {"description": "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", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKey() throws Exception {\r\n assertArrayEquals(Bytes.toBytes(\"this is a \\n key\"),\r\n SplitKeyFile.decodeRowKey(\"this is a \\n key\"));\r\n\r\n assertArrayEquals(Bytes.toBytes(\"this is a \\\\ key\"),\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\\\\\ key\"));\r\n\r\n assertArrayEquals(Bytes.toBytes(\"this is a \\n key\"),\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\x0A key\"));\r\n\r\n assertArrayEquals(Bytes.toBytes(\"this is a \\n key\"),\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\x0a key\"));\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKeyInvalidHexEscape() throws Exception {\r\n try {\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\xZZ key\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid hexadecimal escape in encoded row key: 'this is a \\\\xZZ key'.\",\r\n ioe.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKeyInvalidEscape() throws Exception {\r\n // \\n is escaped as \\x0a\r\n try {\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\n key\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid escape in encoded row key: 'this is a \\\\n key'.\", ioe.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKeyUnterminatedEscape() throws Exception {\r\n try {\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid trailing escape in encoded row key: 'this is a \\\\'.\", ioe.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKeyInvalidHex() throws Exception {\r\n try {\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\x-6\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid hexadecimal escape in encoded row key: 'this is a \\\\x-6'.\",\r\n ioe.getMessage());\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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 {\r\n final ByteArrayOutputStream os = new ByteArrayOutputStream();\r\n int index = 0;\r\n final byte[] bytes = Bytes.toBytes(encoded);\r\n while (index < bytes.length) {\r\n final byte data = bytes[index++];\r\n\r\n if (data != '\\\\') {\r\n os.write(data);\r\n } else {\r\n if (index == bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid trailing escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final byte escaped = bytes[index++];\r\n\r\n switch (escaped) {\r\n case '\\\\': {\r\n // Escaped backslash:\r\n os.write('\\\\');\r\n break;\r\n }\r\n case 'x': {\r\n // Escaped byte in hexadecimal:\r\n if (index + 1 >= bytes.length) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n final String hex = Bytes.toString(Arrays.copyOfRange(bytes, index, index + 2));\r\n try {\r\n final int decodedByte = Integer.parseInt(hex, 16);\r\n if ((decodedByte < 0) || (decodedByte > 255)) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n os.write(decodedByte);\r\n } catch (NumberFormatException nfe) {\r\n throw new IOException(String.format(\r\n \"Invalid hexadecimal escape in encoded row key: '%s'.\", encoded));\r\n }\r\n index += 2;\r\n break;\r\n }\r\n default:\r\n throw new IOException(String.format(\"Invalid escape in encoded row key: '%s'.\", encoded));\r\n }\r\n }\r\n }\r\n return os.toByteArray();\r\n }", "test_case": "@Test\r\n public void testDecodeRowKeyIncompleteHex() throws Exception {\r\n try {\r\n SplitKeyFile.decodeRowKey(\"this is a \\\\x6\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IOException ioe) {\r\n assertEquals(\"Invalid hexadecimal escape in encoded row key: 'this is a \\\\x6'.\",\r\n ioe.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testToString() {\r\n String uri = \"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-hbase://zkhost1:1234/instance/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-hbase://zkhost:1234/instance/table/col1,col2/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-hbase://zkhost:1234/.unset/table/col/\";\r\n assertEquals(uri, KijiURI.newBuilder(uri).build().toString());\r\n }"} {"description": "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", "focal_method": "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 {\r\n final String version = VersionInfo.class.getPackage().getImplementationVersion();\r\n if (version != null) {\r\n // Proper release: use the value of 'Implementation-Version' in META-INF/MANIFEST.MF:\r\n return version;\r\n }\r\n\r\n // Most likely a development version:\r\n final Properties kijiProps = loadKijiSchemaProperties();\r\n return kijiProps.getProperty(KIJI_SCHEMA_VERSION_PROP_NAME, DEFAULT_DEVELOPMENT_VERSION);\r\n }", "test_case": "@Test\r\n public void testGetSoftwareVersion() throws Exception {\r\n // We cannot compare against any concrete value here, or else the test will fail\r\n // depending on whether this is a development version or a release...\r\n assertFalse(VersionInfo.getSoftwareVersion().isEmpty());\r\n }"} {"description": "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", "focal_method": "b'/**\\n * Reports the maximum system version of the Kiji instance format understood by the client.\\n *\\n *

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

    \\n *\\n * @return A parsed version of the instance format protocol version string.\\n */'public static ProtocolVersion getClientDataVersion() {\r\n return Versions.MAX_SYSTEM_VERSION;\r\n }", "test_case": "@Test\r\n public void testGetClientDataVersion() {\r\n // This is the actual version we expect to be in there right now.\r\n assertEquals(Versions.MAX_SYSTEM_VERSION, VersionInfo.getClientDataVersion());\r\n }"} {"description": "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", "focal_method": "b'/**\\n * Gets the version of the Kiji instance format installed on the HBase cluster.\\n *\\n *

    The instance format describes the layout of the global metadata state of\\n * a Kiji instance.

    \\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\r\n IOException {\r\n try {\r\n final ProtocolVersion dataVersion = systemTable.getDataVersion();\r\n return dataVersion;\r\n } catch (TableNotFoundException e) {\r\n final KijiURI kijiURI = systemTable.getKijiURI();\r\n throw new KijiNotInstalledException(\r\n String.format(\"Kiji instance %s is not installed.\", kijiURI),\r\n kijiURI);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetClusterDataVersion() throws Exception {\r\n final KijiSystemTable systemTable = createMock(KijiSystemTable.class);\r\n // This version number for this test was picked out of a hat.\r\n expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse(\"system-1.1\")).anyTimes();\r\n\r\n final Kiji kiji = createMock(Kiji.class);\r\n expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();\r\n\r\n replay(systemTable);\r\n replay(kiji);\r\n assertEquals(ProtocolVersion.parse(\"system-1.1\"), VersionInfo.getClusterDataVersion(kiji));\r\n verify(systemTable);\r\n verify(kiji);\r\n }"} {"description": "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", "focal_method": "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 *

    For the definition of compatibility used in this method, see {@link\\n * #isKijiVersionCompatible}

    \\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 {\r\n validateVersion(kiji.getSystemTable());\r\n }", "test_case": "@Test\r\n public void testValidateVersion() throws Exception {\r\n final KijiSystemTable systemTable = createMock(KijiSystemTable.class);\r\n expect(systemTable.getDataVersion()).andReturn(VersionInfo.getClientDataVersion()).anyTimes();\r\n\r\n final Kiji kiji = createMock(Kiji.class);\r\n expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();\r\n\r\n replay(systemTable);\r\n replay(kiji);\r\n\r\n // This should validate, since we set the cluster data version to match the client version.\r\n VersionInfo.validateVersion(kiji);\r\n\r\n verify(systemTable);\r\n verify(kiji);\r\n }"} {"description": "[\"('/**\\\\\\\\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 *

    For the definition of compatibility used in this method, see {@link\\\\\\\\n * #isKijiVersionCompatible}

    \\\\\\\\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 */', '')\"]", "focal_method": "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 *

    For the definition of compatibility used in this method, see {@link\\n * #isKijiVersionCompatible}

    \\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 {\r\n validateVersion(kiji.getSystemTable());\r\n }", "test_case": "@Test\r\n public void testValidateVersionFail() throws Exception {\r\n final KijiSystemTable systemTable = createMock(KijiSystemTable.class);\r\n expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse(\"kiji-0.9\")).anyTimes();\r\n\r\n final Kiji kiji = createMock(Kiji.class);\r\n expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();\r\n\r\n replay(systemTable);\r\n replay(kiji);\r\n\r\n // This should throw an invalid version exception.\r\n try {\r\n VersionInfo.validateVersion(kiji);\r\n fail(\"An exception should have been thrown.\");\r\n } catch (IncompatibleKijiVersionException ikve) {\r\n assertTrue(ikve.getMessage(), Pattern.matches(\r\n \"Data format of Kiji instance \\\\(kiji-0\\\\.9\\\\) cannot operate \"\r\n + \"with client \\\\(system-[0-9]\\\\.[0-9]\\\\)\",\r\n ikve.getMessage()));\r\n }\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testKijiVsSystemProtocol() {\r\n // New client (1.0.0-rc4 or higher) interacting with a table installed via 1.0.0-rc3.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-1.0\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"kiji-1.0\");\r\n\r\n assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testOldKijiRefusesToReadNewSystemProtocol() {\r\n // The old 1.0.0-rc3 client should refuse to interop with a new instance created by\r\n // 1.0.0-rc4 or higher due to the data version protocol namespace change. Forwards\r\n // compatibility is not supported by the release candidates, even though we honor\r\n // backwards compatibility.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"kiji-1.0\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"system-1.0\");\r\n\r\n assertFalse(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testKijiVsNewerSystemProtocol() {\r\n // An even newer client (not yet defined as of 1.0.0-rc4) that uses a 'system-1.1'\r\n // protocol should still be compatible with a table installed via 1.0.0-rc3.\r\n // kiji-1.0 => system-1.0, and all system-1.x versions should be compatible.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-1.1\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"kiji-1.0\");\r\n\r\n assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testDifferentSystemProtocols() {\r\n // In the future, when we release it, system-1.1 should be compatible with system-1.0.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-1.1\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"system-1.0\");\r\n\r\n assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testSystemProtocolName() {\r\n // A client (1.0.0-rc4 or higher) interacting with a table installed via 1.0.0-rc4.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-1.0\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"system-1.0\");\r\n\r\n assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNormalizedQuorum() {\r\n KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/\").build();\r\n KijiURI reversedQuorumUri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost2,zkhost1):1234/instance/table/col/\").build();\r\n assertEquals(uri.toString(), reversedQuorumUri.toString());\r\n assertEquals(uri.getZookeeperQuorum(), reversedQuorumUri.getZookeeperQuorum());\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testNoForwardCompatibility() {\r\n // A system-1.0-capable client should not be able to read a system-2.0 installation.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-1.0\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"system-2.0\");\r\n\r\n assertFalse(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "['(\"/**\\\\\\\\n * Actual comparison logic that validates client/cluster data compatibility according to\\\\\\\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\\\\\\\n *\\\\\\\\n *

    package-level visibility for unit testing.

    \\\\\\\\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')\"]", "focal_method": "b\"/**\\n * Actual comparison logic that validates client/cluster data compatibility according to\\n * the rules defined in {@link #isKijiVersionCompatible(Kiji)}.\\n *\\n *

    package-level visibility for unit testing.

    \\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(\r\n ProtocolVersion clientVersion, ProtocolVersion clusterVersion) {\r\n\r\n if (Objects.equal(clusterVersion, Versions.SYSTEM_KIJI_1_0_DEPRECATED)) {\r\n // The \"kiji-1.0\" version is equivalent to \"system-1.0\" in compatibility tests.\r\n clusterVersion = Versions.SYSTEM_1_0;\r\n }\r\n\r\n // See SCHEMA-469.\r\n // From https://github.com/kijiproject/wiki/wiki/KijiVersionCompatibility:\r\n //\r\n // (quote)\r\n // Our primary goal with data formats is backwards compatibility. KijiSchema Version 1.x\r\n // will read and interact with data written by Version 1.y, if x > y.\r\n //\r\n // ...\r\n //\r\n // The instance format describes the feature set and format of the entire Kiji instance.\r\n // This allows a client to determine whether it can connect to the instance at all, read\r\n // any cells, and identifies where other metadata (e.g., schemas, layouts) is located, as\r\n // well as the range of supported associated formats within that metadata.\r\n //\r\n // The kiji version command specifies the instance version presently installed on the\r\n // cluster, and the system data version supported by the client. The major version numbers\r\n // of these must agree to connect to one another.\r\n // (end quote)\r\n //\r\n // Given these requirements, we require that our client's supported instance version major\r\n // digit be greater than or equal to the major digit of the system installation.\r\n //\r\n // If we ever deprecate an instance format and then target it for end-of-life (i.e., when\r\n // contemplating KijiSchema 2.0.0), we may introduce a cut-off point: we may support only\r\n // the most recent 'k' major digits; so KijiSchema 2.0.0 may have system-12.0, but support\r\n // reading/writing instances only as far back as system-9.0. This is not yet implemented;\r\n // if we do go down this route, then this method would be the place to do it.\r\n\r\n return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName())\r\n && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();\r\n }", "test_case": "@Test\r\n public void testBackCompatibilityThroughMajorVersions() {\r\n // A system-2.0-capable client should still be able to read a system-1.0 installation.\r\n final ProtocolVersion clientVersion = ProtocolVersion.parse(\"system-2.0\");\r\n final ProtocolVersion clusterVersion = ProtocolVersion.parse(\"system-1.0\");\r\n\r\n assertTrue(VersionInfo.areInstanceVersionsCompatible(clientVersion, clusterVersion));\r\n }"} {"description": "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", "focal_method": "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) {\r\n this.mConstructorStack = CLEANUP_LOG.isDebugEnabled() ? Debug.getStackTrace() : null;\r\n\r\n this.mZKClient = zookeeper;\r\n this.mLockDir = lockDir;\r\n this.mLockPathPrefix = new File(lockDir, LOCK_NAME_PREFIX);\r\n // ZooKeeperClient.retain() should be the last line of the constructor.\r\n this.mZKClient.retain();\r\n DebugResourceTracker.get().registerResource(this);\r\n }", "test_case": "@Test\r\n public void testZooKeeperLock() throws Exception {\r\n final File lockDir = new File(\"/lock\");\r\n final ZooKeeperClient zkClient = ZooKeeperClient.getZooKeeperClient(getZKAddress());\r\n try {\r\n final CyclicBarrier barrier = new CyclicBarrier(2);\r\n final ZooKeeperLock lock1 = new ZooKeeperLock(zkClient, lockDir);\r\n final ZooKeeperLock lock2 = new ZooKeeperLock(zkClient, lockDir);\r\n lock1.lock();\r\n\r\n final Thread thread = new Thread() {\r\n /** {@inheritDoc} */\r\n @Override\r\n public void run() {\r\n try {\r\n assertFalse(lock2.lock(0.1));\r\n barrier.await();\r\n lock2.lock();\r\n lock2.unlock();\r\n\r\n lock2.lock();\r\n lock2.unlock();\r\n lock2.close();\r\n barrier.await();\r\n } catch (Exception e) {\r\n LOG.warn(\"Exception caught in locking thread: {}\", e.getMessage());\r\n }\r\n }\r\n };\r\n thread.start();\r\n\r\n barrier.await(5, TimeUnit.SECONDS); // Eventually fail\r\n\r\n lock1.unlock();\r\n lock1.close();\r\n\r\n barrier.await(5, TimeUnit.SECONDS); // Eventually fail\r\n } finally {\r\n zkClient.release();\r\n }\r\n }"} {"description": "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", "focal_method": "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(\r\n final CuratorFramework zkClient,\r\n final String path\r\n ) throws IOException {\r\n try {\r\n buildAtomicRecursiveDelete(zkClient, zkClient.inTransaction(), path).commit();\r\n return true;\r\n } catch (NoNodeException nne) {\r\n LOG.debug(\"NoNodeException while attempting an atomic recursive delete: {}.\",\r\n nne.getMessage());\r\n // Node was deleted out from under us; we still have to try again because if this is\r\n // thrown any parents of the deleted node possibly still exist.\r\n } catch (NotEmptyException nee) {\r\n LOG.debug(\"NotEmptyException while attempting an atomic recursive delete: {}.\",\r\n nee.getMessage());\r\n // Someone else created a node in the tree between the time we built the transaction and\r\n // committed it.\r\n } catch (Exception e) {\r\n wrapAndRethrow(e);\r\n }\r\n return false;\r\n }", "test_case": "@Test\r\n public void testAtomicRecursiveDelete() throws Exception {\r\n final String path = \"/foo/bar/baz/faz/fooz\";\r\n mZKClient.create().creatingParentsIfNeeded().forPath(path);\r\n ZooKeeperUtils.atomicRecursiveDelete(mZKClient, \"/foo\");\r\n Assert.assertNull(mZKClient.checkExists().forPath(\"/foo\"));\r\n }"} {"description": "[\"('/**\\\\\\\\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')\"]", "focal_method": "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(\r\n final CuratorFramework zkClient,\r\n final String path\r\n ) throws IOException {\r\n try {\r\n buildAtomicRecursiveDelete(zkClient, zkClient.inTransaction(), path).commit();\r\n return true;\r\n } catch (NoNodeException nne) {\r\n LOG.debug(\"NoNodeException while attempting an atomic recursive delete: {}.\",\r\n nne.getMessage());\r\n // Node was deleted out from under us; we still have to try again because if this is\r\n // thrown any parents of the deleted node possibly still exist.\r\n } catch (NotEmptyException nee) {\r\n LOG.debug(\"NotEmptyException while attempting an atomic recursive delete: {}.\",\r\n nee.getMessage());\r\n // Someone else created a node in the tree between the time we built the transaction and\r\n // committed it.\r\n } catch (Exception e) {\r\n wrapAndRethrow(e);\r\n }\r\n return false;\r\n }", "test_case": "@Test\r\n public void testAtomicRecursiveDeleteWithPersistentENode() throws Exception {\r\n final String path = \"/foo/bar/baz/faz/fooz\";\r\n\r\n PersistentEphemeralNode node =\r\n new PersistentEphemeralNode(mZKClient, Mode.EPHEMERAL, path, new byte[0]);\r\n try {\r\n node.start();\r\n node.waitForInitialCreate(5, TimeUnit.SECONDS);\r\n Assert.assertTrue(ZooKeeperUtils.atomicRecursiveDelete(mZKClient, \"/foo\"));\r\n Thread.sleep(1000); // Give ephemeral node time to recreate itself\r\n Assert.assertNotNull(mZKClient.checkExists().forPath(\"/foo\"));\r\n } finally {\r\n node.close();\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final CuratorFramework zkClient,\r\n final CuratorTransaction tx,\r\n final String path\r\n ) throws Exception {\r\n final List children = zkClient.getChildren().forPath(path);\r\n\r\n for (String child : children) {\r\n buildAtomicRecursiveDelete(zkClient, tx, path + \"/\" + child);\r\n }\r\n return tx.delete().forPath(path).and();\r\n }", "test_case": "@Test\r\n public void testAtomicRecusiveDeleteWithConcurrentNodeAddition() throws Exception {\r\n final String path = \"/foo/bar/baz/faz/fooz\";\r\n mZKClient.create().creatingParentsIfNeeded().forPath(path);\r\n CuratorTransactionFinal tx =\r\n ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), \"/foo\");\r\n mZKClient.create().forPath(\"/foo/new-child\");\r\n\r\n try {\r\n tx.commit();\r\n } catch (NotEmptyException nee) {\r\n // expected\r\n }\r\n Assert.assertNotNull(mZKClient.checkExists().forPath(\"/foo\"));\r\n }"} {"description": "[\"('/**\\\\\\\\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 */', '')\"]", "focal_method": "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(\r\n final CuratorFramework zkClient,\r\n final CuratorTransaction tx,\r\n final String path\r\n ) throws Exception {\r\n final List children = zkClient.getChildren().forPath(path);\r\n\r\n for (String child : children) {\r\n buildAtomicRecursiveDelete(zkClient, tx, path + \"/\" + child);\r\n }\r\n return tx.delete().forPath(path).and();\r\n }", "test_case": "@Test\r\n public void testAtomicRecusiveDeleteWithConcurrentNodeDeletion() throws Exception {\r\n final String path = \"/foo/bar/baz/faz/fooz\";\r\n mZKClient.create().creatingParentsIfNeeded().forPath(path);\r\n CuratorTransactionFinal tx =\r\n ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), \"/foo\");\r\n mZKClient.delete().forPath(path);\r\n\r\n try {\r\n tx.commit(); // should throw\r\n } catch (NoNodeException nne) {\r\n // expected\r\n }\r\n Assert.assertNotNull(mZKClient.checkExists().forPath(\"/foo\"));\r\n }"} {"description": "['(\\'/**\\\\\\\\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 */\\', \\'\\')']", "focal_method": "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) {\r\n String address = zkEnsemble;\r\n String namespace = null;\r\n\r\n int index = zkEnsemble.indexOf('/');\r\n\r\n if (index != -1) {\r\n address = zkEnsemble.substring(0, index);\r\n namespace = zkEnsemble.substring(index + 1);\r\n }\r\n\r\n return CachedCuratorFramework.create(ZK_CLIENT_CACHE, address, namespace);\r\n }", "test_case": "@Test\r\n public void testZooKeeperConnectionsAreCached() throws Exception {\r\n final CuratorFramework other = ZooKeeperUtils.getZooKeeperClient(getZKAddress());\r\n try {\r\n Assert.assertTrue(mZKClient.getZookeeperClient() == other.getZookeeperClient());\r\n } finally {\r\n other.close();\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\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 */\\', \\'\\')']", "focal_method": "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) {\r\n String address = zkEnsemble;\r\n String namespace = null;\r\n\r\n int index = zkEnsemble.indexOf('/');\r\n\r\n if (index != -1) {\r\n address = zkEnsemble.substring(0, index);\r\n namespace = zkEnsemble.substring(index + 1);\r\n }\r\n\r\n return CachedCuratorFramework.create(ZK_CLIENT_CACHE, address, namespace);\r\n }", "test_case": "@Test\r\n public void testFakeURIsAreNamespaced() throws Exception {\r\n final String namespace = \"testFakeURIsAreNamespaced\";\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji://.fake.\" + namespace).build();\r\n final CuratorFramework framework = ZooKeeperUtils.getZooKeeperClient(uri);\r\n try {\r\n Assert.assertEquals(namespace, framework.getNamespace());\r\n } finally {\r\n framework.close();\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraUriDoubleApersand() {\r\n final String uriString = \"kiji-cassandra://zkhost:1234/sally@cinnamon@chost:5678\";\r\n try {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build();\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(String.format(\r\n \"Invalid Kiji URI: '%s' : Cannot have more than one '@' in URI authority\",\r\n uriString),\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNormalizedColumns() {\r\n KijiURI uri =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost1,zkhost2):1234/instance/table/col/\").build();\r\n KijiURI reversedColumnURI =\r\n KijiURI.newBuilder(\"kiji-hbase://(zkhost2,zkhost1):1234/instance/table/col/\").build();\r\n assertEquals(uri.toString(), reversedColumnURI.toString());\r\n assertEquals(uri.getColumns(), reversedColumnURI.getColumns());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraUriTooManyColons() {\r\n final String uriString = \"kiji-cassandra://zkhost:1234/sally:cinnamon:foo@chost:5678\";\r\n try {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build();\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(String.format(\r\n \"Invalid Kiji URI: '%s' : Cannot have more than one ':' in URI user info\",\r\n uriString),\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraUriWithUsername() {\r\n final String uriString = \"kiji-cassandra://zkhost:1234/sallycinnamon@chost:5678\";\r\n try {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(uriString).build();\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(String.format(\r\n \"Invalid Kiji URI: '%s' : Cassandra Kiji URIs do not support a username without a \"\r\n + \"password.\",\r\n uriString),\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNoAuthority() {\r\n try {\r\n CassandraKijiURI.newBuilder(\"kiji-cassandra:///\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\"Invalid Kiji URI: 'kiji-cassandra:///' : ZooKeeper ensemble missing.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testBrokenCassandraPort() {\r\n try {\r\n CassandraKijiURI.newBuilder(\"kiji-cassandra://zkhost/chost:port/default\").build();\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\r\n \"Invalid Kiji URI: 'kiji-cassandra://zkhost/chost:port/default' \"\r\n + \": Can not parse port 'port'.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsNoParen() {\r\n try {\r\n CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost1,zkhost2:1234/chost:5678/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\r\n \"Invalid Kiji URI: 'kiji-cassandra://zkhost1,zkhost2:1234/chost:5678/instance/table/col'\"\r\n + \" : Multiple ZooKeeper hosts must be parenthesized.\", kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testMultipleHostsMultiplePorts() {\r\n try {\r\n CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost1:1234,zkhost2:2345/chost:5678/instance/table/col\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\r\n \"Invalid Kiji URI: 'kiji-cassandra://zkhost1:1234,zkhost2:2345/chost:5678/\"\r\n + \"instance/table/col' : Invalid ZooKeeper ensemble cluster identifier.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testExtraPath() {\r\n try {\r\n CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/extra\");\r\n fail(\"An exception should have been thrown.\");\r\n } catch (KijiURIException kurie) {\r\n assertEquals(\r\n \"Invalid Kiji URI: 'kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/\"\r\n + \"instance/table/col/extra' : Too many path segments.\",\r\n kurie.getMessage());\r\n }\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testToString() {\r\n String uri = \"kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/\";\r\n assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-cassandra://zkhost1:1234/chost:5678/instance/table/col/\";\r\n assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-cassandra://zkhost:1234/chost:5678/instance/table/col1,col2/\";\r\n assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString());\r\n uri = \"kiji-cassandra://zkhost:1234/chost:5678/.unset/table/col/\";\r\n assertEquals(uri, CassandraKijiURI.newBuilder(uri).build().toString());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNormalizedQuorum() {\r\n CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/\").build();\r\n CassandraKijiURI reversedQuorumUri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://(zkhost2,zkhost1):1234/chost:5678/instance/table/col/\").build();\r\n assertEquals(uri.toString(), reversedQuorumUri.toString());\r\n assertEquals(uri.getZookeeperQuorum(), reversedQuorumUri.getZookeeperQuorum());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testNormalizedColumns() {\r\n CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://(zkhost1,zkhost2):1234/chost:5678/instance/table/col/\").build();\r\n CassandraKijiURI reversedColumnURI = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://(zkhost2,zkhost1):1234/chost:5678/instance/table/col/\").build();\r\n assertEquals(uri.toString(), reversedColumnURI.toString());\r\n assertEquals(uri.getColumns(), reversedColumnURI.getColumns());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testKijiURIBuilderDefault() {\r\n KijiURI uri = KijiURI.newBuilder().build();\r\n assertTrue(!uri.getZookeeperQuorum().isEmpty()); // Test cannot be more specific.\r\n // Test cannot validate the value of uri.getZookeeperClientPort().\r\n assertEquals(KConstants.DEFAULT_INSTANCE_NAME, uri.getInstance());\r\n assertEquals(null, uri.getTable());\r\n assertTrue(uri.getColumns().isEmpty());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testOrderedCassandraNodes() {\r\n String revString = \"kiji-cassandra://zkhost:1234/(chost2,chost1):5678/instance/table/col/\";\r\n String ordString = \"kiji-cassandra://zkhost:1234/(chost1,chost2):5678/instance/table/col/\";\r\n CassandraKijiURI revUri = CassandraKijiURI.newBuilder(revString).build();\r\n\r\n // \"toString\" should ignore the user-defined ordering.\r\n assertEquals(ordString, revUri.toString());\r\n\r\n // \"toOrderedString\" should maintain the user-defined ordering.\r\n\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraKijiURIBuilderDefault() {\r\n CassandraKijiURI uri = CassandraKijiURI.newBuilder().build();\r\n assertTrue(!uri.getZookeeperQuorum().isEmpty()); // Test cannot be more specific.\r\n // Test cannot validate the value of uri.getZookeeperClientPort().\r\n assertEquals(KConstants.DEFAULT_INSTANCE_NAME, uri.getInstance());\r\n assertEquals(null, uri.getTable());\r\n assertTrue(uri.getColumns().isEmpty());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraKijiURIBuilderFromInstance() {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost:1234/chost:5678/.unset/table\").build();\r\n CassandraKijiURI built = CassandraKijiURI.newBuilder(uri).build();\r\n assertEquals(uri, built);\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testCassandraKijiURIBuilderWithInstance() {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost:1234/chost:5678/instance1/table\").build();\r\n assertEquals(\"instance1\", uri.getInstance());\r\n final CassandraKijiURI modified =\r\n CassandraKijiURI.newBuilder(uri).withInstanceName(\"instance2\").build();\r\n assertEquals(\"instance2\", modified.getInstance());\r\n assertEquals(\"instance1\", uri.getInstance());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSetColumn() {\r\n CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost/chost:5678/instance/table/\").build();\r\n assertTrue(uri.getColumns().isEmpty());\r\n uri =\r\n CassandraKijiURI.newBuilder(uri).withColumnNames(Arrays.asList(\"testcol1\", \"testcol2\"))\r\n .build();\r\n assertEquals(2, uri.getColumns().size());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testSetZookeeperQuorum() {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost/chost:5678/instance/table/col\").build();\r\n final CassandraKijiURI modified = CassandraKijiURI.newBuilder(uri)\r\n .withZookeeperQuorum(new String[] {\"zkhost1\", \"zkhost2\"}).build();\r\n assertEquals(2, modified.getZookeeperQuorum().size());\r\n assertEquals(\"zkhost1\", modified.getZookeeperQuorum().get(0));\r\n assertEquals(\"zkhost2\", modified.getZookeeperQuorum().get(1));\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testTrailingUnset() {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost/chost:5678/.unset/table/.unset\").build();\r\n CassandraKijiURI result = CassandraKijiURI.newBuilder(uri).withTableName(\".unset\").build();\r\n assertEquals(\"kiji-cassandra://zkhost:2181/chost:5678/\", result.toString());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testEscapedMapColumnQualifier() {\r\n final CassandraKijiURI uri = CassandraKijiURI.newBuilder(\r\n \"kiji-cassandra://zkhost/chost:5678/instance/table/map:one%20two\").build();\r\n assertEquals(\"map:one two\", uri.getColumns().get(0).getName());\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static CassandraKijiURIBuilder newBuilder() {\r\n return new CassandraKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testConstructedUriIsEscaped() {\r\n // SCHEMA-6. Column qualifier must be URL-encoded in CassandraKijiURI.\r\n final CassandraKijiURI uri =\r\n CassandraKijiURI.newBuilder(\"kiji-cassandra://zkhost/chost:5678/instance/table/\")\r\n .addColumnName(new KijiColumnName(\"map:one two\")).build();\r\n assertEquals(\r\n \"kiji-cassandra://zkhost:2181/chost:5678/instance/table/map:one%20two/\", uri.toString());\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by Cassandra.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetFullyQualifiedColumn() throws Exception {\r\n for (KijiColumnName column : ImmutableList.of(PRIMITIVE_STRING, STRING_MAP_1)) {\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .build();\r\n\r\n testViewGet(request, Iterables.limit(ROW_DATA.get(column).entrySet(), 1));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.limit(ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet(), 1));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n ROW_DATA.get(column).entrySet());\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column.getFamily(), column.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n testViewGet(\r\n request,\r\n ROW_DATA.get(column).subMap(6L, false, 4L, true).entrySet());\r\n }\r\n }\r\n }\r\n }"} {"description": "[\"('/** {@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')\"]", "focal_method": "b'/** {@inheritDoc} */'@Override\r\n public Filter toHBaseFilter(Context context) throws IOException {\r\n // In the case that we have enough information to generate a prefix, we will\r\n // construct a PrefixFilter that is AND'ed with the RowFilter. This way,\r\n // when the scan passes the end of the prefix, it can end the filtering\r\n // process quickly.\r\n boolean addPrefixFilter = false;\r\n ByteArrayOutputStream prefixBytes = new ByteArrayOutputStream();\r\n\r\n // Define a regular expression that effectively creates a mask for the row\r\n // key based on the key format and the components passed in. Prefix hashes\r\n // are skipped over, and null components match any value.\r\n // ISO-8859-1 is used so that numerals map to valid characters\r\n // see http://stackoverflow.com/a/1387184\r\n\r\n // Use the embedded flag (?s) to turn on single-line mode; this makes the\r\n // '.' match on line terminators. The RegexStringComparator uses the DOTALL\r\n // flag during construction, but it does not use that flag upon\r\n // deserialization. This bug has been fixed in HBASE-5667, part of the 0.95\r\n // release.\r\n StringBuilder regex = new StringBuilder(\"(?s)^\"); // ^ matches the beginning of the string\r\n if (null != mRowKeyFormat.getSalt()) {\r\n if (mRowKeyFormat.getSalt().getHashSize() > 0) {\r\n // If all of the components included in the hash have been specified,\r\n // then match on the value of the hash\r\n Object[] prefixComponents =\r\n getNonNullPrefixComponents(mComponents, mRowKeyFormat.getRangeScanStartIndex());\r\n if (prefixComponents.length == mRowKeyFormat.getRangeScanStartIndex()) {\r\n ByteArrayOutputStream tohash = new ByteArrayOutputStream();\r\n for (Object component : prefixComponents) {\r\n byte[] componentBytes = toBytes(component);\r\n tohash.write(componentBytes, 0, componentBytes.length);\r\n }\r\n byte[] hashed = Arrays.copyOfRange(Hasher.hash(tohash.toByteArray()), 0,\r\n mRowKeyFormat.getSalt().getHashSize());\r\n for (byte hashedByte : hashed) {\r\n regex.append(String.format(\"\\\\x%02x\", hashedByte & 0xFF));\r\n }\r\n\r\n addPrefixFilter = true;\r\n // Write the hashed bytes to the prefix buffer\r\n prefixBytes.write(hashed, 0, hashed.length);\r\n } else {\r\n // match any character exactly 'hash size' number of times\r\n regex.append(\".{\").append(mRowKeyFormat.getSalt().getHashSize()).append(\"}\");\r\n }\r\n }\r\n }\r\n // Only add to the prefix buffer until we hit a null component. We do this\r\n // here, because the prefix is going to expect to have 0x00 component\r\n // terminators, which we put in during this loop but not in the loop above.\r\n boolean hitNullComponent = false;\r\n for (int i = 0; i < mComponents.length; i++) {\r\n final Object component = mComponents[i];\r\n switch (mRowKeyFormat.getComponents().get(i).getType()) {\r\n case INTEGER:\r\n if (null == component) {\r\n // null integers can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_INT).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Integer) component);\r\n // match each byte in the integer using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case LONG:\r\n if (null == component) {\r\n // null longs can be excluded entirely if there are just nulls at\r\n // the end of the EntityId, otherwise, match the correct number of\r\n // bytes\r\n regex.append(\"(.{\").append(Bytes.SIZEOF_LONG).append(\"})?\");\r\n hitNullComponent = true;\r\n } else {\r\n byte[] tempBytes = toBytes((Long) component);\r\n // match each byte in the long using a regex hex sequence\r\n for (byte tempByte : tempBytes) {\r\n regex.append(String.format(\"\\\\x%02x\", tempByte & 0xFF));\r\n }\r\n if (!hitNullComponent) {\r\n prefixBytes.write(tempBytes, 0, tempBytes.length);\r\n }\r\n }\r\n break;\r\n case STRING:\r\n if (null == component) {\r\n // match any non-zero character at least once, followed by a zero\r\n // delimiter, or match nothing at all in case the component was at\r\n // the end of the EntityId and skipped entirely\r\n regex.append(\"([^\\\\x00]+\\\\x00)?\");\r\n hitNullComponent = true;\r\n } else {\r\n // FormattedEntityId converts a string component to UTF-8 bytes to\r\n // create the HBase key. RegexStringComparator will convert the\r\n // value it sees (ie, the HBase key) to a string using ISO-8859-1.\r\n // Therefore, we need to write ISO-8859-1 characters to our regex so\r\n // that the comparison happens correctly.\r\n byte[] utfBytes = toBytes((String) component);\r\n String isoString = new String(utfBytes, Charsets.ISO_8859_1);\r\n regex.append(isoString).append(\"\\\\x00\");\r\n if (!hitNullComponent) {\r\n prefixBytes.write(utfBytes, 0, utfBytes.length);\r\n prefixBytes.write((byte) 0);\r\n }\r\n }\r\n break;\r\n default:\r\n throw new IllegalStateException(\"Unknown component type: \"\r\n + mRowKeyFormat.getComponents().get(i).getType());\r\n }\r\n }\r\n regex.append(\"$\"); // $ matches the end of the string\r\n\r\n final RowFilter regexRowFilter =\r\n SchemaPlatformBridge.get().createRowFilterFromRegex(CompareOp.EQUAL, regex.toString());\r\n if (addPrefixFilter) {\r\n return new FilterList(new PrefixFilter(prefixBytes.toByteArray()), regexRowFilter);\r\n }\r\n return regexRowFilter;\r\n }", "test_case": "@Test\r\n public void testPrefixFilterHaltsFiltering() throws Exception {\r\n RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG, LONG);\r\n EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);\r\n FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100, null, 9000L);\r\n Filter hbaseFilter = filter.toHBaseFilter(null);\r\n\r\n EntityId passingEntityId = factory.getEntityId(100, 100L, 9000L);\r\n byte[] passingHbaseKey = passingEntityId.getHBaseRowKey();\r\n doInclusionAssert(rowKeyFormat, filter, passingEntityId, hbaseFilter, passingHbaseKey, INCLUDE);\r\n boolean filterAllRemaining = hbaseFilter.filterAllRemaining();\r\n String message = createFailureMessage(rowKeyFormat, filter, passingEntityId, hbaseFilter,\r\n passingHbaseKey, filterAllRemaining);\r\n assertEquals(message, false, filterAllRemaining);\r\n\r\n EntityId failingEntityId = factory.getEntityId(101, 100L, 9000L);\r\n byte[] failingHbaseKey = failingEntityId.getHBaseRowKey();\r\n doInclusionAssert(rowKeyFormat, filter, failingEntityId, hbaseFilter, failingHbaseKey, EXCLUDE);\r\n filterAllRemaining = hbaseFilter.filterAllRemaining();\r\n message = createFailureMessage(rowKeyFormat, filter, failingEntityId, hbaseFilter,\r\n failingHbaseKey, filterAllRemaining);\r\n assertEquals(message, true, filterAllRemaining);\r\n }"} {"description": "['(\\'/**\\\\\\\\n * Gets a builder configured with default Kiji URI fields.\\\\\\\\n *\\\\\\\\n * More precisely, the following defaults are initialized:\\\\\\\\n *
      \\\\\\\\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\\\\\\\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\\\\\\\n * (\"default\").
    • \\\\\\\\n *
    • The table name and column names are explicitly left unset.
    • \\\\\\\\n *
    \\\\\\\\n *\\\\\\\\n * @return A builder configured with this Kiji URI.\\\\\\\\n */\\', \\'\\')']", "focal_method": "b'/**\\n * Gets a builder configured with default Kiji URI fields.\\n *\\n * More precisely, the following defaults are initialized:\\n *
      \\n *
    • The Zookeeper quorum and client port is taken from the Hadoop Configuration
    • \\n *
    • The Kiji instance name is set to KConstants.DEFAULT_INSTANCE_NAME\\n * (\"default\").
    • \\n *
    • The table name and column names are explicitly left unset.
    • \\n *
    \\n *\\n * @return A builder configured with this Kiji URI.\\n */'public static HBaseKijiURIBuilder newBuilder() {\r\n return new HBaseKijiURIBuilder();\r\n }", "test_case": "@Test\r\n public void testKijiURIBuilderFromInstance() {\r\n final KijiURI uri = KijiURI.newBuilder(\"kiji-hbase://zkhost:1234/.unset/table\").build();\r\n KijiURI built = KijiURI.newBuilder(uri).build();\r\n assertEquals(uri, built);\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by Cassandra.\\\\\\\\n *\\\\\\\\n * @param entityId EntityId of the row from which to read cells.\\\\\\\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\\\\\\\n * @param table The table being viewed.\\\\\\\\n * @param layout The layout of the table.\\\\\\\\n * @param columnTranslator A column name translator for the table.\\\\\\\\n * @param decoderProvider A cell decoder provider for the table.\\\\\\\\n * @param The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMultipleFullyQualifiedColumns() throws Exception {\r\n final KijiColumnName column1 = PRIMITIVE_STRING;\r\n final KijiColumnName column2 = STRING_MAP_1;\r\n\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable> column1Entries = ROW_DATA.get(column1).entrySet();\r\n final Iterable> column2Entries = ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier())\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Mixed versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column1.getFamily(), column1.getQualifier()))\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(1)\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Mixed versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(1)\r\n .add(column1.getFamily(), column1.getQualifier()))\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(column2.getFamily(), column2.getQualifier()))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by 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 The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetFamilyColumn() throws Exception {\r\n final Map> families =\r\n ImmutableMap.of(\r\n PRIMITIVE_FAMILY, ImmutableList.of(PRIMITIVE_DOUBLE, PRIMITIVE_STRING),\r\n STRING_MAP_FAMILY, ImmutableList.of(STRING_MAP_1, STRING_MAP_2));\r\n\r\n for (Entry> family : families.entrySet()) {\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n final KijiColumnName familyColumn = KijiColumnName.create(family.getKey(), null);\r\n final KijiColumnName column1 = family.getValue().get(0);\r\n final KijiColumnName column2 = family.getValue().get(1);\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef\r\n .create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(familyColumn))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).entrySet();\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef\r\n .create()\r\n .withPageSize(pageSize)\r\n .withMaxVersions(100)\r\n .add(familyColumn))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(request, Iterables.concat(column1Entries, column2Entries));\r\n }\r\n }\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by 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 The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testGetMultipleFamilyColumns() throws Exception {\r\n final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);\r\n final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);\r\n\r\n final KijiColumnName column1 = PRIMITIVE_DOUBLE;\r\n final KijiColumnName column2 = PRIMITIVE_STRING;\r\n final KijiColumnName column3 = STRING_MAP_1;\r\n final KijiColumnName column4 = STRING_MAP_2;\r\n\r\n for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {\r\n\r\n { // Single version | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().add(familyColumn1))\r\n .addColumns(ColumnsDef.create().add(familyColumn2))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);\r\n final Iterable> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).entrySet(), 1);\r\n final Iterable> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Single version | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn1))\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .build();\r\n\r\n final Iterable> column1Entries = ROW_DATA.get(column1).entrySet();\r\n final Iterable> column2Entries = ROW_DATA.get(column2).entrySet();\r\n final Iterable> column3Entries = ROW_DATA.get(column3).entrySet();\r\n final Iterable> column4Entries = ROW_DATA.get(column4).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column3Entries =\r\n ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column4Entries =\r\n ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Mixed versions | no timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(2).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn2))\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n Iterables.limit(ROW_DATA.get(column1).entrySet(), 2);\r\n final Iterable> column2Entries =\r\n Iterables.limit(ROW_DATA.get(column2).entrySet(), 2);\r\n final Iterable> column3Entries = ROW_DATA.get(column3).entrySet();\r\n final Iterable> column4Entries = ROW_DATA.get(column4).entrySet();\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n\r\n { // Multiple versions | timerange\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(1).add(familyColumn2))\r\n .withTimeRange(4, 6)\r\n .build();\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();\r\n final Iterable> column3Entries =\r\n Iterables.limit(ROW_DATA.get(column3).subMap(6L, false, 4L, true).entrySet(), 1);\r\n final Iterable> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(6L, false, 4L, true).entrySet(), 1);\r\n\r\n testViewGet(\r\n request,\r\n Iterables.concat(column1Entries, column2Entries, column3Entries, column4Entries));\r\n }\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by 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 The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test\r\n public void testNarrowView() throws Exception {\r\n final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);\r\n final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);\r\n\r\n final KijiColumnName column1 = PRIMITIVE_DOUBLE;\r\n final KijiColumnName column2 = PRIMITIVE_STRING;\r\n final KijiColumnName column3 = STRING_MAP_1;\r\n final KijiColumnName column4 = STRING_MAP_2;\r\n\r\n for (int pageSize : ImmutableList.of(0)) {\r\n\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(familyColumn1))\r\n .addColumns(\r\n ColumnsDef.create().withPageSize(pageSize).withMaxVersions(100).add(column3))\r\n .addColumns(ColumnsDef.create().withPageSize(pageSize).add(column4))\r\n .withTimeRange(2, 10)\r\n .build();\r\n\r\n final KijiResult view = mReader.getResult(mTable.getEntityId(ROW), request);\r\n try {\r\n testViewGet(view.narrowView(PRIMITIVE_LONG), ImmutableList.>of());\r\n\r\n final Iterable> column1Entries =\r\n ROW_DATA.get(column1).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column1), column1Entries);\r\n\r\n final Iterable> column2Entries =\r\n ROW_DATA.get(column2).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column2), column2Entries);\r\n\r\n testViewGet(view.narrowView(familyColumn1),\r\n Iterables.concat(column1Entries, column2Entries));\r\n\r\n final Iterable> column3Entries =\r\n ROW_DATA.get(column3).subMap(10L, false, 2L, true).entrySet();\r\n testViewGet(view.narrowView(column3), column3Entries);\r\n\r\n final Iterable> column4Entries =\r\n Iterables.limit(ROW_DATA.get(column4).subMap(10L, false, 2L, true).entrySet(), 1);\r\n testViewGet(view.narrowView(column4), column4Entries);\r\n\r\n testViewGet(view.narrowView(familyColumn2),\r\n Iterables.concat(column3Entries, column4Entries));\r\n } finally {\r\n view.close();\r\n }\r\n }\r\n }"} {"description": "[\"('/**\\\\\\\\n * Create a new {@link KijiResult} backed by 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 The type of value in the {@code KijiCell} of this view.\\\\\\\\n * @return an {@code KijiResult}.\\\\\\\\n * @throws IOException On error while decoding cells.\\\\\\\\n */', '')\"]", "focal_method": "b'/**\\n * Create a new {@link KijiResult} backed by Cassandra.\\n *\\n * @param entityId EntityId of the row from which to read cells.\\n * @param dataRequest KijiDataRequest defining the values to retrieve.\\n * @param table The table being viewed.\\n * @param layout The layout of the table.\\n * @param columnTranslator A column name translator for the table.\\n * @param decoderProvider A cell decoder provider for the table.\\n * @param 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 KijiResult create(\r\n final EntityId entityId,\r\n final KijiDataRequest dataRequest,\r\n final CassandraKijiTable table,\r\n final KijiTableLayout layout,\r\n final CassandraColumnNameTranslator columnTranslator,\r\n final CellDecoderProvider decoderProvider\r\n ) throws IOException {\r\n final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();\r\n final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();\r\n unpagedRequestBuilder.withTimeRange(\r\n dataRequest.getMinTimestamp(),\r\n dataRequest.getMaxTimestamp());\r\n pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());\r\n\r\n for (final Column columnRequest : dataRequest.getColumns()) {\r\n if (columnRequest.getFilter() != null) {\r\n throw new UnsupportedOperationException(\r\n String.format(\"Cassandra Kiji does not support filters on column requests: %s.\",\r\n columnRequest));\r\n }\r\n if (columnRequest.isPagingEnabled()) {\r\n pagedRequestBuilder.newColumnsDef(columnRequest);\r\n } else {\r\n unpagedRequestBuilder.newColumnsDef(columnRequest);\r\n }\r\n }\r\n\r\n final CellDecoderProvider requestDecoderProvider =\r\n decoderProvider.getDecoderProviderForRequest(dataRequest);\r\n\r\n final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();\r\n final KijiDataRequest pagedRequest = pagedRequestBuilder.build();\r\n\r\n if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {\r\n return new EmptyKijiResult(entityId, dataRequest);\r\n }\r\n\r\n final MaterializedKijiResult materializedKijiResult;\r\n if (!unpagedRequest.isEmpty()) {\r\n materializedKijiResult =\r\n createMaterialized(\r\n table.getURI(),\r\n entityId,\r\n unpagedRequest,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider,\r\n table.getAdmin());\r\n } else {\r\n materializedKijiResult = null;\r\n }\r\n\r\n final CassandraPagedKijiResult pagedKijiResult;\r\n if (!pagedRequest.isEmpty()) {\r\n pagedKijiResult =\r\n new CassandraPagedKijiResult(\r\n entityId,\r\n pagedRequest,\r\n table,\r\n layout,\r\n columnTranslator,\r\n requestDecoderProvider);\r\n } else {\r\n pagedKijiResult = null;\r\n }\r\n\r\n if (unpagedRequest.isEmpty()) {\r\n return pagedKijiResult;\r\n } else if (pagedRequest.isEmpty()) {\r\n return materializedKijiResult;\r\n } else {\r\n return DefaultKijiResult.create(dataRequest, materializedKijiResult, pagedKijiResult);\r\n }\r\n }", "test_case": "@Test(expected = UnsupportedOperationException.class)\r\n public void testGetWithFilters() throws Exception {\r\n final KijiColumnName column2 = STRING_MAP_1;\r\n\r\n final KijiDataRequest request = KijiDataRequest\r\n .builder()\r\n .addColumns(\r\n ColumnsDef.create()\r\n .withFilter(\r\n new KijiColumnRangeFilter(\r\n STRING_MAP_1.getQualifier(), true,\r\n STRING_MAP_2.getQualifier(), false))\r\n .withMaxVersions(10)\r\n .add(column2.getFamily(), null))\r\n .build();\r\n\r\n final Iterable> column1Entries = ROW_DATA.get(column2).entrySet();\r\n\r\n testViewGet(request, column1Entries);\r\n }"}