@Test public void testPutCreationWithByteBuffer() { Put p = new Put(ROW); List<Cell> c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(0, c.size()); Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(1984L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2013L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2001L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2001L, c.get(0).getTimestamp());
private int getInteger(Put p, byte[] family, byte[] qualifier) { List<Cell> cells = p.get(family, qualifier); if (cells != null && cells.size() > 0) { Cell cell = cells.get(0); return (Integer)PInteger.INSTANCE.toObject(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); } return 0; }
@Test public void testTaggingAPutWrongQualifier() throws Exception { Put put = generateOriginalPut(); Cell initialCell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); // Different qualifier, so no tags should be set MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, EMPTY_BYTE_ARRAY, mockBuilder, EMPTY_BYTE_ARRAY, DUMMY_TAGS); verify(mockBuilder, never()).setTags(Mockito.any(byte[].class)); Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); assertEquals(initialCell, newCell); assertNull(TagUtil.carryForwardTags(newCell)); }
columnToBeAdded.get(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, PhoenixDatabaseMetaData.KEY_SEQ_BYTES); if (keySeqCells != null && keySeqCells.size() > 0) {
expectedKvs.addAll(allKvs); allKvs.addAll(0, p.get(family, qual)); codec.verifiers.add(new ListMatchingVerifier("cleanup state 2", expectedKvs, familyRef)); codec.verifiers.add(new ListMatchingVerifier("put state 2", allKvs, familyRef));
@Test public void testSkipTaggingAPutDueToSameCellValue() throws Exception { Put put = generateOriginalPut(); Cell initialCell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); // valueArray is set as the value stored in the cell, so we skip tagging the cell MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, QUALIFIER, mockBuilder, ORIGINAL_VALUE, DUMMY_TAGS); verify(mockBuilder, never()).setTags(Mockito.any(byte[].class)); Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); assertEquals(initialCell, newCell); assertNull(TagUtil.carryForwardTags(newCell)); }
private boolean switchAttribute(PTable table, boolean currAttribute, List<Mutation> tableMetaData, byte[] attrQualifier) { for (Mutation m : tableMetaData) { if (m instanceof Put) { Put p = (Put)m; List<Cell> cells = p.get(TABLE_FAMILY_BYTES, attrQualifier); if (cells != null && cells.size() > 0) { Cell cell = cells.get(0); boolean newAttribute = (boolean)PBoolean.INSTANCE.toObject(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); return currAttribute != newAttribute; } } } return false; }
@Test public void testPutCreationWithByteBuffer() { Put p = new Put(ROW); List<Cell> c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(0, c.size()); Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(1984L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2013L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2001L, c.get(0).getTimestamp()); c = p.get(FAMILY, QUALIFIER); Assert.assertEquals(1, c.size()); Assert.assertEquals(2001L, c.get(0).getTimestamp());
for (Cell c : put.get(FAMILY, COLUMN)) { writer.append(c);
@Test public void testMutatingAPut() throws Exception { Put put = generateOriginalPut(); byte[] newValue = Bytes.toBytes("new-value"); Cell cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); assertEquals(Bytes.toString(ORIGINAL_VALUE), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); MetaDataUtil.mutatePutValue(put, TABLE_FAMILY_BYTES, QUALIFIER, newValue); cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); assertEquals(Bytes.toString(newValue), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); }
LocalTableState table = new LocalTableState(state, m); table.addPendingUpdates(m.get(fam, qual));
LocalTableState table = new LocalTableState(env, state, m); KeyValue kv = m.get(fam, qual).get(0); kv.setMemstoreTS(0); table.addPendingUpdates(kv);
LocalTableState table = new LocalTableState(state, m); KeyValue kv = PhoenixKeyValueUtil.maybeCopyCell(m.get(fam, qual).get(0)); kv.setSequenceId(0); table.addPendingUpdates(kv);
private int getInteger(Put p, byte[] family, byte[] qualifier) { List<Cell> cells = p.get(family, qualifier); if (cells != null && cells.size() > 0) { Cell cell = cells.get(0); return (Integer)PInteger.INSTANCE.toObject(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); } return 0; }
private boolean switchAttribute(PTable table, boolean currAttribute, List<Mutation> tableMetaData, byte[] attrQualifier) { for (Mutation m : tableMetaData) { if (m instanceof Put) { Put p = (Put)m; List<Cell> cells = p.get(TABLE_FAMILY_BYTES, attrQualifier); if (cells != null && cells.size() > 0) { Cell cell = cells.get(0); boolean newAttribute = (boolean)PBoolean.INSTANCE.toObject(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); return currAttribute != newAttribute; } } } return false; }