Example #1
0
 /*
  * Use this method to create a bare bones Super Column. This super column does
  * not have any of the Column information.
  */
 private SuperColumn defreezeSuperColumn(DataInputStream dis) throws IOException {
   String name = dis.readUTF();
   boolean delete = dis.readBoolean();
   SuperColumn superColumn = new SuperColumn(name);
   if (delete) superColumn.delete();
   return superColumn;
 }
Example #2
0
  /*
   * Deserialize a particular column since the name is in the form of
   * superColumn:column.
   */
  public IColumn deserialize(DataInputStream dis, String name, IFilter filter) throws IOException {
    if (dis.available() == 0) return null;

    String[] names = RowMutation.getColumnAndColumnFamily(name);
    if (names.length == 1) {
      IColumn superColumn = defreezeSuperColumn(dis);
      if (name.equals(superColumn.name())) {
        if (!superColumn.isMarkedForDelete()) {
          /* read the number of columns stored */
          int size = dis.readInt();
          /* read the size of all columns */
          dis.readInt();
          IColumn column = null;
          for (int i = 0; i < size; ++i) {
            column = Column.serializer().deserialize(dis, filter);
            if (column != null) {
              superColumn.addColumn(column.name(), column);
              column = null;
              if (filter.isDone()) {
                break;
              }
            }
          }
        }
        return superColumn;
      } else {
        /* read the number of columns stored */
        dis.readInt();
        /* read the size of all columns to skip */
        int size = dis.readInt();
        dis.skip(size);
        return null;
      }
    }

    SuperColumn superColumn = defreezeSuperColumn(dis);
    if (!superColumn.isMarkedForDelete()) {
      int size = dis.readInt();
      /* skip the size of the columns */
      dis.readInt();
      if (size > 0) {
        for (int i = 0; i < size; ++i) {
          IColumn subColumn = Column.serializer().deserialize(dis, names[1], filter);
          if (subColumn != null) {
            superColumn.addColumn(subColumn.name(), subColumn);
            break;
          }
        }
      }
    }
    return superColumn;
  }
Example #3
0
  public void serialize(IColumn column, DataOutputStream dos) throws IOException {
    SuperColumn superColumn = (SuperColumn) column;
    dos.writeUTF(superColumn.name());
    dos.writeBoolean(superColumn.isMarkedForDelete());

    Collection<IColumn> columns = column.getSubColumns();
    int size = columns.size();
    dos.writeInt(size);

    /*
     * Add the total size of the columns. This is useful to skip over all the
     * columns in this super column if we are not interested in this super
     * column.
     */
    dos.writeInt(superColumn.getSizeOfAllColumns());
    // dos.writeInt(superColumn.size());

    for (IColumn subColumn : columns) {
      Column.serializer().serialize(subColumn, dos);
    }
  }
Example #4
0
 public IColumn deserialize(DataInputStream dis) throws IOException {
   SuperColumn superColumn = defreezeSuperColumn(dis);
   if (!superColumn.isMarkedForDelete()) fillSuperColumn(superColumn, dis);
   return superColumn;
 }