protected ColumnFamily readColumnFamily(ReadCommand command, int consistency_level) throws InvalidRequestException { String cfName = command.getColumnFamilyName(); ThriftValidation.validateKey(command.key); if (consistency_level == ConsistencyLevel.ZERO) { throw new InvalidRequestException( "Consistency level zero may not be applied to read operations"); } if (consistency_level == ConsistencyLevel.ALL) { throw new InvalidRequestException( "Consistency level all is not yet supported on read operations"); } Row row; try { row = StorageProxy.readProtocol(command, consistency_level); } catch (IOException e) { throw new RuntimeException(e); } catch (TimeoutException e) { throw new RuntimeException(e); } if (row == null) { return null; } return row.getColumnFamily(cfName); }
public void insert( String table, String key, ColumnPath column_path, byte[] value, long timestamp, int consistency_level) throws InvalidRequestException, UnavailableException { if (logger.isDebugEnabled()) logger.debug("insert"); ThriftValidation.validateKey(key); ThriftValidation.validateColumnPath(table, column_path); RowMutation rm = new RowMutation(table, key.trim()); try { rm.add(new QueryPath(column_path), value, timestamp); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } doInsert(consistency_level, rm); }