@Test public void primaryKey() throws Exception { for (Aggregation aggregation : aggregations) { byte[] bytes = mapper.writeValueAsBytes(aggregation); Item item = itemMapper.fromByteBuffer(ByteBuffer.wrap(bytes)); assertEquals(itemMapper.primaryKey(item), itemMapper.key(ByteBuffer.wrap(bytes))); } }
public PrimaryKey primaryKey(Item item) { long campaignItemId = item.getLong(CAMPAIGN_TABLE_HASH_KEY); long period = item.getLong(PERIOD_TABLE_RANGE_KEY); return new PrimaryKey(CAMPAIGN_TABLE_HASH_KEY, campaignItemId, PERIOD_TABLE_RANGE_KEY, period); }
ItemMapper { public PrimaryKey primaryKey(Item item) { long campaignItemId = item.getLong(CAMPAIGN_TABLE_HASH_KEY); long period = item.getLong(PERIOD_TABLE_RANGE_KEY); return new PrimaryKey(CAMPAIGN_TABLE_HASH_KEY, campaignItemId, PERIOD_TABLE_RANGE_KEY, period); } }
ItemMapper { public PrimaryKey primaryKey(Item item) { long campaignItemId = item.getLong(CAMPAIGN_TABLE_HASH_KEY); long period = item.getLong(PERIOD_TABLE_RANGE_KEY); return new PrimaryKey(CAMPAIGN_TABLE_HASH_KEY, campaignItemId, PERIOD_TABLE_RANGE_KEY, period); }  }
ItemMapper { public PrimaryKey primaryKey(Item item) { long campaignItemId = item.getLong(CAMPAIGN_TABLE_HASH_KEY); long period = item.getLong(PERIOD_TABLE_RANGE_KEY); return new PrimaryKey(CAMPAIGN_TABLE_HASH_KEY, campaignItemId, PERIOD_TABLE_RANGE_KEY, period); }  PrimaryKey key(ByteBuffer byteBuffer); PrimaryKey key(JsonNode node); PrimaryKey primaryKey(Item item); Map<PrimaryKey, Item> mergeItems(List<ByteBuffer> list); List<Item> mergeItems(Collection<Item> created, Collection<Item> read); Item mergeItem(PrimaryKey primaryKey, Item newItem, Item oldItem); Object mergeValue(Object newObject, Object oldValue); Item fromByteBuffer(ByteBuffer byteBuffer); }
ItemMapper { public PrimaryKey primaryKey(Item item) { long campaignItemId = item.getLong(CAMPAIGN_TABLE_HASH_KEY); long period = item.getLong(PERIOD_TABLE_RANGE_KEY); return new PrimaryKey(CAMPAIGN_TABLE_HASH_KEY, campaignItemId, PERIOD_TABLE_RANGE_KEY, period); }  PrimaryKey key(ByteBuffer byteBuffer); PrimaryKey key(JsonNode node); PrimaryKey primaryKey(Item item); Map<PrimaryKey, Item> mergeItems(List<ByteBuffer> list); List<Item> mergeItems(Collection<Item> created, Collection<Item> read); Item mergeItem(PrimaryKey primaryKey, Item newItem, Item oldItem); Object mergeValue(Object newObject, Object oldValue); Item fromByteBuffer(ByteBuffer byteBuffer); static final String CAMPAIGN_TABLE_HASH_KEY; static final String PERIOD_TABLE_RANGE_KEY; }