/** * Scan all cells in a row. * * @param row * the row to scan. * @param family * if not null, the family to filter and return. * @return iterator for the cells. Cells may appear in any order, including * random. Never null. */ public Iterable<Cell> scanFamily(byte[] row, ColumnMatcher family) { synchronized (lock) { Map<Key, Cell> r = map.get(new Key(row)); if (r == null) return Collections.emptyList(); if (family == null) return new ArrayList<Cell>(r.values()); ArrayList<Cell> out = new ArrayList<Cell>(4); for (Cell cell : r.values()) { if (family.sameFamily(cell.getName())) out.add(cell); } return out; } }
/** * Scan all cells in a row. * * @param row * the row to scan. * @param family * if not null, the family to filter and return. * @return iterator for the cells. Cells may appear in any order, including * random. Never null. */ public Iterable<Cell> scanFamily(byte[] row, ColumnMatcher family) { synchronized (lock) { Map<Key, Cell> r = map.get(new Key(row)); if (r == null) return Collections.emptyList(); if (family == null) return new ArrayList<Cell>(r.values()); ArrayList<Cell> out = new ArrayList<Cell>(4); for (Cell cell : r.values()) { if (family.sameFamily(cell.getName())) out.add(cell); } return out; } }
/** * Put a value into a cell. * * @param row * @param col * @param val */ public void put(byte[] row, byte[] col, byte[] val) { synchronized (lock) { Key rowKey = new Key(row); Map<Key, Cell> r = map.get(rowKey); if (r == null) { r = new HashMap<Key, Cell>(4); map.put(rowKey, r); } r.put(new Key(col), new Cell(row, col, val)); } }
/** * Put a value into a cell. * * @param row * @param col * @param val */ public void put(byte[] row, byte[] col, byte[] val) { synchronized (lock) { Key rowKey = new Key(row); Map<Key, Cell> r = map.get(rowKey); if (r == null) { r = new HashMap<Key, Cell>(4); map.put(rowKey, r); } r.put(new Key(col), new Cell(row, col, val)); } }
/** * Delete an entire row. * * @param row */ public void deleteRow(byte[] row) { synchronized (lock) { map.remove(new Key(row)); } }
/** * Delete an entire row. * * @param row */ public void deleteRow(byte[] row) { synchronized (lock) { map.remove(new Key(row)); } }