Write a batch of edits to the journal.
{@see QJournalProtocol#journal(RequestInfo, long, long, int, byte[])}
160270
synchronized ShortVoid journal(RequestInfo reqInfo, 
      long segmentTxId, long firstTxnId, 
      int numTxns, byte[] records) throws IOException {
    checkJournalStorageFormatted();
    checkWriteRequest(reqInfo);

    if (curSegment == null) {
      checkSync(false, "Can't write, no segment open");
    }
    
    if (curSegmentTxId != segmentTxId) {
      // Sanity check: it is possible that the writer will fail IPCs
      // on both the finalize() and then the start() of the next segment.
      // This could cause us to continue writing to an old segment
      // instead of rolling to a new one, which breaks one of the
      // invariants in the design. If it happens, abort the segment
      // and throw an exception.
      JournalOutOfSyncException e = new JournalOutOfSyncException(
          "Writer out of sync: it thinks it is writing segment " + segmentTxId
          + " but current segment is " + curSegmentTxId);
      abortCurSegment();
      throw e;
    }
      
    if (nextTxId != firstTxnId) {
      checkSync(false, "Can't write txid " + firstTxnId
          + " expecting nextTxId=" + nextTxId);
    }
    
    long lastTxnId = firstTxnId + numTxns - 1;
    if (LOG.isTraceEnabled()) {
      LOG.trace("Writing txid " + firstTxnId + "-" + lastTxnId);
    }

    // If the edit has already been marked as committed, we know
    // it has been fsynced on a quorum of other nodes, and we are
    // "catching up" with the rest. Hence we do not need to fsync.
    boolean isLagging = lastTxnId <= committedTxnId.get();
    boolean shouldFsync = !isLagging;
    
    curSegment.writeRaw(records, 0, records.length);
    curSegment.setReadyToFlush();
    long start = System.nanoTime();
    curSegment.flush(shouldFsync);
    long time = DFSUtil.getElapsedTimeMicroSeconds(start);
    currentSegmentWrittenBytes += records.length;
    
    metrics.addSync(time);
    
    if (time / 1000 > WARN_SYNC_MILLIS_THRESHOLD) {
      LOG.warn("Sync of transaction range " + firstTxnId + "-" + lastTxnId + 
               " took " + (time / 1000) + "ms");
    }

    if (isLagging) {
      // This batch of edits has already been committed on a quorum of other
      // nodes. So, we are in "catch up" mode. This gets its own metric.
      metrics.batchesWrittenWhileLagging.inc(1);
    }
    
    metrics.batchesWritten.inc(1);
    metrics.bytesWritten.inc(records.length);
    metrics.txnsWritten.inc(numTxns);
    
    highestWrittenTxId = lastTxnId;
    metrics.setLastWrittenTxId(highestWrittenTxId);
    metrics.setCurrentTxnsLag(getCurrentLagTxns());
    nextTxId = lastTxnId + 1;
    return ShortVoid.instance;
  }
489969
@Override
	public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
		this.startOutput();
		for (String formattedResult : messageFormatter.formatResults(results, server)) {
				log.debug("Sending result: {}", formattedResult);
				this.sendOutput(formattedResult);
		}
		this.finishOutput();
	}
1159962
@Override
    public void write(Iterable<QueryResult> results) {
        for (QueryResult result : results) {
            try {
                out.write(result.toString());
            } catch (IOException e) {
                // never occurs
            }
        }
    }
642013
protected void submitTraces() {
        if (!traces.isEmpty()) {
            // Locally store list and create new list for subsequent traces
            List<Trace> toSend = traces;
            traces = new ArrayList<>(batchSize + 1);

            executor.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        tracePublisher.publish(tenantId, toSend);
                    } catch (Exception e) {
                        // TODO: Retain for retry
                        log.log(Level.SEVERE, "Failed to publish traces", e);
                    }
                }
            });
        }
    }
825244
public void batchWrite(List<? extends Object> objectsToWrite, List<? extends Object> objectsToDelete) {
        batchWrite(objectsToWrite, objectsToDelete, this.config);
    }
866325
public final void increaseWrittenBytes(int increment, long currentTime) {
        if (increment <= 0) {
            return;
        }

        writtenBytes += increment;
        lastWriteTime = currentTime;
        idleCountForBoth.set(0);
        idleCountForWrite.set(0);

//        if (getService() instanceof AbstractIoService) {
//            ((AbstractIoService) getService()).getStatistics().increaseWrittenBytes(increment, currentTime);
//        }

        increaseScheduledWriteBytes(-increment);
    }
