Serialize pointer map.

@param pointer Pointer data.
@return Pointer content bytes.
15421
@NotNull
  public static byte[] serializePointer(@NotNull Map<String, String> pointer) {
    final Map<String, String> data = new TreeMap<>(pointer);
    final StringBuilder buffer = new StringBuilder();
    // Write version.
    {
      String version = data.remove(VERSION);
      if (version == null) {
        version = VERSION_URL;
      }
      buffer.append(VERSION).append(' ').append(version).append('\n');
    }
    for (Map.Entry<String, String> entry : data.entrySet()) {
      buffer.append(entry.getKey()).append(' ').append(entry.getValue()).append('\n');
    }
    return buffer.toString().getBytes(StandardCharsets.UTF_8);
  }
1302015
private static Pointer mapMemory(String mapName, int mode, int size) {
    HANDLE mapping = Kernel32.INSTANCE.OpenFileMapping(mode, false, mapName);
    Pointer v = Kernel32.INSTANCE.MapViewOfFile(mapping, mode, 0, 0, new SIZE_T(size));
    Kernel32.INSTANCE.CloseHandle(mapping);
    return v;
  }
62800
public static String serialize(Method method, Object data) throws SerializationException {

        String result = RPC.encodeResponseForSuccess(method, data, CmsPrefetchSerializationPolicy.instance());
        result = CmsEncoder.escapeXml(result, true);
        return result;
    }
410225
void map(ByteBuffer buffer) {
    if (!(reader instanceof MappedJournalSegmentReader)) {
      JournalReader<E> reader = this.reader;
      this.reader = new MappedJournalSegmentReader<>(buffer, segment, maxEntrySize, index, namespace);
      this.reader.reset(reader.getNextIndex());
      reader.close();
    }
  }
922087
@Override
    public void write(ByteBuffer buffer) {
//        if (obj instanceof Persistable)
//            ((Persistable) obj).write(buffer);
//        else {
        if (obj != null)
            buffer.put(getSerialized());
        tmpBuffer = null;
//        }
    }
348266
@Override
    public void memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer) {
        this.memoryHandler.memcpy(dstBuffer, srcBuffer);
    }
1140455
private void _serializeMap(PageContext pc, Set test, Map map, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
	sb.append(goIn());
	sb.append("{");

	Iterator it = map.keySet().iterator();
	boolean doIt = false;
	while (it.hasNext()) {
	    Object key = it.next();
	    if (doIt) sb.append(',');
	    doIt = true;
	    sb.append(StringUtil.escapeJS(key.toString(), '"', charsetEncoder));
	    sb.append(':');
	    _serialize(pc, test, map.get(key), sb, serializeQueryByColumns, done);
	}

	sb.append('}');
    }
33692
Map<String, Object> serialize() {

		final Map<String, Object> serializedForm       = new TreeMap<>();
		final Map<String, Object> serializedProperties = new TreeMap<>();
		final Map<String, Object> serializedMethods    = new TreeMap<>();

		// populate properties
		for (final StructrPropertyDefinition property : properties) {
			serializedProperties.put(property.getName(), property.serialize());
		}

		// populate methods
		for (final StructrMethodDefinition method : methods) {

			final String name = method.getName();

			if (serializedMethods.containsKey(name)) {

				// Name is already present in the map, so there are at least
				// two method with the same name.
				final Object currentValue = serializedMethods.get(name);
				if (currentValue instanceof Collection) {

					// add serialized method to collection
					final Collection collection = (Collection)currentValue;

					collection.add(method.serialize());

				} else if (currentValue instanceof Map) {

					// remove map, add collection, add
					// map to collection
					final Map<String, Object> otherMethod   = (Map<String, Object>)serializedMethods.get(name);
					final Map<String, Object> currentMethod = method.serialize();
					final List<Map<String, Object>> list    = new LinkedList<>();

					list.add(otherMethod);
					list.add(currentMethod);

					serializedMethods.put(name, list);

				} else {

					logger.warn("Invalid storage datastructure for methods: {}", currentValue.getClass().getName());
				}

			} else {

				serializedMethods.put(method.getName(), method.serialize());
			}
		}

		serializedForm.put(JsonSchema.KEY_TYPE, "object");
		serializedForm.put(JsonSchema.KEY_IS_ABSTRACT, isAbstract);
		serializedForm.put(JsonSchema.KEY_IS_INTERFACE, isInterface);
		if (getClass().equals(StructrNodeTypeDefinition.class)) {
			serializedForm.put(JsonSchema.KEY_IS_BUILTIN_TYPE, isBuiltinType);
		}

		// properties
		if (!serializedProperties.isEmpty()) {
			serializedForm.put(JsonSchema.KEY_PROPERTIES, serializedProperties);
		}

		// required
		final Set<String> requiredProperties = getRequiredProperties();
		if (!requiredProperties.isEmpty()) {
			serializedForm.put(JsonSchema.KEY_REQUIRED, requiredProperties);
		}

		// views
		if (!views.isEmpty()) {

			// FIXME: views are different

			serializedForm.put(JsonSchema.KEY_VIEWS, views);
			serializedForm.put(JsonSchema.KEY_VIEW_ORDER, viewOrder);
		}

		// methods
		if (!serializedMethods.isEmpty()) {
			serializedForm.put(JsonSchema.KEY_METHODS, serializedMethods);
		}

		final URI ext = getExtends();
		if (ext != null) {

			serializedForm.put(JsonSchema.KEY_EXTENDS, root.toJsonPointer(ext));
		}

		if (!implementedInterfaces.isEmpty()) {

			final Set<String> interfaces = new TreeSet<>();

			for (final URI uri : implementedInterfaces) {
				interfaces.add(root.toJsonPointer(uri));
			}

			if (!interfaces.isEmpty()) {
				serializedForm.put(JsonSchema.KEY_IMPLEMENTS, interfaces);
			}
		}

		if (StringUtils.isNotBlank(category)) {
			serializedForm.put(JsonSchema.KEY_CATEGORY, category);
		}

		return serializedForm;
	}
