public HGSearchResult<T> execute()
    {
    	switch (scanType)
    	{
    		case keys: return ((HGIndex<T, ?>)index).scanKeys();
    		case values: ((HGIndex<?, T>)index).scanValues();
    		default:
		    	switch (operator)
		    	{
		    		case EQ:
		    			return ((HGIndex<Object, T>)index).find(key.get());
		    		case LT:
		    			return ((HGSortIndex<Object, T>)index).findLT(key.get());
		    		case GT:
		    			return ((HGSortIndex<Object, T>)index).findGT(key.get());
		    		case LTE:
		    			return ((HGSortIndex<Object, T>)index).findLTE(key.get());
		    		case GTE:
		    			return ((HGSortIndex<Object, T>)index).findGTE(key.get());   
		    		default:
		    			throw new HGException("Wrong operator code [" + operator + "] passed to IndexBasedQuery.");
		    	}
	    }
    }