Writes this record to the provided generator in the most efficient manner possible in the current state.
961898
void writeTo(JsonGenerator generator) throws IOException {
        DeserializationState deserState = _deserState.get();

        if (deserState.isDeserialized()) {
            // Object has already been deserialized, use standard writer
            generator.writeObject(deserState.deserialized);
            return;
        }

        if (deserState.overrides.isEmpty()) {
            // With no overrides the most efficient action is to copy the original JSON verbatim.
            try {
                generator.writeRaw(deserState.json);
                return;
            } catch (UnsupportedOperationException e) {
                // Not all parsers are guaranteed to support this.  If this is one then use the default
                // generator implementation which follows.
            }
        }

        ObjectCodec codec = generator.getCodec();
        if (codec == null) {
            // No codec, defer to generator
            generator.writeObject(deserialized());
            return;
        }

        JsonParser parser = codec.getFactory().createParser(deserState.json);
        checkState(parser.nextToken() == JsonToken.START_OBJECT, "JSON did not contain an object");
        generator.writeStartObject();

        // Typically the JSON string has been pre-sorted.  Insert the overrides in order.  If it turns out the
        // JSON wasn't sorted then we'll just dump the remaining overrides at the end; it's valid JSON
        // one way or the other.

        //noinspection unchecked
        Iterator<Map.Entry<String, Object>> sortedOverrides =
                ((Map<String, Object>) OrderedJson.ordered(deserState.overrides)).entrySet().iterator();

        Map.Entry<String, Object> nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;

        JsonToken token;
        while ((token = parser.nextToken()) != JsonToken.END_OBJECT) {
            assert token == JsonToken.FIELD_NAME;

            String field = parser.getText();
            if (deserState.overrides.containsKey(field)) {
                // There's an override for this entry; skip it
                token = parser.nextToken();
                if (token.isStructStart()) {
                    parser.skipChildren();
                }
            } else {
                // Write all overrides which sort prior to this field
                while (nextOverride != null && OrderedJson.KEY_COMPARATOR.compare(nextOverride.getKey(), field) < 0) {
                    generator.writeFieldName(nextOverride.getKey());
                    generator.writeObject(nextOverride.getValue());
                    nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;
                }

                // Copy this field name and value to the generator
                generator.copyCurrentStructure(parser);
            }
            // Both of the above operations leave the current token immediately prior to the next
            // field or the end object token.
        }

        // Write any remaining overrides
        while (nextOverride != null) {
            generator.writeFieldName(nextOverride.getKey());
            generator.writeObject(nextOverride.getValue());
            nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;
        }

        generator.writeEndObject();
    }
1022801
protected boolean writeNextRecord(T record) throws IOException {
		try {
			this.serializer.serialize(record, this.collectingView);
			this.numRecordsInBuffer++;
			return true;
		} catch (EOFException eofex) {
			return false;
		}
	}
892357
def write(self, arc_record):
        ""
        if not self.version:
            self.version = 2
        if not self.header_written:
            self.header_written = True
            self._write_header()
        arc_record.write_to(self.fileobj, self.version)
        self.fileobj.write("\n")
650665
private synchronized void updateRecordsWrittenMeter() {
    if (this.recordsWrittenMeter.isPresent()) {
      this.recordsWrittenMeter.get().mark(recordsWritten() - this.recordsWrittenMeter.get().getCount());
    }
  }
811122
public static void write(final BedRecord record, final PrintWriter writer) {
        checkNotNull(record);
        checkNotNull(writer);
        writer.println(record.toString());
    }
1213253
private void performNextWrite() {
        Append append = getNextAppend();
        if (append == null) {
            return;
        }
        long traceId = LoggerHelpers.traceEnter(log, "storeAppend", append);
        Timer timer = new Timer();
        storeAppend(append)
                .whenComplete((v, e) -> {
                    handleAppendResult(append, e, timer);
                    LoggerHelpers.traceLeave(log, "storeAppend", traceId, v, e);
                })
                .whenComplete((v, e) -> append.getData().release());
    }
1220503
public void write( IGeneratorSet generatorSet)
    {
    writer_.writeDeclaration();

    writer_
      .element( GENERATORS_TAG)
      .content( () ->
        {
        Arrays.stream( generatorSet.getGeneratorFunctions())
          .sorted()
          .forEach( function -> writeGenerator( function, generatorSet.getGenerator( function)));
        })
      .write();
    }
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.");
        }
    }
