code: public static Stream<Record> decode(final Stream<Statement> stream,
              @Nullable final Iterable<? extends URI> types, @Nullable final Boolean chunked) {
          Preconditions.checkNotNull(stream);
          if (types != null) {
              stream.setProperty("types", types);
          }
          if (chunked != null) {
              stream.setProperty("chunked", chunked);
          }
          return stream.transform(null, new Function<Handler<Record>, Handler<Statement>>() {
  
              @SuppressWarnings("unchecked")
              @Override
              public Handler<Statement> apply(final Handler<Record> handler) {
                  final Iterable<? extends URI> types = stream.getProperty("types", Iterable.class);
                  final Boolean chunked = stream.getProperty("chunked", Boolean.class);
                  return new Decoder(handler, types, chunked);
              }
  
          });
      }
docs: Performs RDF-to-record decoding by converting a stream of RDF statements in a stream of
  records. Parameter {@code types} specify the types of records that have to be extracted
  from the statement stream, while parameter {@code chunked} specifies whether the input
  statement stream is chunked, i.e., organized as a sequence of statement chunks with each
  chunk containing the statements for a record (and its nested records). Chunked RDF streams
  noticeably speed up decoding, and are always produced by the KnowledgeStore API. Type and
  chunking information may be set to null (e.g., because unknown at the time the method is
  called): in this case, they will be read from metadata attributes attached to the stream,
  named {@code "types"} and {@code "chunked"}; reading will happen just before decoding will
  take place, i.e., when a terminal stream operation will be called.
  
  @param stream
  the stream of statements to decode
  @param types
  the types of records to extract from the statement stream, null if to be read
  from stream metadata
  @param chunked
  true if the input statement stream is chunked, null if to be read from stream
  metadata
  @return the resulting stream of records