private void writeInt(FileOutputStream fos, int dataSize) throws IOException { ensureBufHasRoom(fos, INT_SIZE_IN_BYTES); writeIntB(tmpBytes, 0, dataSize); buf.put(tmpBytes); }
private void writeInt(FileOutputStream fos, int dataSize) throws IOException { ensureBufHasRoom(fos, INT_SIZE_IN_BYTES); writeIntB(tmpBytes, 0, dataSize); buf.put(tmpBytes); }
private void writeKeySet(FileOutputStream fos, FileChannel outChannel, Iterator<K> iterator) throws IOException { while (iterator.hasNext()) { K key = iterator.next(); Data dataKey = serializationService.toData(key); if (dataKey != null) { int dataSize = dataKey.totalSize(); writeInt(fos, dataSize); int position = 0; int remaining = dataSize; while (remaining > 0) { int transferredCount = Math.min(BUFFER_SIZE - buf.position(), remaining); ensureBufHasRoom(fos, transferredCount); buf.put(dataKey.toByteArray(), position, transferredCount); position += transferredCount; remaining -= transferredCount; } lastWrittenBytes += INT_SIZE_IN_BYTES + dataSize; lastKeyCount++; } flushLocalBuffer(outChannel); } }
private void writeKeySet(FileOutputStream fos, FileChannel outChannel, Iterator<K> iterator) throws IOException { while (iterator.hasNext()) { K key = iterator.next(); Data dataKey = serializationService.toData(key); if (dataKey != null) { int dataSize = dataKey.totalSize(); writeInt(fos, dataSize); int position = 0; int remaining = dataSize; while (remaining > 0) { int transferredCount = Math.min(BUFFER_SIZE - buf.position(), remaining); ensureBufHasRoom(fos, transferredCount); buf.put(dataKey.toByteArray(), position, transferredCount); position += transferredCount; remaining -= transferredCount; } lastWrittenBytes += INT_SIZE_IN_BYTES + dataSize; lastKeyCount++; } flushLocalBuffer(outChannel); } }