code: public boolean hasLegacyShards(ByteBuffer context)
      {
          int totalCount = (context.remaining() - headerLength(context)) / STEP_LENGTH;
          int localAndGlobalCount = Math.abs(context.getShort(context.position()));
  
          if (localAndGlobalCount < totalCount)
              return true; // remote shard(s) present
  
          for (int i = 0; i < localAndGlobalCount; i++)
              if (context.getShort(context.position() + HEADER_SIZE_LENGTH + i * HEADER_ELT_LENGTH) >= 0)
                  return true; // found a local shard
  
          return false;
      }
docs: Detects whether or not the context has any legacy (local or remote) shards in it.