@Override public Map<RowColumn, Bytes> get(Collection<RowColumn> rowColumns) { checkIfOpen(); if (rowColumns.size() == 0) { return Collections.emptyMap(); } ParallelSnapshotScanner pss = new ParallelSnapshotScanner(rowColumns, env, startTs, stats, readLocksSeen); Map<Bytes, Map<Column, Bytes>> scan = pss.scan(); Map<RowColumn, Bytes> ret = new HashMap<>(); for (Entry<Bytes, Map<Column, Bytes>> entry : scan.entrySet()) { updateColumnsRead(entry.getKey(), entry.getValue().keySet()); for (Entry<Column, Bytes> colVal : entry.getValue().entrySet()) { ret.put(new RowColumn(entry.getKey(), colVal.getKey()), colVal.getValue()); } } return ret; }
private void scan(Map<Bytes, Map<Column, Bytes>> ret, List<Entry<Key, Value>> locks) { BatchScanner bs = setupBatchScanner(); try { for (Entry<Key, Value> entry : bs) { Bytes row = rowConverter.apply(entry.getKey().getRowData()); Column col = columnConverter.apply(entry.getKey()); long colType = entry.getKey().getTimestamp() & ColumnConstants.PREFIX_MASK; if (colType == ColumnConstants.LOCK_PREFIX) { locks.add(entry); } else if (colType == ColumnConstants.DATA_PREFIX) { ret.computeIfAbsent(row, k -> new HashMap<>()).put(col, Bytes.of(entry.getValue().get())); } else if (colType == ColumnConstants.RLOCK_PREFIX) { readLocksSeen.computeIfAbsent(row, k -> new HashSet<>()).add(col); } else { throw new IllegalArgumentException("Unexpected column type " + colType); } } } finally { bs.close(); } } }
List<Entry<Key, Value>> locks = new ArrayList<>(); scan(ret, locks);
private void scan(Map<Bytes, Map<Column, Bytes>> ret, List<Entry<Key, Value>> locks) { BatchScanner bs = setupBatchScanner(); try { for (Entry<Key, Value> entry : bs) { Bytes row = rowConverter.apply(entry.getKey().getRowData()); Column col = columnConverter.apply(entry.getKey()); ColumnType colType = ColumnType.from(entry.getKey()); switch (colType) { case LOCK: locks.add(entry); break; case DATA: ret.computeIfAbsent(row, k -> new HashMap<>()).put(col, Bytes.of(entry.getValue().get())); break; case RLOCK: readLocksSeen.computeIfAbsent(row, k -> new HashSet<>()).add(col); break; default: throw new IllegalArgumentException("Unexpected column type " + colType); } } } finally { bs.close(); } } }
List<Entry<Key, Value>> locks = new ArrayList<>(); scan(ret, locks);
@Override public Map<RowColumn, Bytes> get(Collection<RowColumn> rowColumns) { checkIfOpen(); if (rowColumns.isEmpty()) { return Collections.emptyMap(); } ParallelSnapshotScanner pss = new ParallelSnapshotScanner(rowColumns, env, startTs, stats, readLocksSeen); Map<Bytes, Map<Column, Bytes>> scan = pss.scan(); Map<RowColumn, Bytes> ret = new HashMap<>(); for (Entry<Bytes, Map<Column, Bytes>> entry : scan.entrySet()) { updateColumnsRead(entry.getKey(), entry.getValue().keySet()); for (Entry<Column, Bytes> colVal : entry.getValue().entrySet()) { ret.put(new RowColumn(entry.getKey(), colVal.getKey()), colVal.getValue()); } } return ret; }
@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, readLocksSeen); 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 Map<Bytes, Map<Column, Bytes>> get(Collection<Bytes> rows, Set<Column> columns) { checkIfOpen(); if (rows.isEmpty() || columns.isEmpty()) { return Collections.emptyMap(); } env.getSharedResources().getVisCache().validate(columns); ParallelSnapshotScanner pss = new ParallelSnapshotScanner(rows, columns, env, startTs, stats, readLocksSeen); 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; }