{
Term k = entry.left.prepare(keySpec);
Term v = entry.right.prepare(valueSpec);
if (k instanceof Term.NonTerminal || v instanceof Term.NonTerminal)
throw new InvalidRequestException(String.format("Invalid map literal for %s: bind variables are not supported inside collection literals", receiver));
// We don't support values > 64K because the serialization format encode the length as an unsigned short.
ByteBuffer keyBytes = ((Constants.Value)k).bytes;
if (keyBytes == null)
throw new InvalidRequestException("null is not supported inside collections");
if (keyBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
throw new InvalidRequestException(String.format("Map key is too long. Map keys are limited to %d bytes but %d bytes keys provided",
FBUtilities.MAX_UNSIGNED_SHORT,
keyBytes.remaining()));
ByteBuffer valueBytes = ((Constants.Value)v).bytes;
if (valueBytes == null)
throw new InvalidRequestException("null is not supported inside collections");
if (valueBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
throw new InvalidRequestException(String.format("Map value is too long. Map values are limited to %d bytes but %d bytes value provided",
FBUtilities.MAX_UNSIGNED_SHORT,
valueBytes.remaining()));
if (values.put(keyBytes, valueBytes) != null)
throw new InvalidRequestException(String.format("Invalid map literal: duplicate entry for key %s", entry.left));
}
return new Value(values);
}