MCPcopy Create free account
hub / github.com/cschanck/single-file-java / write

Method write

src/main/java/org/sfj/ChiseledMap.java:322–344  ·  view source on GitHub ↗
(ByteBuffer len, ByteBuffer arr, ByteBuffer d, int fp)

Source from the content-addressed store, hash-verified

320 }
321
322 private void write(ByteBuffer len, ByteBuffer arr, ByteBuffer d, int fp) throws IOException {
323 // write the data into the buffer, flushing if necessary
324 if (writeBuffer.capacity() < fp) {
325 // can't use the write buffer, flush pending and write it explicitly.
326 flushBuffer();
327 ByteBuffer tmp = ByteBuffer.allocateDirect(fp);
328 tmp.put(len);
329 tmp.put(arr);
330 tmp.put(d);
331 tmp.flip();
332 flushBuffer(tmp);
333 } else {
334 if (writeBuffer.remaining() < fp) {
335 // no room at the inn. flush and go.
336 flushBuffer();
337 }
338 // actually append the 3 parts to the buffer, inc the counter.
339 writeBuffer.put(len);
340 writeBuffer.put(arr);
341 writeBuffer.put(d);
342 pendingWrites++;
343 }
344 }
345
346 private void writeFully(ByteBuffer b, long pos) throws IOException {
347 while (b.hasRemaining()) {

Callers 2

appendMethod · 0.95
writeFullyMethod · 0.45

Calls 2

flushBufferMethod · 0.95
putMethod · 0.45

Tested by

no test coverage detected