/** * Build put list for inserting only the specified indices of the row * * @param tableId * @param row * @param indices * @return The list of put mutations */ public List<Put> insertIndices(long tableId, final Row row, final Collection<IndexSchema> indices) { checkNotNull(row); final byte[] serializedRow = row.serialize(); final ImmutableList.Builder<Put> puts = ImmutableList.builder(); doToIndices(tableId, row, indices, new IndexAction() { @Override public void execute(IndexRowKeyBuilder builder) { puts.add(emptyQualifierPut(builder.withSortOrder(SortOrder.Ascending).build(), serializedRow)); puts.add(emptyQualifierPut(builder.withSortOrder(SortOrder.Descending).build(), serializedRow)); } }); return puts.build(); }
public static byte[] updateSerializedSchema(byte[] row) { byte version = row[0]; if (isMostRecentVersion(version)) { return row; } // Bring the row up to most recent version return Row.deserialize(row).serialize(); }
public byte[] getRow(byte[] uuid) { checkTableOpen(); checkNotNull(uuid, "Get row cannot have a null UUID."); return table.getRow(Util.bytesToUUID(uuid)).serialize(); }
/** * Build put list for a row insert with specified indices * * @param tableId * @param row * @param indices * @return The list of put mutations */ public List<Put> insert(long tableId, final Row row, final Collection<IndexSchema> indices) { checkNotNull(row); // tableId, indices checked by called methods final byte[] serializedRow = row.serialize(); final UUID uuid = row.getUUID(); final ImmutableList.Builder<Put> puts = ImmutableList.builder(); puts.add(emptyQualifierPut(new DataRowKey(tableId, uuid), serializedRow)); puts.addAll(insertIndices(tableId, row, indices)); return puts.build(); }
/** * Test that row serialization and deserialization is isomorphic in the * serialization direction. * * @throws Exception */ @Test public void testSerDe() throws Exception { TableSchema schema = new TableSchemaGenerator().next(); for (Row row : Iterables.toIterable(new RowGenerator(schema))) { Assert.assertEquals(row, Row.deserialize(row.serialize())); } } }