private static void validateColumns( String keyspace, String columnFamilyName, ByteBuffer superColumnName, Iterable<ByteBuffer> column_names) throws InvalidRequestException { if (superColumnName != null) { if (superColumnName.remaining() > IColumn.MAX_NAME_LENGTH) throw new InvalidRequestException( "supercolumn name length must not be greater than " + IColumn.MAX_NAME_LENGTH); if (superColumnName.remaining() == 0) throw new InvalidRequestException("supercolumn name must not be empty"); if (DatabaseDescriptor.getColumnFamilyType(keyspace, columnFamilyName) == ColumnFamilyType.Standard) throw new InvalidRequestException( "supercolumn specified to ColumnFamily " + columnFamilyName + " containing normal columns"); } AbstractType comparator = ColumnFamily.getComparatorFor(keyspace, columnFamilyName, superColumnName); for (ByteBuffer name : column_names) { if (name.remaining() > IColumn.MAX_NAME_LENGTH) throw new InvalidRequestException( "column name length must not be greater than " + IColumn.MAX_NAME_LENGTH); if (name.remaining() == 0) throw new InvalidRequestException("column name must not be empty"); try { comparator.validate(name); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } } }
public List<SuperColumn> get_slice_super( String table, String key, String column_family, byte[] start, byte[] finish, boolean is_ascending, int count, int consistency_level) throws InvalidRequestException { if (logger.isDebugEnabled()) logger.debug("get_slice_super"); if (!DatabaseDescriptor.getColumnFamilyType(table, column_family).equals("Super")) throw new InvalidRequestException("get_slice_super requires a super CF name"); if (count <= 0) throw new InvalidRequestException("get_slice_super requires positive count"); ColumnFamily cfamily = readColumnFamily( new SliceFromReadCommand( table, key, new QueryPath(column_family), start, finish, is_ascending, count), consistency_level); if (cfamily == null) { return EMPTY_SUPERCOLUMNS; } Collection<IColumn> columns = cfamily.getSortedColumns(); return thriftifySuperColumns(columns, !is_ascending); }
public static ColumnFamilyType validateColumnFamily(String tablename, String cfName) throws InvalidRequestException { if (cfName.isEmpty()) { throw new InvalidRequestException("non-empty columnfamily is required"); } ColumnFamilyType cfType = DatabaseDescriptor.getColumnFamilyType(tablename, cfName); if (cfType == null) { throw new InvalidRequestException("unconfigured columnfamily " + cfName); } return cfType; }
public static void validateDeletion(String keyspace, String cfName, Deletion del) throws InvalidRequestException { validateColumnFamily(keyspace, cfName); if (del.predicate != null) { validateSlicePredicate(keyspace, cfName, del.super_column, del.predicate); if (del.predicate.slice_range != null) throw new InvalidRequestException("Deletion does not yet support SliceRange predicates."); } if (ColumnFamilyType.Standard == DatabaseDescriptor.getColumnFamilyType(keyspace, cfName) && del.super_column != null) { String msg = String.format( "deletion of super_column is not possible on a standard ColumnFamily (KeySpace=%s ColumnFamily=%s Deletion=%s)", keyspace, cfName, del); throw new InvalidRequestException(msg); } }