public void validate(Set<Column> columns) { for (Column column : columns) { validate(column); } }
@Override public void setWeakNotification(Bytes row, Column col) { checkIfOpen(); Preconditions.checkNotNull(row); Preconditions.checkNotNull(col); if (!env.getWeakObservers().containsKey(col)) { throw new IllegalArgumentException("Column not configured for weak notifications " + col); } env.getSharedResources().getVisCache().validate(col); Set<Column> columns = weakNotifications.get(row); if (columns == null) { columns = new HashSet<>(); weakNotifications.put(row, columns); } columns.add(col); }
@Override public Map<Bytes, Map<Column, Bytes>> get(Collection<Bytes> rows, Set<Column> columns) { checkIfOpen(); if (rows.size() == 0 || columns.size() == 0) { return Collections.emptyMap(); } env.getSharedResources().getVisCache().validate(columns); ParallelSnapshotScanner pss = new ParallelSnapshotScanner(rows, columns, env, startTs, stats); Map<Bytes, Map<Column, Bytes>> ret = pss.scan(); for (Entry<Bytes, Map<Column, Bytes>> entry : ret.entrySet()) { updateColumnsRead(entry.getKey(), entry.getValue().keySet()); } return ret; }
@Override public void set(Bytes row, Column col, Bytes value) throws AlreadySetException { checkIfOpen(); Preconditions.checkNotNull(row); Preconditions.checkNotNull(col); Preconditions.checkNotNull(value); if (col.getFamily().equals(ColumnConstants.NOTIFY_CF)) { throw new IllegalArgumentException(ColumnConstants.NOTIFY_CF + " is a reserved family"); } env.getSharedResources().getVisCache().validate(col); // TODO copy? Map<Column, Bytes> colUpdates = updates.get(row); if (colUpdates == null) { colUpdates = new HashMap<>(); updates.put(row, colUpdates); } if (colUpdates.get(col) != null) { throw new AlreadySetException("Value already set " + row + " " + col); } colUpdates.put(col, value); }
private Map<Column, Bytes> getImpl(Bytes row, Set<Column> columns) { // TODO push visibility filtering to server side? env.getSharedResources().getVisCache().validate(columns); ScannerConfiguration config = new ScannerConfiguration(); config.setSpan(Span.exact(row)); for (Column column : columns) { config.fetchColumn(column.getFamily(), column.getQualifier()); } RowIterator iter = getImpl(config); Map<Column, Bytes> ret = new HashMap<>(); while (iter.hasNext()) { Entry<Bytes, ColumnIterator> entry = iter.next(); ColumnIterator citer = entry.getValue(); while (citer.hasNext()) { Entry<Column, Bytes> centry = citer.next(); if (columns.contains(centry.getKey())) { ret.put(centry.getKey(), centry.getValue()); } } } // only update columns read after successful read updateColumnsRead(row, columns); return ret; }