private Object decodeIndexFieldFrom(String fieldName, byte[] rowKey) throws IOException { final StructRowKey structRowKey = definition.asStructRowKey(); structRowKey.iterateOver(rowKey); final StructIterator iterator = structRowKey.iterator(); int fieldPosition = definition.getFieldPosition(fieldName); if (fieldPosition == -1) { throw new MalformedQueryException("field [" + fieldName + "] is not part of the index"); } // skip all fields up to fieldPosition for (int i = 0; i < fieldPosition; i++) { iterator.skip(); } // return the requested field return iterator.next(); }