apache/druid · error · java.lang.UnsupportedOperationException

HyperUniquesBufferAggregator does not support getFloat()

Error message

HyperUniquesBufferAggregator does not support getFloat()

What it means

HyperUniquesBufferAggregator is the buffer-backed variant of the hyperUnique aggregator: it materializes a sketch from the ByteBuffer via doGet and supports only get()/sketch access. getFloat(ByteBuffer,int) throws UnsupportedOperationException because a sketch is not a float.

Solutions

  1. Use get(buf, position) (the HLL sketch) and compute the estimate from it
  2. Use a float-typed aggregator when a primitive float is required
  3. Gate numeric accessor calls on the factory's type name ("hyperUnique")
  4. In SQL, use APPROX_COUNT_DISTINCT_DS_HLL for a numeric result

Example fix

// before
float f = bufAgg.getFloat(buf, position); // throws
// after
Object o = bufAgg.get(buf, position); // HyperLogLogCollector sketch
double est = o == null ? 0.0 : ((HyperLogLogCollector) o).estimateCardinality();
Defensive patterns

Strategy: type-guard

Validate before calling

if ("hyperUnique".equals(factory.getTypeName())) { Object o = bufAgg.get(buf, pos); /* sketch */ }

Type guard

static boolean supportsFloat(BufferAggregator a, AggregatorFactory f) { return "float".equals(f.getTypeName()); }

Try / catch

try { f = bufAgg.getFloat(buf, pos); } catch (UnsupportedOperationException e) { f = Float.NaN; }

Prevention

When it happens

Trigger: Calling getFloat(buf, position) on a HyperUniquesBufferAggregator, typically from generic buffer-aggregator result loops that assume numeric metrics.

Common situations: Custom group-by engines or extension code reading buffer aggregators numerically; benchmarks/tests exercising all accessors on every BufferAggregator implementation.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/68187b22bac380a0. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java:99

    try {
      HyperLogLogCollector.makeCollector(buf).fold(collector);
    }
    finally {
      buf.limit(oldLimit);
      buf.position(oldPosition);
    }
  }

  @Override
  public Object get(ByteBuffer buf, int position)
  {
    return doGet(buf, position);
  }

  @Override
  public float getFloat(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getFloat()");
  }


  @Override
  public long getLong(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getLong()");
  }

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getDouble()");
  }

  @Override
  public void close()
  {

View on GitHub (pinned to 9b90983fd2)