region WriterSegmentProcessor Implementation
344820
@Override
    public long getLowestUncommittedSequenceNumber() {
        StorageOperation first = this.operations.getFirst();
        return first == null ? Operation.NO_SEQUENCE_NUMBER : first.getSequenceNumber();
    }
1129618
@Override
    public void writeFragmentTo(MwsWriter w) {
        w.write("ListOrdersByNextTokenResult", listOrdersByNextTokenResult);
        w.write("ResponseMetadata", responseMetadata);
    }
430370
public void formatRegion(XtextResource resource, int offset, int length) {
		assert resource != null;
		assert offset >= 0;
		assert length >= 0;
		final String result = formatResourceRegion(resource, offset, length);
		// Write back to the resource
		try (StringInputStream stringInputStream = new StringInputStream(result)) {
			resource.load(stringInputStream, Collections.emptyMap());
		} catch (Exception exception) {
			throw Exceptions.sneakyThrow(exception);
		}
	}
735724
public static void copyToView(
			MemorySegment[] segments,
			int offset,
			int sizeInBytes,
			DataOutputView target) throws IOException {
		for (MemorySegment sourceSegment : segments) {
			int curSegRemain = sourceSegment.size() - offset;
			if (curSegRemain > 0) {
				int copySize = Math.min(curSegRemain, sizeInBytes);

				byte[] bytes = allocateReuseBytes(copySize);
				sourceSegment.get(offset, bytes, 0, copySize);
				target.write(bytes, 0, copySize);

				sizeInBytes -= copySize;
				offset = 0;
			} else {
				offset -= sourceSegment.size();
			}

			if (sizeInBytes == 0) {
				return;
			}
		}

		if (sizeInBytes != 0) {
			throw new RuntimeException("No copy finished, this should be a bug, " +
					"The remaining length is: " + sizeInBytes);
		}
	}
192959
protected void writeFeatureLocation(Writer writer) throws IOException {
        new FeatureLocationWriter(entry, feature, wrapType,
        		featureHeader, qualifierHeader).write(writer);
    }
344593
private void writeElements(SerIterator itemIterator) throws IOException {
        if (itemIterator.metaTypeRequired()) {
            output.writeObjectStart();
            output.writeObjectKeyValue(META, itemIterator.metaTypeName());
            output.writeObjectKey(VALUE);
        }
        if (itemIterator.category() == SerCategory.MAP) {
            writeMap(itemIterator);
        } else if (itemIterator.category() == SerCategory.COUNTED) {
            writeCounted(itemIterator);
        } else if (itemIterator.category() == SerCategory.TABLE) {
            writeTable(itemIterator);
        } else if (itemIterator.category() == SerCategory.GRID) {
            writeGrid(itemIterator);
        } else {
            writeArray(itemIterator);
        }
        if (itemIterator.metaTypeRequired()) {
            output.writeObjectEnd();
        }
    }
163405
protected void writeSceneData (SparseMisoSceneModel model,
                                   DataWriter writer)
        throws SAXException
    {
        writer.dataElement("swidth", Integer.toString(model.swidth));
        writer.dataElement("sheight", Integer.toString(model.sheight));
        writer.dataElement("defTileSet", Integer.toString(model.defTileSet));

        writer.startElement("sections");
        for (Iterator<Section> iter = model.getSections(); iter.hasNext(); ) {
            Section sect = iter.next();
            if (sect.isBlank()) {
                continue;
            }
            AttributesImpl attrs = new AttributesImpl();
            attrs.addAttribute("", "x", "", "", String.valueOf(sect.x));
            attrs.addAttribute("", "y", "", "", String.valueOf(sect.y));
            attrs.addAttribute("", "width", "", "", String.valueOf(sect.width));
            writer.startElement("", "section", "", attrs);

            writer.dataElement(
                "base", StringUtil.toString(sect.baseTileIds, "", ""));

            // write our uninteresting object tile information
            writer.startElement("objects");
            for (int ii = 0; ii < sect.objectTileIds.length; ii++) {
                attrs = new AttributesImpl();
                attrs.addAttribute("", "tileId", "", "",
                                   String.valueOf(sect.objectTileIds[ii]));
                attrs.addAttribute("", "x", "", "",
                                   String.valueOf(sect.objectXs[ii]));
                attrs.addAttribute("", "y", "", "",
                                   String.valueOf(sect.objectYs[ii]));
                writer.emptyElement("", "object", "", attrs);
            }

            // write our interesting object tile information
            for (ObjectInfo element : sect.objectInfo) {
                writeInterestingObject(element, writer);
            }
            writer.endElement("objects");
            writer.endElement("section");
        }
        writer.endElement("sections");
    }
