public NamesQueryFilter deserialize(DataInput in, int version) throws IOException {
   int size = in.readInt();
   SortedSet<CellName> columns = new TreeSet<CellName>(type);
   ISerializer<CellName> serializer = type.cellSerializer();
   for (int i = 0; i < size; ++i) columns.add(serializer.deserialize(in));
   boolean countCQL3Rows = in.readBoolean();
   return new NamesQueryFilter(columns, countCQL3Rows);
 }
 public long serializedSize(NamesQueryFilter f, int version) {
   TypeSizes sizes = TypeSizes.NATIVE;
   int size = sizes.sizeof(f.columns.size());
   ISerializer<CellName> serializer = type.cellSerializer();
   for (CellName cName : f.columns) size += serializer.serializedSize(cName, sizes);
   size += sizes.sizeof(f.countCQL3Rows);
   return size;
 }
 public void serialize(NamesQueryFilter f, DataOutputPlus out, int version) throws IOException {
   out.writeInt(f.columns.size());
   ISerializer<CellName> serializer = type.cellSerializer();
   for (CellName cName : f.columns) {
     serializer.serialize(cName, out);
   }
   out.writeBoolean(f.countCQL3Rows);
 }
 private V deserialize(RefCountedMemory mem) {
   try {
     return serializer.deserialize(new EncodedDataInputStream(new MemoryInputStream(mem)));
   } catch (IOException e) {
     logger.debug("Cannot fetch in memory data, we will failback to read from disk ", e);
     return null;
   }
 }
  private RefCountedMemory serialize(V value) {
    long serializedSize = serializer.serializedSize(value, ENCODED_TYPE_SIZES);
    if (serializedSize > Integer.MAX_VALUE)
      throw new IllegalArgumentException("Unable to allocate " + serializedSize + " bytes");

    RefCountedMemory freeableMemory;
    try {
      freeableMemory = new RefCountedMemory(serializedSize);
    } catch (OutOfMemoryError e) {
      return null;
    }

    try {
      serializer.serialize(
          value, new EncodedDataOutputStream(new MemoryOutputStream(freeableMemory)));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return freeableMemory;
  }