public ObjectStream<List<String>> tokenize(StringTokenizer tok) { return ObjectStreams.transform(this, new TokenizerFunction(tok)); }
/** * Open a stream to read entities from this source. * @return A stream of entities. */ @Override public ObjectStream<Entity> openStream() throws IOException { BufferedReader reader = source.openBufferedStream(); ObjectStream<String> lines = new LineStream(reader); int headerLines = format.getHeaderLines(); List<String> header = new ArrayList<>(); while (header.size() < headerLines) { String line = lines.readObject(); if (line == null) { IOException ex = new IOException(String.format("%s: expected %d header lines, found %d", sourceURL, headerLines, header.size())); try { lines.close(); } catch (Throwable th) { ex.addSuppressed(th); } throw ex; } header.add(line); } LineEntityParser parser = format.makeParser(header); return ObjectStreams.transform(lines, parser); }
@Override public ObjectStream<IdBox<Long2DoubleMap>> streamUsers() { ObjectStream<IdBox<List<Entity>>> stream = dao.query(getEntityType()) .groupBy(CommonAttributes.USER_ID) .stream(); return ObjectStreams.transform(stream, new Function<IdBox<List<Entity>>, IdBox<Long2DoubleMap>>() { @Nullable @Override public IdBox<Long2DoubleMap> apply(@Nullable IdBox<List<Entity>> input) { if (input == null) { return null; } return IdBox.create(input.getId(), makeVector(input.getValue())); } }); } }
: ObjectStreams.transform(baseStream, Entities.projection(query.getViewType())); List<SortKey> sort = query.getSortKeys(); List<SortKey> dataKeys = data.getSortKeys();
public ObjectStream<List<String>> tokenize(StrTokenizer tok) { return ObjectStreams.transform(this, new TokenizerFunction(tok)); }
/** * Open a stream to read entities from this source. * @return A stream of entities. */ @Override public ObjectStream<Entity> openStream() throws IOException { BufferedReader reader = source.openBufferedStream(); ObjectStream<String> lines = new LineStream(reader); int headerLines = format.getHeaderLines(); List<String> header = new ArrayList<>(); while (header.size() < headerLines) { String line = lines.readObject(); if (line == null) { IOException ex = new IOException(String.format("%s: expected %d header lines, found %d", sourceURL, headerLines, header.size())); try { lines.close(); } catch (Throwable th) { ex.addSuppressed(th); } throw ex; } header.add(line); } LineEntityParser parser = format.makeParser(header); return ObjectStreams.transform(lines, parser); }
@Override public ObjectStream<IdBox<Long2DoubleMap>> streamUsers() { ObjectStream<IdBox<List<Entity>>> stream = dao.query(getEntityType()) .groupBy(CommonAttributes.USER_ID) .stream(); return ObjectStreams.transform(stream, new Function<IdBox<List<Entity>>, IdBox<Long2DoubleMap>>() { @Nullable @Override public IdBox<Long2DoubleMap> apply(@Nullable IdBox<List<Entity>> input) { if (input == null) { return null; } return IdBox.create(input.getId(), makeVector(input.getValue())); } }); } }
: ObjectStreams.transform(baseStream, Entities.projection(query.getViewType())); List<SortKey> sort = query.getSortKeys(); List<SortKey> dataKeys = data.getSortKeys();