Java Code Examples for org.apache.hadoop.hbase.KeyValue#getQualifier()
The following examples show how to use
org.apache.hadoop.hbase.KeyValue#getQualifier() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityQualifierUtils.java From Eagle with Apache License 2.0 | 6 votes |
public static Map<String,Object> keyValuesToMap(List<KeyValue> row,EntityDefinition ed){ Map<String,Object> result = new HashMap<String,Object>(); for(KeyValue kv:row){ String qualifierName = new String(kv.getQualifier()); if(!ed.isTag(qualifierName)){ Qualifier qualifier = ed.getDisplayNameMap().get(qualifierName); if(qualifier == null){ qualifier = ed.getQualifierNameMap().get(qualifierName); } qualifierName = qualifier.getDisplayName(); Object value = qualifier.getSerDeser().deserialize(kv.getValue()); result.put(qualifierName,value); }else{ result.put(qualifierName,new String(kv.getValue())); } } return result; }
Example 2
Source File: EntityQualifierUtils.java From Eagle with Apache License 2.0 | 6 votes |
public static Map<String,Double> keyValuesToDoubleMap(List<KeyValue> row,EntityDefinition ed){ Map<String,Double> result = new HashMap<String,Double>(); for(KeyValue kv:row){ String qualifierName = new String(kv.getQualifier()); if(!ed.isTag(qualifierName)){ Qualifier qualifier = ed.getDisplayNameMap().get(qualifierName); if(qualifier == null){ qualifier = ed.getQualifierNameMap().get(qualifierName); } qualifierName = qualifier.getDisplayName(); Object value = qualifier.getSerDeser().deserialize(kv.getValue()); result.put(qualifierName,convertObjToDouble(value)); }else{ result.put(qualifierName,Double.NaN); } } return result; }
Example 3
Source File: EntityQualifierUtils.java From eagle with Apache License 2.0 | 6 votes |
public static Map<String, Object> keyValuesToMap(List<KeyValue> row, EntityDefinition ed) { Map<String, Object> result = new HashMap<String, Object>(); for (KeyValue kv : row) { String qualifierName = new String(kv.getQualifier()); if (!ed.isTag(qualifierName)) { Qualifier qualifier = ed.getDisplayNameMap().get(qualifierName); if (qualifier == null) { qualifier = ed.getQualifierNameMap().get(qualifierName); } qualifierName = qualifier.getDisplayName(); Object value = qualifier.getSerDeser().deserialize(kv.getValue()); result.put(qualifierName, value); } else { result.put(qualifierName, new String(kv.getValue())); } } return result; }
Example 4
Source File: EntityQualifierUtils.java From eagle with Apache License 2.0 | 6 votes |
public static Map<String, Double> keyValuesToDoubleMap(List<KeyValue> row, EntityDefinition ed) { Map<String, Double> result = new HashMap<String, Double>(); for (KeyValue kv : row) { String qualifierName = new String(kv.getQualifier()); if (!ed.isTag(qualifierName)) { Qualifier qualifier = ed.getDisplayNameMap().get(qualifierName); if (qualifier == null) { qualifier = ed.getQualifierNameMap().get(qualifierName); } qualifierName = qualifier.getDisplayName(); Object value = qualifier.getSerDeser().deserialize(kv.getValue()); result.put(qualifierName, convertObjToDouble(value)); } else { result.put(qualifierName, Double.NaN); } } return result; }
Example 5
Source File: HBaseInternalLogHelper.java From Eagle with Apache License 2.0 | 5 votes |
/** * * @param ed * @param r * @param qualifiers if null, return all qualifiers defined in ed * @return */ public static InternalLog parse(EntityDefinition ed, Result r, byte[][] qualifiers) { final byte[] row = r.getRow(); // skip the first 4 bytes : prefix final int offset = (ed.getPartitions() == null) ? (4) : (4 + ed.getPartitions().length * 4); long timestamp = ByteUtil.bytesToLong(row, offset); // reverse timestamp timestamp = Long.MAX_VALUE - timestamp; final byte[] family = ed.getColumnFamily().getBytes(); final Map<String, byte[]> allQualifierValues = new HashMap<String, byte[]>(); if (qualifiers != null) { int count = qualifiers.length; final byte[][] values = new byte[count][]; for (int i = 0; i < count; i++) { // TODO if returned value is null, it means no this column for this row, so why set null to the object? values[i] = r.getValue(family, qualifiers[i]); allQualifierValues.put(new String(qualifiers[i]), values[i]); } }else{ // return all qualifiers for(KeyValue kv:r.list()){ byte[] qualifier = kv.getQualifier(); byte[] value = kv.getValue(); allQualifierValues.put(new String(qualifier),value); } } final InternalLog log = buildObject(ed, row, timestamp, allQualifierValues); return log; }
Example 6
Source File: BooleanExpressionComparator.java From Eagle with Apache License 2.0 | 5 votes |
/** * * @param row List[KeyValue] All key values in a row * * @return 0 to filter out row [false], otherwise to include row into scanner [true] */ @Override public int compareTo(List<KeyValue> row) { Map<String,Double> context = new HashMap<String, Double>(); for(KeyValue kv:row){ String qualifierName = new String(kv.getQualifier()); // Because assume just handle about double value // so ignore tag whose value is String if(!this.ed.isTag(qualifierName)){ Qualifier qualifier = this.ed.getQualifierNameMap().get(qualifierName); String displayName = qualifier.getDisplayName(); if(displayName == null) displayName = qualifierName; try { if(this.requiredFields.contains(displayName)) { EntitySerDeser serDeser = qualifier.getSerDeser(); double value = EntityQualifierUtils.convertObjToDouble(serDeser.deserialize(kv.getValue())); if (Double.isNaN(value)) { context.put(displayName, value); } } }catch (Exception ex){ LOG.warn("Failed to parse value of field "+displayName+" as double, ignore: "+ex.getMessage(),ex); } } } return compareTo(context); }
Example 7
Source File: HBaseInternalLogHelper.java From eagle with Apache License 2.0 | 5 votes |
/** * @param ed * @param r * @param qualifiers if null, return all qualifiers defined in ed * @return */ public static InternalLog parse(EntityDefinition ed, Result r, byte[][] qualifiers) { final byte[] row = r.getRow(); // skip the first 4 bytes : prefix final int offset = (ed.getPartitions() == null) ? (4) : (4 + ed.getPartitions().length * 4); long timestamp = ByteUtil.bytesToLong(row, offset); // reverse timestamp timestamp = Long.MAX_VALUE - timestamp; final byte[] family = ed.getColumnFamily().getBytes(); final Map<String, byte[]> allQualifierValues = new HashMap<String, byte[]>(); if (qualifiers != null) { int count = qualifiers.length; final byte[][] values = new byte[count][]; for (int i = 0; i < count; i++) { // TODO if returned value is null, it means no this column for this row, so why set null to // the object? values[i] = r.getValue(family, qualifiers[i]); allQualifierValues.put(new String(qualifiers[i]), values[i]); } } else { // return all qualifiers for (KeyValue kv : r.list()) { byte[] qualifier = kv.getQualifier(); byte[] value = kv.getValue(); allQualifierValues.put(new String(qualifier), value); } } final InternalLog log = buildObject(ed, row, timestamp, allQualifierValues); return log; }
Example 8
Source File: BooleanExpressionComparator.java From eagle with Apache License 2.0 | 5 votes |
/** * @param row List[KeyValue] All key values in a row * @return 0 to filter out row [false], otherwise to include row into scanner [true] */ @Override public int compareTo(List<KeyValue> row) { Map<String, Double> context = new HashMap<String, Double>(); for (KeyValue kv : row) { String qualifierName = new String(kv.getQualifier()); // Because assume just handle about double value // so ignore tag whose value is String if (!this.ed.isTag(qualifierName)) { Qualifier qualifier = this.ed.getQualifierNameMap().get(qualifierName); String displayName = qualifier.getDisplayName(); if (displayName == null) { displayName = qualifierName; } try { if (this.requiredFields.contains(displayName)) { EntitySerDeser serDeser = qualifier.getSerDeser(); double value = EntityQualifierUtils .convertObjToDouble(serDeser.deserialize(kv.getValue())); if (Double.isNaN(value)) { context.put(displayName, value); } } } catch (Exception ex) { LOG.warn("Failed to parse value of field " + displayName + " as double, ignore: " + ex.getMessage(), ex); } } } return compareTo(context); }
Example 9
Source File: TransactionState.java From hbase-secondary-index with GNU General Public License v3.0 | 4 votes |
KeyValue applyDeletes(final KeyValue kv, final long minTime, final long maxTime) { if (deletes.isEmpty()) { return kv; } for (Delete delete : deletes) { // Skip if delete should not apply if (!Bytes.equals(kv.getRow(), delete.getRow()) || kv.getTimestamp() > delete.getTimeStamp() || delete.getTimeStamp() > maxTime || delete.getTimeStamp() < minTime) { continue; } // Whole-row delete if (delete.isEmpty()) { return null; } for (Entry<byte[], List<KeyValue>> deleteEntry : delete .getFamilyMap().entrySet()) { byte[] family = deleteEntry.getKey(); if (!Bytes.equals(kv.getFamily(), family)) { continue; } List<KeyValue> familyDeletes = deleteEntry.getValue(); if (familyDeletes == null) { return null; } for (KeyValue keyDeletes : familyDeletes) { byte[] deleteQualifier = keyDeletes.getQualifier(); byte[] kvQualifier = kv.getQualifier(); if (keyDeletes.getTimestamp() > kv.getTimestamp() && Bytes.equals(deleteQualifier, kvQualifier)) { return null; } } } } return kv; }