/** * HBaseの一行をItemDataに変換 * * @param r row in HBase * @return 商品情報 */ public ItemData toDataStore(Result r) { if (r == null || r.isEmpty()) { return null; } ItemData item = null; // meta family NavigableMap<byte[], byte[]> map = r.getFamilyMap(META_FAMILY); if (map != null && !map.isEmpty()) { item = new ItemData(); // ctime byte[] bCtime = map.get(Bytes.toBytes("ctime")); if (bCtime != null) { item.ctime = Bytes.toLong(bCtime); } } // data family map = r.getFamilyMap(DATA_FAMILY); if (map != null && !map.isEmpty()) { if (item == null) { item = new ItemData(); } // shop ID byte[] bShopID = map.get(Bytes.toBytes("shop_id")); if (bShopID != null) { item.shopID = Bytes.toInt(bShopID); } // item ID byte[] bItemID = map.get(Bytes.toBytes("item_id")); if (bItemID != null) { item.itemID = Bytes.toInt(bItemID); } // genre ID byte[] bGenreID = map.get(Bytes.toBytes("genre_id")); if (bGenreID != null) { item.genreID = Bytes.toInt(bGenreID); } // item name byte[] bItemName = map.get(Bytes.toBytes("item_name")); if (bItemName != null) { item.itemName = Bytes.toString(bItemName); } // full item url byte[] bFullItemUrl = map.get(Bytes.toBytes("full_item_url")); if (bFullItemUrl != null) { item.fullItemUrl = Bytes.toString(bFullItemUrl); } // price byte[] bPrice = map.get(Bytes.toBytes("price")); if (bPrice != null) { item.price = Bytes.toString(bPrice); } } if (item == null) { item = new ItemData(); } item.rowkey = r.getRow(); return item; }