Exemple #1
0
  public IColumn diff(IColumn column) {
    IColumn columnDiff = new SuperColumn(column.name());
    Collection<IColumn> columns = column.getSubColumns();

    for (IColumn subColumn : columns) {
      IColumn columnInternal = columns_.get(subColumn.name());
      if (columnInternal == null) {
        columnDiff.addColumn(subColumn.name(), subColumn);
      } else {
        IColumn subColumnDiff = columnInternal.diff(subColumn);
        if (subColumnDiff != null) {
          columnDiff.addColumn(subColumn.name(), subColumnDiff);
        }
      }
    }
    if (columnDiff.getSubColumns().size() != 0) return columnDiff;
    else return null;
  }
Exemple #2
0
  private void fillSuperColumn(IColumn superColumn, DataInputStream dis) throws IOException {
    if (dis.available() == 0) return;

    /* read the number of columns */
    int size = dis.readInt();
    /* read the size of all columns */
    dis.readInt();
    for (int i = 0; i < size; ++i) {
      IColumn subColumn = Column.serializer().deserialize(dis);
      superColumn.addColumn(subColumn.name(), subColumn);
    }
  }
Exemple #3
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;
  }