1032951
def _write_tfrecords_from_generator(generator, output_files, shuffle=True):
  """"""
  if do_files_exist(output_files):
    raise ValueError(
        "Pre-processed files already exists: {}.".format(output_files))

  with _incomplete_files(output_files) as tmp_files:
    # Write all shards
    writers = [tf.io.TFRecordWriter(fname) for fname in tmp_files]
    with _close_on_exit(writers) as writers:
      logging.info("Writing TFRecords")
      _round_robin_write(writers, generator)
    # Shuffle each shard
    if shuffle:
      # WARNING: Using np instead of Python random because Python random
      # produce different values between Python 2 and 3 and between
      # architectures
      random_gen = np.random.RandomState(42)
      for path in utils.tqdm(
          tmp_files, desc="Shuffling...", unit=" shard", leave=False):
        _shuffle_tfrecord(path, random_gen=random_gen)
541792
private void processWritesSync() {
        if (this.closed.get()) {
            // BookKeeperLog is closed. No point in trying anything else.
            return;
        }

        if (getWriteLedger().ledger.isClosed()) {
            // Current ledger is closed. Execute the rollover processor to safely create a new ledger. This will reinvoke
            // the write processor upon finish, so the writes can be reattempted.
            this.rolloverProcessor.runAsync();
        } else if (!processPendingWrites() && !this.closed.get()) {
            // We were not able to complete execution of all writes. Try again.
            this.writeProcessor.runAsync();
        }
    }
991112
protected function generateSlugAndSave()
    {
        if ($this->slugWorkingRecord->{$this->slugDbField}) {
            return;
        }

        $this->generateSlug();

        if ($this->slugWorkingRecord->{$this->slugDbField}) {
            $this->slugWorkingRecord->write();
        }
    }
1016244
public void write(Collection<? extends E> elements) throws IOException {
		final Progression progressBar = getTaskProgression();
		Progression subTask = null;

		if (progressBar != null) {
			progressBar.setProperties(0, 0, (elements.size() + 1) * 100, false);
		}

		if (this.fileBounds == null) {
			this.fileBounds = getFileBounds();
		}

		if (this.fileBounds != null) {
			writeHeader(this.fileBounds, this.elementType, elements);

			if (progressBar != null) {
				progressBar.setValue(100);
				subTask = progressBar.subTask(elements.size() * 100);
				subTask.setProperties(0, 0, elements.size(), false);
			}

			for (final E element : elements) {

				writeElement(this.recordIndex, element, this.elementType);

				if (subTask != null) {
					subTask.setValue(this.recordIndex + 1);
				}

				++this.recordIndex;

			}
		} else {
			throw new BoundsNotFoundException();
		}

		if (progressBar != null) {
			progressBar.end();
		}
	}
820122
@Override
    public void write(DataOutput out) throws IOException {
        if (record != null) record.write(out);
    }
688021
public static void write(final Iterable<BedRecord> records, final PrintWriter writer) {
        checkNotNull(records);
        checkNotNull(writer);
        for (BedRecord record : records) {
            writer.println(record.toString());
        }
    }
1365660
private void synchronizedRecordResult(CircuitBreakerResult result) {
        synchronized (this) {
            switch (state.get()) {
                case CLOSED:
                    rollingWindow.record(result);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Recording result {0} in closed state: {1}", result, rollingWindow);
                    }
                    if (rollingWindow.isOverThreshold()) {
                        stateOpen();
                    }
                    break;
                case HALF_OPEN:
                    if (result == CircuitBreakerResult.FAILURE) {
                        stateOpen();
                    } else {
                        halfOpenRunningExecutions--;
                        halfOpenSuccessfulExecutions++;
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Recording result {0} in half-open state. Running executions: {1}, Current results: ({2}/{3})",
                                     result, halfOpenRunningExecutions, halfOpenSuccessfulExecutions, policy.getSuccessThreshold());
                        }
                        if (halfOpenSuccessfulExecutions >= policy.getSuccessThreshold()) {
                            stateClosed();
                        }
                    }
                    break;
                case OPEN:
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Recording result {0} in open state", result);
                    }
                    // Nothing else to do
                    break;
            }
        }
    }
107952
protected Record next(Writer writer) {
        Value value = recordIte.next();

        if (valuesLabels != null) {
            int i = 0;
            for (ValueWritable vw : value.getValues()) {
                vw.getLabel().set(valuesLabels[i++]);
            }
        }

        currentRecord.setValue(value);
        writer.setDefaultRecord(currentRecord);
        return currentRecord;
    }
1202222
public boolean withRecord(final int key, final RecordWriter writer)
    {
        final int claimedOffset = claimRecord(key);
        if (claimedOffset == DID_NOT_CLAIM_RECORD)
        {
            return false;
        }

        try
        {
            writer.writeRecord(claimedOffset);
        }
        finally
        {
            commit(claimedOffset);
        }

        return true;
    }