Return a stream over the given results. If the results are not inline, the
results will come from S3

@param resultValue result
@return stream
@throws Exception errors
358050
public Reader getResults(ResultValue resultValue) throws Exception
    {
        if (resultValue.isInline())
        {
            return new StringReader(resultValue.getResults());
        }

        return readFromS3(resultValue.getResult_location());
    }
1334014
private InputStream getInputStream(String url) throws Exception {
        HttpGet getMethod = new HttpGet(url);
        DefaultHttpClient client = new DefaultHttpClient(m_cManager);
        client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT_SECONDS * 1000);
        UsernamePasswordCredentials creds = getCreds(url);
        if (creds != null) {
            client.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
            client.addRequestInterceptor(new PreemptiveAuth());
        }
        client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
        HttpInputStream in = new HttpInputStream(client, getMethod);
        if (in.getStatusCode() != 200) {
            try {
                in.close();
            } catch (Exception e) {
            }
            throw new IOException("HTTP request failed.  Got status code "
                    + in.getStatusCode()
                    + " from remote server while attempting to GET " + url);
        } else {
            return in;
        }
    }
330361
@Override
  public <S> StreamBuilderImpl<S,U> 
  custom(FunctionSync<ResultStream<S>,ResultStream<T>> builder)
  {
    return new Chain<S,T,U>(this, builder);
  }
1122238
private boolean readNextValue() throws IOException, SQLException {
    byte[] buf = reader.getPacketArray(false);

    //is error Packet
    if (buf[0] == ERROR) {
      protocol.removeActiveStreamingResult();
      protocol.removeHasMoreResults();
      protocol.setHasWarnings(false);
      ErrorPacket errorPacket = new ErrorPacket(new Buffer(buf));
      resetVariables();
      throw ExceptionMapper.get(errorPacket.getMessage(), errorPacket.getSqlState(),
          errorPacket.getErrorNumber(), null, false);
    }

    //is end of stream
    if (buf[0] == EOF && ((eofDeprecated && buf.length < 0xffffff)
        || (!eofDeprecated && buf.length < 8))) {
      int serverStatus;
      int warnings;

      if (!eofDeprecated) {
        //EOF_Packet
        warnings = (buf[1] & 0xff) + ((buf[2] & 0xff) << 8);
        serverStatus = ((buf[3] & 0xff) + ((buf[4] & 0xff) << 8));

        //CallableResult has been read from intermediate EOF server_status
        //and is mandatory because :
        //
        // - Call query will have an callable resultSet for OUT parameters
        //   this resultSet must be identified and not listed in JDBC statement.getResultSet()
        //
        // - after a callable resultSet, a OK packet is send,
        //   but mysql before 5.7.4 doesn't send MORE_RESULTS_EXISTS flag
        if (callableResult) {
          serverStatus |= MORE_RESULTS_EXISTS;
        }

      } else {

        //OK_Packet with a 0xFE header
        int pos = skipLengthEncodedValue(buf, 1); //skip update count
        pos = skipLengthEncodedValue(buf, pos); //skip insert id
        serverStatus = ((buf[pos++] & 0xff) + ((buf[pos++] & 0xff) << 8));
        warnings = (buf[pos++] & 0xff) + ((buf[pos] & 0xff) << 8);
        callableResult = (serverStatus & PS_OUT_PARAMETERS) != 0;
      }
      protocol.setServerStatus((short) serverStatus);
      protocol.setHasWarnings(warnings > 0);
      if ((serverStatus & MORE_RESULTS_EXISTS) == 0) {
        protocol.removeActiveStreamingResult();
      }

      resetVariables();
      return false;
    }

    //this is a result-set row, save it
    if (dataSize + 1 >= data.length) {
      growDataArray();
    }
    data[dataSize++] = buf;
    return true;
  }
1130795
@Override
    public Reader getNCharacterStream(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            String value = table.getString(columnIndex - 1);
            if (!wasNull())
                return new StringReader(value);
            return null;
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
1072521
public final static <T> CompletableFuture<List<T>> streamToCompletableFuture(final Stream<T> stream) {
        return CompletableFuture.completedFuture(stream.collect(Collectors.toList()));

    }
213750
public Try<T> orElse(Supplier<Try<T>> defaultValue) {
    try {
      return isSuccess() ? this : defaultValue.get();
    } catch (RuntimeException e) {
      return new Failure<>(e);
    }
  }
1117321
public <T> T performGetRequest(String url, Class<T> returnType, Map<String, String> uriVariables) {

        int tryNumber = 1;
        while(tryNumber <= API_RETRY) {
            try {
                return restTemplate.getForObject(url, returnType, uriVariables);
            } catch (HttpStatusCodeException error) {
                boolean isTooManyRequestsError = handleHttpStatusCodeError(uriVariables, tryNumber, error);
                if (isTooManyRequestsError) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        log.error("Error in performGetRequest", e);
                    }
                } else {
                    tryNumber++;
                }
            } catch (Exception e) {
                handleApiError(tryNumber, e);
                tryNumber++;
            }
        }

        throw new RestApiException("Error getting " + returnType.getSimpleName() + " url variables " + uriVariables.toString());

    }
