diff --git "a/train.jsonl" "b/train.jsonl" new file mode 100644--- /dev/null +++ "b/train.jsonl" @@ -0,0 +1,300 @@ +{"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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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, IVecy <=> (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 * \\n\\t * If
\\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 * 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 * @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 \\n\\t * false and false: then 123.45 -> 123 \\n\\t * 0.678 -> 1 \\n\\t * true and false: then 123.45 -> 123. \\n\\t * 0.678 -> 1. \\n\\t * true and true: then 123.45 -> 123.0 \\n\\t * 0.678 -> 1.0 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 *\\n\\t * @param requestedDigits number of digits after the decimal point(last digit rounded)\\n\\t * @param formatOptions\\n\\t * @throws IllegalArgumentException if
\\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 * 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 * 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 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). More precisely, merges are handled in the following way: After calling build(), you may not use the builder anymore. 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. 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. 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. 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. 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. 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. 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. 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. After calling build(), you may not use the builder anymore. After calling build(), you may not use the builder anymore. 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. 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. 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. 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. 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. 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. A valid Java identifier may not start with a number, but may contain any\\n * combination of letters, digits, underscores, or dollar signs. See the \\n * Java Language Specification If this method returns true, it does not necessarily mean that the Java class with\\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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: 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. The following are examples of legal protocol versions: The following are illegal: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\tArrayListFormattedEntityIdRowFilter
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 *\\\\\\\\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 *\\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\\\\\\\\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 *\\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\\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\\\\\\\\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 *\\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 * 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 * \\\\\\\\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 *\\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\\\\\\\\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 *
\\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 *
\\\\\\\\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 *
\\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 *
\\\\\\\\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 *\\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 *
\\\\\\\\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 *
\\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 *
\\\\\\\\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 *
\\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 *
\\\\\\\\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 *
\\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 *
\\\\\\\\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 *
\\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\\\\\\\\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 *\\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\\\\\\\\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 *\\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\\\\\\\\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 *\\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\\\\\\\\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 *\\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\"hbase=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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 *
\\\\\\\\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 *\\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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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=...\"
\\\\\\\\n * \"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=...\"
\\n * \"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\\\\\\\\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 *\\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\\\\\\\\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 *\\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\\\\\\\\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 *\\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 * className
exists; it only means that one could write a Java class with\\n * that fully-qualified name.\\\\\\\\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 *\\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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\\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 *
\\\\\\\\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 *\\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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 *
\\\\\\\\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 *\\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 * \\\\\\\\n *
\\\\\\\\n *\\\\\\\\n * \\\\\\\\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 * \\n *
\\n *\\n * \\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