/** * build rowkey from InternalLog object * @param log internal log entity to write * @return the rowkey of the entity */ public static byte[] buildRowkey(InternalLog log) { final String[] partitions = log.getPartitions(); final Map<String, String> tags = log.getTags(); final SortedMap<Integer, Integer> tagHashMap = generateSortedTagMap(partitions, tags); // reverse timestamp long ts = Long.MAX_VALUE - log.getTimestamp(); List<Integer> partitionHashValues = new ArrayList<Integer>(); if (partitions != null) { for (String partition : partitions) { final String tagValue = tags.get(partition); if (tagValue != null) { partitionHashValues.add(tagValue.hashCode()); } else { partitionHashValues.add(EMPTY_PARTITION_DEFAULT_HASH_CODE); } } } return buildRowkey(log.getPrefix().hashCode(), partitionHashValues, ts, tagHashMap); }
/** * build rowkey from InternalLog object * * @param log internal log entity to write * @return the rowkey of the entity */ public static byte[] buildRowkey(InternalLog log) { final String[] partitions = log.getPartitions(); final Map<String, String> tags = log.getTags(); final SortedMap<Integer, Integer> tagHashMap = generateSortedTagMap(partitions, tags); // reverse timestamp long ts = Long.MAX_VALUE - log.getTimestamp(); List<Integer> partitionHashValues = new ArrayList<Integer>(); if (partitions != null) { for (String partition : partitions) { final String tagValue = tags.get(partition); if (tagValue != null) { partitionHashValues.add(tagValue.hashCode()); } else { partitionHashValues.add(EMPTY_PARTITION_DEFAULT_HASH_CODE); } } } return buildRowkey(log.getPrefix().hashCode(), partitionHashValues, ts, tagHashMap); }
TaggedLogAPIEntity entity = entityFactory.create(); entity.setTags(log.getTags()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix());
TaggedLogAPIEntity entity = entityFactory.create(); entity.setTags(log.getTags()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix());
public List<TaggedLogAPIEntity> read(List<String> rowkeys) throws IOException { HBaseLogByRowkeyReader reader = new HBaseLogByRowkeyReader(this.table, this.columnFamily, outputAll, outputColumns); List<TaggedLogAPIEntity> entities = new ArrayList<TaggedLogAPIEntity>(); try { reader.open(); for (String rowkeyString : rowkeys) { byte[] rowkey = EagleBase64Wrapper.decode(rowkeyString); InternalLog log = reader.get(rowkey); TaggedLogAPIEntity entity = entityFactory.create(); entities.add(entity); entity.setTags(log.getTags()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix()); Map<String, byte[]> qualifierValues = log.getQualifierValues(); mapper.populateQualifierValues(entity, qualifierValues); } } catch (IOException ex) { LOG.error("Fail read by rowkey", ex); throw ex; } finally { reader.close(); } return entities; } }
public List<TaggedLogAPIEntity> read(List<String> rowkeys) throws IOException{ HBaseLogByRowkeyReader reader = new HBaseLogByRowkeyReader(this.table, this.columnFamily, outputAll, outputColumns); List<TaggedLogAPIEntity> entities = new ArrayList<TaggedLogAPIEntity>(); try{ reader.open(); for(String rowkeyString : rowkeys){ byte[] rowkey = EagleBase64Wrapper.decode(rowkeyString); InternalLog log = reader.get(rowkey); TaggedLogAPIEntity entity = entityFactory.create(); entities.add(entity); entity.setTags(log.getTags()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix()); Map<String, byte[]> qualifierValues = log.getQualifierValues(); mapper.populateQualifierValues(entity, qualifierValues); } }catch(IOException ex){ LOG.error("Fail read by rowkey", ex); throw ex; }finally{ reader.close(); } return entities; } }
public static TaggedLogAPIEntity buildEntity(InternalLog log, EntityDefinition entityDef) throws Exception { Map<String, byte[]> qualifierValues = log.getQualifierValues(); TaggedLogAPIEntity entity = ENTITY_SERDESER.readValue(qualifierValues, entityDef); if (entity.getTags() == null && log.getTags() != null) { entity.setTags(log.getTags()); } entity.setExp(log.getExtraValues()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix()); return entity; }
public static TaggedLogAPIEntity buildEntity(InternalLog log, EntityDefinition entityDef) throws Exception { Map<String, byte[]> qualifierValues = log.getQualifierValues(); TaggedLogAPIEntity entity = ENTITY_SERDESER.readValue(qualifierValues, entityDef); if (entity.getTags() == null && log.getTags() != null) { entity.setTags(log.getTags()); } entity.setExp(log.getExtraValues()); entity.setTimestamp(log.getTimestamp()); entity.setEncodedRowkey(log.getEncodedRowkey()); entity.setPrefix(log.getPrefix()); return entity; }