/** * TODO need think about if multi-PUT is necessary, by checking if autoFlush works */ public List<byte[]> write(List<InternalLog> logs) throws IOException { final List<Put> puts = new ArrayList<Put>(logs.size()); final List<byte[]> result = new ArrayList<byte[]>(logs.size()); for (InternalLog log : logs) { final byte[] rowkey = RowkeyBuilder.buildRowkey(log); final Put p = new Put(rowkey); populateColumnValues(p, log); puts.add(p); final List<byte[]> indexRowkeys = log.getIndexRowkeys(); if (indexRowkeys != null) { writeIndexes(rowkey, indexRowkeys, puts); } result.add(rowkey); } tbl.put(puts); return result; }
/** * TODO need think about if multi-PUT is necessary, by checking if autoFlush works */ public List<byte[]> write(List<InternalLog> logs) throws IOException{ final List<Put> puts = new ArrayList<Put>(logs.size()); final List<byte[]> result = new ArrayList<byte[]>(logs.size()); for (InternalLog log : logs) { final byte[] rowkey = RowkeyBuilder.buildRowkey(log); final Put p = new Put(rowkey); populateColumnValues(p, log); puts.add(p); final List<byte[]> indexRowkeys = log.getIndexRowkeys(); if (indexRowkeys != null) { writeIndexes(rowkey, indexRowkeys, puts); } result.add(rowkey); } tbl.put(puts); return result; }
public static String getEncodedRowkey(AlertAPIEntity entity) throws Exception { InternalLog log = HBaseInternalLogHelper.convertToInternalLog(entity, EntityDefinitionManager.getEntityDefinitionByEntityClass(entity.getClass())); return EagleBase64Wrapper.encodeByteArray2URLSafeString(RowkeyBuilder.buildRowkey(log)); }
/** * 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 static byte[] getRowkey(InternalLog log) { byte[] rowkey = null; if (log.getEncodedRowkey() != null && !(log.getEncodedRowkey().isEmpty())) { rowkey = EagleBase64Wrapper.decode(log.getEncodedRowkey()); } else { rowkey = RowkeyBuilder.buildRowkey(log); } return rowkey; }
public static byte[] getRowkey(InternalLog log) { byte[] rowkey = null; if(log.getEncodedRowkey() != null && !(log.getEncodedRowkey().isEmpty())){ rowkey = EagleBase64Wrapper.decode(log.getEncodedRowkey()); }else{ rowkey = RowkeyBuilder.buildRowkey(log); } return rowkey; }
/** * 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); }
/** * TODO need think about if multi-PUT is necessary, by checking if autoFlush works */ @Override public byte[] write(InternalLog log) throws IOException { final byte[] rowkey = RowkeyBuilder.buildRowkey(log); final Put p = new Put(rowkey); populateColumnValues(p, log); tbl.put(p); final List<byte[]> indexRowkeys = log.getIndexRowkeys(); if (indexRowkeys != null) { writeIndexes(rowkey, indexRowkeys); } return rowkey; }
/** * TODO need think about if multi-PUT is necessary, by checking if autoFlush works */ @Override public byte[] write(InternalLog log) throws IOException{ final byte[] rowkey = RowkeyBuilder.buildRowkey(log); final Put p = new Put(rowkey); populateColumnValues(p, log); tbl.put(p); final List<byte[]> indexRowkeys = log.getIndexRowkeys(); if (indexRowkeys != null) { writeIndexes(rowkey, indexRowkeys); } return rowkey; }
public static byte[] getRowkey(TaggedLogAPIEntity entity, EntityDefinition entityDef) throws Exception { byte[] rowkey = null; if (entity.getEncodedRowkey() != null && !(entity.getEncodedRowkey().isEmpty())) { rowkey = EagleBase64Wrapper.decode(entity.getEncodedRowkey()); } else { InternalLog log = HBaseInternalLogHelper.convertToInternalLog(entity, entityDef); rowkey = RowkeyBuilder.buildRowkey(log); } return rowkey; }
public static byte[] getRowkey(TaggedLogAPIEntity entity, EntityDefinition entityDef) throws Exception { byte[] rowkey = null; if(entity.getEncodedRowkey() != null && !(entity.getEncodedRowkey().isEmpty())){ rowkey = EagleBase64Wrapper.decode(entity.getEncodedRowkey()); }else{ InternalLog log = HBaseInternalLogHelper.convertToInternalLog(entity, entityDef); rowkey = RowkeyBuilder.buildRowkey(log); } return rowkey; }