writer.write(this, value); } else { throw new IOException("can not write type [" + type + "]");
writer.write(this, value); } else { throw new IOException("can not write type [" + type + "]");
writer.write(this, value); } else { throw new IOException("can not write type [" + type + "]");
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type {@link List}s. * <pre><code> * Map<String, List<String>> map = ...; * out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMapOfLists(final Map<K, List<V>> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeMap(map, keyWriter, (stream, list) -> { writeVInt(list.size()); for (final V value : list) { valueWriter.write(this, value); } }); }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type {@link List}s. * <pre><code> * Map<String, List<String>> map = ...; * out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMapOfLists(final Map<K, List<V>> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeMap(map, keyWriter, (stream, list) -> { writeVInt(list.size()); for (final V value : list) { valueWriter.write(this, value); } }); }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type. * <pre><code> * Map<String, String> map = ...; * out.writeMap(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMap(final Map<K, V> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeVInt(map.size()); for (final Map.Entry<K, V> entry : map.entrySet()) { keyWriter.write(this, entry.getKey()); valueWriter.write(this, entry.getValue()); } }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type. * <pre><code> * Map<String, String> map = ...; * out.writeMap(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMap(final Map<K, V> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeVInt(map.size()); for (final Map.Entry<K, V> entry : map.entrySet()) { keyWriter.write(this, entry.getKey()); valueWriter.write(this, entry.getValue()); } }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type. * <pre><code> * Map<String, String> map = ...; * out.writeMap(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMap(final Map<K, V> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeVInt(map.size()); for (final Map.Entry<K, V> entry : map.entrySet()) { keyWriter.write(this, entry.getKey()); valueWriter.write(this, entry.getValue()); } }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type {@link List}s. * <pre><code> * Map<String, List<String>> map = ...; * out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMapOfLists(final Map<K, List<V>> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeMap(map, keyWriter, (stream, list) -> { writeVInt(list.size()); for (final V value : list) { valueWriter.write(this, value); } }); }
/** * Writes the specified array to the stream using the specified {@link Writer} for each element in the array. This method can be seen as * writer version of {@link StreamInput#readArray(Writeable.Reader, IntFunction)}. The length of array encoded as a variable-length * integer is first written to the stream, and then the elements of the array are written to the stream. * * @param writer the writer used to write individual elements * @param array the array * @param <T> the type of the elements of the array * @throws IOException if an I/O exception occurs while writing the array */ public <T> void writeArray(final Writer<T> writer, final T[] array) throws IOException { writeVInt(array.length); for (T value : array) { writer.write(this, value); } }
/** * Writes a collection of generic objects via a {@link Writer} */ public <T> void writeCollection(Collection<T> collection, Writer<T> writer) throws IOException { writeVInt(collection.size()); for (T val: collection) { writer.write(this, val); } }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type {@link List}s. * <pre><code> * Map<String, List<String>> map = ...; * out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMapOfLists(final Map<K, List<V>> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeMap(map, keyWriter, (stream, list) -> { writeVInt(list.size()); for (final V value : list) { valueWriter.write(this, value); } }); }
/** * Write a {@link Map} of {@code K}-type keys to {@code V}-type. * <pre><code> * Map<String, String> map = ...; * out.writeMap(map, StreamOutput::writeString, StreamOutput::writeString); * </code></pre> * * @param keyWriter The key writer * @param valueWriter The value writer */ public final <K, V> void writeMap(final Map<K, V> map, final Writer<K> keyWriter, final Writer<V> valueWriter) throws IOException { writeVInt(map.size()); for (final Map.Entry<K, V> entry : map.entrySet()) { keyWriter.write(this, entry.getKey()); valueWriter.write(this, entry.getValue()); } }
/** * Writes the specified array to the stream using the specified {@link Writer} for each element in the array. This method can be seen as * writer version of {@link StreamInput#readArray(Writeable.Reader, IntFunction)}. The length of array encoded as a variable-length * integer is first written to the stream, and then the elements of the array are written to the stream. * * @param writer the writer used to write individual elements * @param array the array * @param <T> the type of the elements of the array * @throws IOException if an I/O exception occurs while writing the array */ public <T> void writeArray(final Writer<T> writer, final T[] array) throws IOException { writeVInt(array.length); for (T value : array) { writer.write(this, value); } }
/** * Writes a collection of generic objects via a {@link Writer} */ public <T> void writeCollection(Collection<T> collection, Writer<T> writer) throws IOException { writeVInt(collection.size()); for (T val: collection) { writer.write(this, val); } }