columnValue.setFamily(family) .setQualifier(CellUtil.cloneQualifier(cell)) .setType(cell.getType().getCode()) .setTimestamp(cell.getTimestamp()) .setValue(CellUtil.cloneValue(cell));
@Test public void testGetType() throws IOException { Cell c = Mockito.mock(Cell.class); Mockito.when(c.getType()).thenCallRealMethod(); for (Cell.Type type : Cell.Type.values()) { Mockito.when(c.getTypeByte()).thenReturn(type.getCode()); assertEquals(type, c.getType()); } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Maximum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Minimum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } }
@Test public void testGetType() throws IOException { Cell c = Mockito.mock(Cell.class); Mockito.when(c.getType()).thenCallRealMethod(); for (Cell.Type type : Cell.Type.values()) { Mockito.when(c.getTypeByte()).thenReturn(type.getCode()); assertEquals(type, c.getType()); } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Maximum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Minimum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } }
public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }
@Test public void testGetType() throws IOException { Cell c = Mockito.mock(Cell.class); Mockito.when(c.getType()).thenCallRealMethod(); for (Cell.Type type : Cell.Type.values()) { Mockito.when(c.getTypeByte()).thenReturn(type.getCode()); assertEquals(type, c.getType()); } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Maximum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } try { Mockito.when(c.getTypeByte()).thenReturn(KeyValue.Type.Minimum.getCode()); c.getType(); fail("The code of Maximum can't be handled by Cell.Type"); } catch(UnsupportedOperationException e) { } }
@Override public byte getTypeByte() { return type.getCode(); }
public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }
col.setTimestamp(kv.getTimestamp()); col.setValue(CellUtil.cloneValue(kv)); col.setType(kv.getType().getCode()); if (kv.getTagsLength() > 0) { col.setTags(PrivateCellUtil.cloneTags(kv));
columnValue.setFamily(family) .setQualifier(CellUtil.cloneQualifier(cell)) .setType(cell.getType().getCode()) .setTimestamp(cell.getTimestamp()) .setValue(CellUtil.cloneValue(cell));
@Override public byte getTypeByte() { return type.getCode(); }
private Cell newCellWithDifferentColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF2_BYTES, 0, CF2_BYTES.length).setQualifier(CellUtil.cloneQualifier(cell)) .setTimestamp(cell.getTimestamp()).setType(cell.getType().getCode()) .setValue(CellUtil.cloneValue(cell)).build(); }
private Cell newCellWithNotExistColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF_NOT_EXIST_BYTES, 0, CF_NOT_EXIST_BYTES.length) .setQualifier(CellUtil.cloneQualifier(cell)).setTimestamp(cell.getTimestamp()) .setType(cell.getType().getCode()).setValue(CellUtil.cloneValue(cell)).build(); }