/** * 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); }
public byte[] generateIndexRowkey(TaggedLogAPIEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { if (entity.getClass() != entityDef.getEntityClass()) { throw new IllegalArgumentException("Expected entity class: " + entityDef.getEntityClass().getName() + ", but got class " + entity.getClass().getName()); } final byte[][] indexValues = generateIndexValues(entity); final int[] partitionHashCodes = generatePartitionHashCodes(entity); SortedMap<Integer, Integer> tagMap = null; if (!index.unique()) { // non cluster index tagMap = RowkeyBuilder.generateSortedTagMap(entityDef.getPartitions(), entity.getTags()); } return generateUniqueIndexRowkey(indexValues, partitionHashCodes, tagMap); }
public byte[] generateIndexRowkey(TaggedLogAPIEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { if (entity.getClass() != entityDef.getEntityClass()) { throw new IllegalArgumentException("Expected entity class: " + entityDef.getEntityClass().getName() + ", but got class " + entity.getClass().getName()); } final byte[][] indexValues = generateIndexValues(entity); final int[] partitionHashCodes = generatePartitionHashCodes(entity); SortedMap<Integer, Integer> tagMap = null; if (!index.unique()) { // non cluster index tagMap = RowkeyBuilder.generateSortedTagMap(entityDef.getPartitions(), entity.getTags()); } return generateUniqueIndexRowkey(indexValues, partitionHashCodes, tagMap); }