private void readTid(@NotNull WireIn metaDataWire) {
   ValueIn valueIn = metaDataWire.readEventName(eventName);
   if (CoreFields.tid.contentEquals(eventName)) {
     tid = valueIn.int64();
     eventName.setLength(0);
   } else tid = -1;
 }
  /** peeks the csp or if it has a cid converts the cid into a Csp and returns that */
  private void readCsp(@NotNull final WireIn wireIn) {
    final StringBuilder keyName = Wires.acquireStringBuilder();

    cspText.setLength(0);
    final ValueIn read = wireIn.readEventName(keyName);
    if (csp.contentEquals(keyName)) {
      read.textTo(cspText);

    } else if (cid.contentEquals(keyName)) {
      final long cid = read.int64();
      final CharSequence s = mapWireHandler.getCspForCid(cid);
      cspText.append(s);
    }
  }
        @Override
        public void readMarshallable(WireIn wire) throws IllegalStateException {
          @SuppressWarnings("ConstantConditions")
          final Bytes<?> outBytes = outWire.bytes();

          try {

            final StringBuilder eventName = Wires.acquireStringBuilder();
            @SuppressWarnings("ConstantConditions")
            final ValueIn valueIn = inWire.readEventName(eventName);

            outWire.writeDocument(
                true, w -> w.writeEventName(CoreFields.tid).int64(CollectionWireHandler.this.tid));

            outWire.writeDocument(
                false,
                out -> {

                  // note :  remove on the key-set returns a boolean and on the map returns the
                  // old value
                  if (EventId.remove.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.remove(fromWire.apply(valueIn)));
                    return;
                  }

                  // note :  remove on the key-set returns a boolean and on the map returns the
                  // old value
                  if (EventId.iterator.contentEquals(eventName)) {
                    final ValueOut valueOut = out.writeEventName(CoreFields.reply);
                    valueOut.sequence(v -> underlyingCollection.forEach(e -> toWire.accept(v, e)));
                    return;
                  }

                  if (EventId.numberOfSegments.contentEquals(eventName)) {
                    outWire.write(CoreFields.reply).int32(1);
                    return;
                  }

                  if (EventId.isEmpty.contentEquals(eventName)) {
                    outWire.write(CoreFields.reply).bool(underlyingCollection.isEmpty());
                    return;
                  }

                  if (EventId.size.contentEquals(eventName)) {
                    outWire.write(CoreFields.reply).int32(underlyingCollection.size());
                    return;
                  }

                  if (EventId.clear.contentEquals(eventName)) {
                    underlyingCollection.clear();
                    return;
                  }

                  if (EventId.contains.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.contains(fromWire.apply(valueIn)));
                    return;
                  }

                  if (EventId.add.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.add(fromWire.apply(valueIn)));
                    return;
                  }

                  if (EventId.remove.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.remove(fromWire.apply(valueIn)));
                    return;
                  }

                  if (EventId.containsAll.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.remove(collectionFromWire()));
                    return;
                  }

                  if (EventId.addAll.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.addAll(collectionFromWire()));
                    return;
                  }

                  if (EventId.removeAll.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.removeAll(collectionFromWire()));
                    return;
                  }

                  if (EventId.retainAll.contentEquals(eventName)) {
                    outWire
                        .write(CoreFields.reply)
                        .bool(underlyingCollection.retainAll(collectionFromWire()));
                    return;
                  }

                  throw new IllegalStateException("unsupported event=" + eventName);
                });
          } catch (Exception e) {
            LOG.error("", e);
          } finally {

            if (YamlLogging.showServerWrites) {
              long len = outBytes.writePosition();
              if (len >= SIZE_OF_SIZE) {
                String s = Wires.fromSizePrefixedBlobs(outBytes);

                LOG.info("server writes:\n\n" + s);
              }
            }
          }
        }