/* * 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; }
/* * Go through each sub column if it exists then as it to resolve itself if the * column does not exist then create it. */ public boolean putColumn(IColumn column) { if (!(column instanceof SuperColumn)) throw new UnsupportedOperationException("Only Super column objects should be put here"); if (!name_.equals(column.name())) throw new IllegalArgumentException( "The name should match the name of the current column or super column"); Collection<IColumn> columns = column.getSubColumns(); for (IColumn subColumn : columns) { IColumn columnInternal = columns_.get(subColumn.name()); if (columnInternal == null) { addColumn(subColumn.name(), subColumn); } else { columnInternal.putColumn(subColumn); } } return false; }