return new HashMap<String, Object>(); EnrichmentLookup.HBaseContext hbaseContext = new EnrichmentLookup.HBaseContext(lookup.getTable(), cf); try { LookupKV<EnrichmentKey, EnrichmentValue> kv = lookup.get(new EnrichmentKey(enrichmentType, indicator), hbaseContext, true);
@Override public Iterable<LookupKV<EnrichmentKey, EnrichmentValue>> get( Iterable<KeyWithContext<EnrichmentKey, HBaseContext>> keys , boolean logAccess ) throws IOException { if(Iterables.isEmpty(keys)) { return Collections.emptyList(); } HTableInterface table = Iterables.getFirst(keys, null).getContext().getTable(); List<LookupKV<EnrichmentKey, EnrichmentValue>> ret = new ArrayList<>(); Iterator<KeyWithContext<EnrichmentKey, HBaseContext>> keyWithContextIterator = keys.iterator(); for(Result result : table.get(keysToGets(keys))) { HBaseContext context = keyWithContextIterator.next().getContext(); ret.add(converter.fromResult(result, getColumnFamily(context))); } return ret; }
return false; EnrichmentLookup.HBaseContext hbaseContext = new EnrichmentLookup.HBaseContext(lookup.getTable(), cf); try { return lookup.exists(new EnrichmentKey(enrichmentType, indicator), hbaseContext, true);
private String getColumnFamily(HBaseContext context) { return context.getColumnFamily() == null?columnFamily:context.getColumnFamily(); }
@Override public boolean exists(EnrichmentKey key, HBaseContext context, boolean logAccess) throws IOException { return context.getTable().exists(converter.toGet(getColumnFamily(context), key)); }
@Override public LookupKV<EnrichmentKey, EnrichmentValue> get(EnrichmentKey key, HBaseContext context, boolean logAccess) throws IOException { return converter.fromResult(context.getTable().get(converter.toGet(getColumnFamily(context), key)), getColumnFamily(context)); }
@Nullable @Override public KeyWithContext<EnrichmentKey, EnrichmentLookup.HBaseContext> apply(@Nullable String enrichmentType) { EnrichmentKey key = new EnrichmentKey(enrichmentType, indicator); EnrichmentLookup.HBaseContext context = new EnrichmentLookup.HBaseContext(table, getColumnFamily(enrichmentType, config)); return new KeyWithContext<>(key, context); } }
@Override public Iterable<Boolean> exists(Iterable<KeyWithContext<EnrichmentKey, HBaseContext>> key, boolean logAccess) throws IOException { List<Boolean> ret = new ArrayList<>(); if(Iterables.isEmpty(key)) { return Collections.emptyList(); } HTableInterface table = Iterables.getFirst(key, null).getContext().getTable(); for(boolean b : table.existsAll(keysToGets(key))) { ret.add(b); } return ret; }