843093
public static <T> ExceptionalStream<T, SQLException> rows(final ResultSet resultSet, final String columnName) {
        N.checkArgNotNull(resultSet, "resultSet");
        N.checkArgNotNull(columnName, "columnName");

        return rows(resultSet, getColumnIndex(resultSet, columnName));
    }
1374008
def as_stream(self):
        

        if not self.singular:
            raise ArgumentError("Attempted to convert a non-singular selector to a data stream, it matches multiple", selector=self)

        return DataStream(self.match_type, self.match_id, self.match_spec == DataStreamSelector.MatchSystemOnly)
645622
public static Converter<String, Object> createPathParamConverter(final Type resultType) {
    if (!(resultType instanceof Class)) {
      throw new IllegalArgumentException("Unsupported @PathParam type " + resultType);
    }
    return new Converter<String, Object>() {
      @Override
      public Object convert(String value) {
        return ConvertUtils.convert(value, (Class<?>) resultType);
      }
    };
  }
635599
public void streamResult(OutputStream os,
                          HeadersAmp headers,
                          String address,
                          long qId,
                          int sequence,
                          List<Object> values,
                          Throwable exn,
                          boolean isComplete)
     throws IOException
  {
    init(os);

    OutH3 out = _out;

    if (out == null) {
      return;
    }
    
    if (log.isLoggable(_level)) {
      log.log(_level, "hamp-stream-result-w " + values + "," + isComplete + " (in " + this + ")"
                 + "\n  {id:" + qId + " to:" + address + ", " + headers + "," + os + "}");
    }
    
    try {
      out.writeLong(MessageTypeHamp.STREAM_RESULT.ordinal());
    
      writeHeaders(out, headers);
    
      writeToAddress(out, address);
      out.writeLong(qId);
      
      out.writeLong(sequence);

      out.writeObject(values);
      out.writeObject(exn);
      out.writeBoolean(isComplete);
      
      //out.flushBuffer();
      out.flush();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
      
      throw e;
    }
  }
96977
public void findStream(String sql, Object []args, ResultStream<Cursor> result)
  {
    QueryBuilderKraken builder = QueryParserKraken.parse(this, sql);
    
    if (builder.isTableLoaded()) {
      QueryKraken query = builder.build(); 
      
      findStream(query, args, result);
    }
    else {
      String tableName = builder.getTableName();
      
      _tableService.loadTable(tableName,
                              result.of((x,r)->{
                                findStream(builder.build(), args, r); 
                              }));
                      //new FindStreamResult(result, builder, args));
    }
  }
33530
public <T> StreamSupplier<T> queryRawStream(List<String> dimensions, List<String> storedMeasures, AggregationPredicate where,
			Class<T> resultClass) throws QueryException {
		return queryRawStream(dimensions, storedMeasures, where, resultClass, classLoader);
	}
537042
@Override
	public <T> Stream<T> query(final SqlContext sqlContext, final ResultSetConverter<T> converter) throws SQLException {
		final ResultSet rs = query(sqlContext);
		return StreamSupport.stream(new ResultSetSpliterator<>(rs, converter), false).onClose(() -> {
			try {
				if (rs != null && !rs.isClosed()) {
					rs.close();
				}
			} catch (SQLException ex) {
				// do nothing
			}
		});
	}
321849
static LongStream stream(
        LongTuple tuple, int startInclusive, int endExclusive) 
    {
        LongTupleSpliterator longTupleSpliterator = 
            new LongTupleSpliterator(
                tuple, startInclusive, endExclusive);
        return StreamSupport.longStream(longTupleSpliterator, false);
    }
460854
private static Converter<List<String>, Object> createListConverter(Type resultType) {
    // Use boxed type if raw type is primitive type. Otherwise the type won't change.
    Class<?> resultClass = getRawClass(resultType);

    // For string, just return the first value
    if (resultClass == String.class) {
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return value;
        }
      };
    }

    // Creates converter based on the type

    // Primitive
    Converter<List<String>, Object> converter = createPrimitiveTypeConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // String constructor
    converter = createStringConstructorConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Static string argument methods
    converter = createStringMethodConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Collection
    converter = createCollectionConverter(resultType);
    if (converter != null) {
      return converter;
    }

    throw new IllegalArgumentException("Unsupported type " + resultType + " of type class " + resultType.getClass());
  }