List of usage examples for org.apache.solr.common.util JavaBinCodec close
@Override
public void close() throws IOException
From source file:com.b2international.index.es.EsDocumentSearcher.java
License:Apache License
private String toSearchAfterToken(final Object[] searchAfter) { if (searchAfter == null) { return null; }/*w w w .j a v a 2s . c o m*/ try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final JavaBinCodec codec = new JavaBinCodec(); codec.marshal(searchAfter, baos); codec.close(); final byte[] tokenBytes = baos.toByteArray(); return Base64.getUrlEncoder().encodeToString(tokenBytes); } catch (IOException e) { throw new FormattedRuntimeException("Couldn't encode searchAfter paramaters to a token.", e); } }
From source file:com.b2international.index.es.EsDocumentSearcher.java
License:Apache License
private Object[] fromSearchAfterToken(final String searchAfterToken) { if (Strings.isNullOrEmpty(searchAfterToken)) { return null; }/* w ww. j a v a 2 s . com*/ final byte[] decodedToken = Base64.getUrlDecoder().decode(searchAfterToken); try (final ByteArrayInputStream bais = new ByteArrayInputStream(decodedToken)) { JavaBinCodec codec = new JavaBinCodec(); List<Object> obj = (List<Object>) codec.unmarshal(bais); codec.close(); return obj.toArray(); } catch (final IOException e) { throw new FormattedRuntimeException("Couldn't decode searchAfter token.", e); } }