1157442
static int write(FileDescriptor fd, ByteBuffer src, long position,
                     NativeDispatcher nd)
        throws IOException
    {
        if (src instanceof DirectBuffer)
            return writeFromNativeBuffer(fd, src, position, nd);

        // Substitute a native buffer
        int pos = src.position();
        int lim = src.limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
        try {
            bb.put(src);
            bb.flip();
            // Do not update src until we see how many bytes were written
            src.position(pos);

            int n = writeFromNativeBuffer(fd, bb, position, nd);
            if (n > 0) {
                // now update src
                src.position(pos + n);
            }
            return n;
        } finally {
            Util.offerFirstTemporaryDirectBuffer(bb);
        }
    }
942777
@Override
  @InService(PageServiceImpl.class)
  void writeImpl(TableKelp table,
                 PageServiceImpl pageServiceImpl,
                 TableWriterService readWrite,
                 SegmentStream sOut,
                 long oldSequence,
                 int saveLength,
                 int saveTail)
  {
    Objects.requireNonNull(sOut);
    
    // System.out.println("WIMPL:" + this + " "+ Long.toHexString(System.identityHashCode(this)) + " " + _stub);
    if (saveLength <= 0
        || oldSequence != sOut.getSequence()
        || _stub == null
        || ! _stub.allowDelta()) {
      PageLeafImpl newPage;
      
      if (! isDirty() 
          && (_blocks.length == 0 || _blocks[0].isCompact())) {
        newPage = copy(getSequence());
      }
      else {
        newPage = compact(table);
      }

      int sequenceWrite = newPage.nextWriteSequence();

      if (! pageServiceImpl.compareAndSetLeaf(this, newPage)
          && ! pageServiceImpl.compareAndSetLeaf(_stub, newPage)) {
        System.out.println("HMPH: " + pageServiceImpl.getPage(getId()) + " " + this + " " + _stub);
      }
      
      saveLength = newPage.getDataLengthWritten();
      
      // newPage.write(db, pageActor, sOut, saveLength);
      
      // oldSequence = newPage.getSequence();
      
      saveTail = newPage.getSaveTail();
      
      newPage.clearDirty();

      readWrite.writePage(newPage, sOut,
                          oldSequence, saveLength, saveTail,
                          sequenceWrite,
                          Result.of(x->newPage.afterDataFlush(pageServiceImpl, sequenceWrite)));
    }
    else {
      int sequenceWrite = nextWriteSequence();
      
      clearDirty();
      
      readWrite.writePage(this, sOut,
                          oldSequence, saveLength, saveTail,
                          sequenceWrite,
                          Result.of(x->afterDataFlush(pageServiceImpl, sequenceWrite)));
    }
  }
415883
public static void writeToCheckpoint(OutputStream output, List<? extends Checkpointed> components)
      throws IOException, InterruptedException {
    OutputChunked chunked = new OutputChunked(
        new CheckpointOutputStream(output, CheckpointType.COMPOUND), 64 * Constants.KB);
    for (Checkpointed component : components) {
      chunked.writeString(component.getCheckpointName().toString());
      component.writeToCheckpoint(chunked);
      chunked.endChunks();
    }
    chunked.flush();
  }
959008
@Override
    public void writeFragmentTo(MwsWriter w) {
        w.write("CurrencyCode", currencyCode);
        w.write("Amount", amount);
    }