213136
static byte[] serializeChunk(SegmentChunk segmentChunk) {
        return combine(Long.toString(segmentChunk.getStartOffset()), segmentChunk.getName());
    }
702898
final ByteBuffer copyPointer(int index) {
    ByteBuffer pointer = readPointer(index);
    // Making a copy for so that someone can modify the underlying impl
    ByteBuffer result = ByteBuffer.allocate(pointer.capacity());
    result.put(pointer);
    result.flip();
    return result;
  }
1114749
protected String serializeFromMap(@Nullable String user, long start, long duration, @Nullable List<String> roles, Map<String, Object> nameAndValMap) {
		return serializeFromMap(user, start, duration, toArr(roles), nameAndValMap);
	}
445298
public static String serialize(Object data) {
        String ret=null;

        if (data != null) {
            if (data.getClass() == String.class) {
                ret = (String)data;
            } else if (data instanceof byte[]) {
                ret = new String((byte[])data);
            } else {
                try {
                    ret = mapper.writeValueAsString(data);
                } catch (JsonProcessingException e) {
                    if (log.isLoggable(Level.FINEST)) {
                        log.log(Level.FINEST, "Failed to serialize object into json", e);
                    }
                }
            }
        }
390421
public void str(Pointer ptr, IoStrRead read) {
        str(ptr, ptr.buffer.length - ptr.start, read);
    }
181550
@Nullable
  public static Map<String, String> parsePointer(@NotNull byte[] blob) {
    return parsePointer(blob, 0, blob.length);
  }
1277707
public ByteBuffer serializeToByteBuffer() throws IOException {
    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
    final Encoder encoder = EncoderFactory.get().binaryEncoder(stream, null);
    final DatumWriter writer = new GenericDatumWriter<GenericRecord>();
    writer.setSchema(createAvroSchema());
    final AvroParquetReader<GenericRecord> reader = createAvroReader();

    GenericRecord record = reader.read();
    while (record != null) {
      writer.write(record, encoder);
      record = reader.read();
    }

    try {
      reader.close();
    } catch (IOException ex){
      LOG.log(Level.SEVERE, ex.getMessage());
      throw ex;
    }

    encoder.flush();
    final ByteBuffer buf = ByteBuffer.wrap(stream.toByteArray());
    buf.order(ByteOrder.LITTLE_ENDIAN);
    return buf;
  }
410009
public <K, V> void serializeSortedMap(S rec, String fieldName, String keyTypeName, String valueTypeName, SortedMap<K, V> obj) {
        serializeMap(rec, fieldName, keyTypeName, valueTypeName, obj);
    }
250549
def serialize(point: Mapping, measurement=None, **extra_tags) -> bytes:
    """"""
    tags = _serialize_tags(point, extra_tags)
    return (
        f'{_serialize_measurement(point, measurement)}'
        f'{"," if tags else ""}{tags} '
        f'{_serialize_fields(point)} '
        f'{_serialize_timestamp(point)}'
    ).encode()