1312918
def write_batch(self, batch):
        
        for item in batch:
            self.write_buffer.buffer(item)
            key = self.write_buffer.get_key_from_item(item)
            if self.write_buffer.should_write_buffer(key):
                self._write_current_buffer_for_group_key(key)
            self.increment_written_items()
            self._check_items_limit()
1140511
public final void writeTo(DataOutput dout) throws IOException {
        dout.writeShort(mNameConstant.getIndex());
        dout.writeInt(getLength());
        writeDataTo(dout);
    }
1097896
@Override
    public void write(int b) throws IOException {
        Exceptions.checkNotClosed(this.closed, this);
        Preconditions.checkState(this.currentFrame != null, "No current frame exists. Most likely no record is started.");

        int attemptCount = 0;
        int totalBytesWritten = 0;
        while (totalBytesWritten == 0 && attemptCount < 2) {
            // We attempt to write 1 byte. If append() says it wrote 0 bytes, it means the current frame is full. Seal it and create a new one.
            totalBytesWritten += this.currentFrame.append((byte) b);
            if (totalBytesWritten == 0) {
                this.currentFrame.endEntry(false); // Close the current entry, and indicate it is not the last one of the record.
                flush();
                createNewFrame();
                startNewRecordInCurrentFrame(false);
            }

            attemptCount++;
        }

        if (totalBytesWritten == 0) {
            throw new SerializationException("Unable to make progress in serializing to DataFrame.");
        }
    }
757036
private void writeObject(ObjectOutputStream out) throws IOException {
		out.writeInt(batchSize);
		this.conf.write(out);
		out.writeUTF(schema.toString());

		out.writeInt(selectedFields.length);
		for (int f : selectedFields) {
			out.writeInt(f);
		}

		out.writeInt(conjunctPredicates.size());
		for (Predicate p : conjunctPredicates) {
			out.writeObject(p);
		}
	}
612956
public void write(ObjectWriter out, PlainChangesLog pcl) throws IOException
   {
      // write id
      out.writeInt(SerializationConstants.PLAIN_CHANGES_LOG_IMPL);

      out.writeInt(pcl.getEventType());
      out.writeString(pcl.getSessionId());

      List<ItemState> list = pcl.getAllStates();

      int listSize = list.size();
      out.writeInt(listSize);
      ItemStateWriter wr = new ItemStateWriter();
      for (int i = 0; i < listSize; i++)
      {
         wr.write(out, list.get(i));
      }

   }
256757
private synchronized void updateBytesWrittenMeter() {
    if (this.bytesWrittenMeter.isPresent()) {
      try {
        this.bytesWrittenMeter.get().mark(bytesWritten() - this.bytesWrittenMeter.get().getCount());
      } catch (IOException e) {
        log.error("Cannot get bytesWritten for DataWriter, will not update " + this.bytesWrittenMeter.get().toString(),
            e);
      }
    }
  }
126328
@Override
    public void write(DataOutput out) throws IOException {
        out.writeInt(contentType.ordinal());
        if (content != null) {
            WritableUtils.writeVInt(out, content.length);
            out.write(content, 0, content.length);
        } else if (is != null) {
            content = new byte[MAX_BUFFER_SIZE];
            int len = 0;
            while ((len = is.read(content)) > 0) {
                out.write(content, 0, len);
            }
        }      
    }
872410
public void write(WriteOptions writeOptions, WriteBatch batch) throws RocksDbException {
        try {
            rocksDb.write(writeOptions != null ? writeOptions : this.writeOptions, batch);
        } catch (Exception e) {
            throw e instanceof RocksDbException ? (RocksDbException) e : new RocksDbException(e);
        }
    }
1280824
function writeFlushed() {
          ee.emit('written', { total: obj.total, time: obj.time, batch: obj.batch });
          if (logCompletedBatch) {
            logCompletedBatch(obj.batch);
          }
          debug(' backed up batch', obj.batch, ' docs: ', obj.total, 'Time', obj.time);
        }
857661
@Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    request.writeTo(out);

    if (filteringAliases == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      out.writeStringArray(filteringAliases);
    }
  }
1112586
void writeTo(OutputStream out) throws IOException {
		//TODO could optimize for aligned instances
		final int size = finish - start;
		final int length = (size + 7) >> 3;
		if (length == 0) return;
		int p = size & 7;
		final int q = finish - p;
		if (p != 0) out.write((byte) getBitsAdj(q, p));
		p = q;
		while (p > start) {
			p -= 8;
			out.write((byte) getBitsAdj(p, 8));
		}
	}