725677
protected function writeToIPCSegment()
    {
        if (shmop_read($this->internalSemaphoreKey, 1, 1) === 1) {
            return;
        }

        $serialized_IPC_array = serialize($this->internalIPCArray);
        $shm_bytes_written = shmop_write($this->internalIPCKey, $serialized_IPC_array, 0);

        if ($shm_bytes_written !== strlen($serialized_IPC_array)) {
            throw new Exception(
                'Fatal exception writing SHM segment (shmop_write)'.strlen($serialized_IPC_array).
                '-'.shmop_size($this->internalIPCKey)
            );
        }
    }
940366
public static void writeToMemory(byte[] src, Object target, long targetOffset) {
    Platform.copyMemory(src, Platform.BYTE_ARRAY_OFFSET, target, targetOffset, src.length);
  }
554541
public static void writeProcessorOutputToValues(
            final Object output,
            final Processor<?, ?> processor,
            final Values values) {
        Map<String, String> mapper = processor.getOutputMapperBiMap();
        if (mapper == null) {
            mapper = Collections.emptyMap();
        }

        final Collection<Field> fields = getAllAttributes(output.getClass());
        for (Field field: fields) {
            String name = getOutputValueName(processor.getOutputPrefix(), mapper, field);
            try {
                final Object value = field.get(output);
                if (value != null) {
                    values.put(name, value);
                } else {
                    values.remove(name);
                }
            } catch (IllegalAccessException e) {
                throw ExceptionUtils.getRuntimeException(e);
            }
        }
    }
1219142
def write_segment(self, objects):
        
        segment = TdmsSegment(objects)
        segment.write(self._file)
101493
@Override
  @InService(TableWriterService.class)
  public Page writeCheckpoint(TableKelp table,
                              OutSegment sOut,
                              long oldSequence,
                              int saveLength,
                              int saveTail,
                              int saveSequence)
    throws IOException
  {
    BlockLeaf []blocks = _blocks;
    
    int size = BLOCK_SIZE * blocks.length;
    
    WriteStream os = sOut.out();
    
    int available = sOut.getAvailable();
    
    if (available < os.position() + size) {
      return null;
    }
    
    long newSequence = sOut.getSequence();
    
    if (newSequence < oldSequence) {
      return null;
    }
    
    compareAndSetSequence(oldSequence, newSequence);

    PageLeafStub stub = _stub;
    // System.out.println("WRC: " + this + " " + stub);
    Type type;

    if (saveLength > 0
        && oldSequence == newSequence
        && stub != null 
        && stub.allowDelta()) {
      int offset = (int) os.position();
      
      type = writeDelta(table, sOut.out(), saveLength);
      
      int length = (int) (os.position() - offset);

      stub.addDelta(table, offset, length);
    }
    else {
      // _lastSequence = newSequence;
      int offset = (int) os.position();
      
      if (sOut.isCompress()) {
        try (OutputStream zOut = sOut.outCompress()) {
          type = writeCheckpointFull(table, zOut, saveTail);
        }
      }
      else {
        type = writeCheckpointFull(table, sOut.out(), saveTail);
      }
      
      int length = (int) (os.position() - offset);
      
      // create stub to the newly written data, allowing this memory to be
      // garbage collected
      stub = new PageLeafStub(getId(), getNextId(), 
                              sOut.getSegment(),
                              offset, length);
      
      stub.setLeafRef(this);
      
      _stub = stub;
    }
    
    _writeType = type;
    
    return this;
  }
747630
public void process(GrayF32 intensityImage, @Nullable QueueCorner localMin, @Nullable QueueCorner localMax) {

		if( localMin != null )
			localMin.reset();
		if( localMax != null )
			localMax.reset();

		// the defines the region that can be processed
		int endX = intensityImage.width - border;
		int endY = intensityImage.height - border;

		int step = configuration.radius+1;

		search.initialize(configuration,intensityImage,localMin,localMax);

		for(int y = border; y < endY; y += step ) {
			int y1 = y + step;
			if( y1 > endY) y1 = endY;

			for(int x = border; x < endX; x += step ) {
				int x1 = x + step;
				if( x1 > endX) x1 = endX;
				search.searchBlock(x,y,x1,y1);
			}
		}
	}