コード例 #1
0
  public Column get_column(String table, String key, ColumnPath column_path, int consistency_level)
      throws InvalidRequestException, NotFoundException {
    if (logger.isDebugEnabled()) logger.debug("get_column");
    ThriftValidation.validateColumnPath(table, column_path);

    QueryPath path = new QueryPath(column_path.column_family, column_path.super_column);
    ColumnFamily cfamily =
        readColumnFamily(
            new SliceByNamesReadCommand(table, key, path, Arrays.asList(column_path.column)),
            consistency_level);
    // TODO can we leverage getSlice here and just check that it returns one column?
    if (cfamily == null) {
      throw new NotFoundException();
    }
    Collection<IColumn> columns = null;
    if (column_path.super_column != null) {
      IColumn column = cfamily.getColumn(column_path.super_column);
      if (column != null) {
        columns = column.getSubColumns();
      }
    } else {
      columns = cfamily.getSortedColumns();
    }
    if (columns == null || columns.size() == 0) {
      throw new NotFoundException();
    }

    assert columns.size() == 1;
    IColumn column = columns.iterator().next();
    if (column.isMarkedForDelete()) {
      throw new NotFoundException();
    }

    return new Column(column.name(), column.value(), column.timestamp());
  }
コード例 #2
0
ファイル: QueryFilter.java プロジェクト: schubertzhang/dastor
 public static boolean isRelevant(IColumn column, IColumnContainer container, int gcBefore) {
   // the column itself must be not gc-able (it is live, or a still relevant tombstone, or has live
   // subcolumns), (1)
   // and if its container is deleted, the column must be changed more recently than the container
   // tombstone (2)
   // (since otherwise, the only thing repair cares about is the container tombstone)
   long maxChange = column.mostRecentLiveChangeAt();
   return (!column.isMarkedForDelete()
           || column.getLocalDeletionTime() > gcBefore
           || maxChange > column.getMarkedForDeleteAt()) // (1)
       && (!container.isMarkedForDelete() || maxChange > container.getMarkedForDeleteAt()); // (2)
 }
コード例 #3
0
ファイル: SuperColumn.java プロジェクト: jbellis/helenus
  /*
   * 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;
  }
コード例 #4
0
ファイル: SuperColumn.java プロジェクト: jbellis/helenus
  public IColumn deserialize(DataInputStream dis, IFilter filter) throws IOException {
    if (dis.available() == 0) return null;

    IColumn superColumn = defreezeSuperColumn(dis);
    superColumn = filter.filter(superColumn, dis);
    if (superColumn != null) {
      if (!superColumn.isMarkedForDelete()) fillSuperColumn(superColumn, dis);
      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;
    }
  }
コード例 #5
0
  public List<Column> thriftifyColumns(Collection<IColumn> columns, boolean reverseOrder) {
    if (columns == null || columns.isEmpty()) {
      return EMPTY_COLUMNS;
    }

    ArrayList<Column> thriftColumns = new ArrayList<Column>(columns.size());
    for (IColumn column : columns) {
      if (column.isMarkedForDelete()) {
        continue;
      }
      Column thrift_column = new Column(column.name(), column.value(), column.timestamp());
      thriftColumns.add(thrift_column);
    }

    // we have to do the reversing here, since internally we pass results around in ColumnFamily
    // objects, which always sort their columns in the "natural" order
    if (reverseOrder) Collections.reverse(thriftColumns);
    return thriftColumns;
  }
コード例 #6
0
 private static boolean isLive(ColumnFamily cf, IColumn c) {
   return c != null && !c.isMarkedForDelete() && !cf.deletionInfo().isDeleted(c);
 }