@Override public List<Short> check(Environment env, Mutation mutation) { List<ColumnUpdate> updates = mutation.getUpdates(); HashSet<String> ok = null; if (updates.size() > 1) ok = new HashSet<String>(); VisibilityEvaluator ve = null; for (ColumnUpdate update : updates) { byte[] cv = update.getColumnVisibility(); if (cv.length > 0) { String key = null; if (ok != null && ok.contains(key = new String(cv, UTF_8))) continue; try { if (ve == null) ve = new VisibilityEvaluator(env); if (!ve.evaluate(new ColumnVisibility(cv))) return Collections.singletonList(Short.valueOf((short) 2)); } catch (BadArgumentException bae) { return Collections.singletonList(new Short((short) 1)); } catch (VisibilityParseException e) { return Collections.singletonList(new Short((short) 1)); } if (ok != null) ok.add(key); } } return null; }
private int printMutation(Text table, Mutation m) { if (log.isTraceEnabled()) { log.trace(String.format("Table %s row key: %s", table, hexDump(m.getRow()))); for (ColumnUpdate cu : m.getUpdates()) { log.trace( String.format( "Table %s column: %s:%s", table, hexDump(cu.getColumnFamily()), hexDump(cu.getColumnQualifier()))); log.trace( String.format( "Table %s security: %s", table, new ColumnVisibility(cu.getColumnVisibility()).toString())); log.trace(String.format("Table %s value: %s", table, hexDump(cu.getValue()))); } } return m.getUpdates().size(); }
@Override public void addMutation(Mutation m) throws MutationsRejectedException { List<ColumnUpdate> updates = m.getUpdates(); for (ColumnUpdate cu : updates) { Key key = new Key( m.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(), cu.getColumnVisibility(), 42, false, false); Value val = new Value(cu.getValue(), false); try { writer.append(key, val); } catch (IOException e) { throw new RuntimeException(e); } } }