if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));
if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));
mBuf.order(ByteOrder.nativeOrder()); mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));
/** * Writes a partition. */ public void writePartition() throws IOException, AlluxioException { if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf)); } mBuf.flip(); for (int pId = mLeft; pId < mRight; pId++) { final long startTimeMs = System.currentTimeMillis(); FileOutStream os = mFileSystem.createFile(new AlluxioURI(sFileName + (pId + sBaseFileNumber)), CreateFilePOptions.newBuilder().setRecursive(true).build()); for (int k = 0; k < sBlocksPerFile; k++) { mBuf.putInt(0, k + mWorkerId); os.write(mBuf.array()); } os.close(); logPerIteration(startTimeMs, pId, "th WriteAlluxioFile @ Worker ", pId); } }
/** * Tests the {@link FormatUtils#byteBufferToString(ByteBuffer)} method. */ @Test public void byteBufferToString() { class TestCase { String mExpected; ByteBuffer mInput; public TestCase(String expected, ByteBuffer input) { mExpected = expected; mInput = input; } } List<TestCase> testCases = new ArrayList<>(); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0, 0}))); testCases.add(new TestCase("", ByteBuffer.wrap(new byte[] {0, 0, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0}))); testCases.add(new TestCase("1", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0, 0}))); testCases.add(new TestCase("1 2", ByteBuffer.wrap(new byte[] {0, 0, 0, 1, 0, 0, 0, 2}))); for (TestCase testCase : testCases) { Assert.assertEquals(testCase.mExpected, FormatUtils.byteBufferToString(testCase.mInput)); } }
if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));
if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));
/** * Writes a partition. */ public void writePartition() throws IOException, AlluxioException { if (sDebugMode) { mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf)); } mBuf.flip(); for (int pId = mLeft; pId < mRight; pId++) { final long startTimeMs = System.currentTimeMillis(); FileOutStream os = mFileSystem.createFile(new AlluxioURI(sFileName + (pId + sBaseFileNumber))); for (int k = 0; k < sBlocksPerFile; k++) { mBuf.putInt(0, k + mWorkerId); os.write(mBuf.array()); } os.close(); logPerIteration(startTimeMs, pId, "th WriteAlluxioFile @ Worker ", pId); } }
mBuf.order(ByteOrder.nativeOrder()); mBuf.flip(); LOG.info(FormatUtils.byteBufferToString(mBuf));