public static String getRiverVersion() { String version = "Undefined"; try { String properties = Streams.copyToStringFromClasspath("/org/elasticsearch/river/mongodb/es-build.properties"); Properties props = new Properties(); props.load(new FastStringReader(properties)); String ver = props.getProperty("version", "undefined"); String hash = props.getProperty("hash", "undefined"); if (!"undefined".equals(hash)) { hash = hash.substring(0, 7); } String timestamp = "undefined"; String gitTimestampRaw = props.getProperty("timestamp"); if (gitTimestampRaw != null) { timestamp = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(Long.parseLong(gitTimestampRaw)); } version = String.format("version[%s] - hash[%s] - time[%s]", ver, hash, timestamp); } catch (Exception ex) { } return version; }
/** * Resets the stream to the most recent mark, or to the beginning of the * string if it has never been marked. * * @throws IOException If an I/O error occurs */ @Override public void reset() throws IOException { ensureOpen(); next = mark; }
public void addText(String name, String text, float boost) { if (boost != 1.0f) { customBoost = true; } final int lastStartOffset; if (entries.isEmpty()) { lastStartOffset = -1; } else { final Entry last = entries.get(entries.size() - 1); lastStartOffset = last.startOffset() + last.reader().length(); } final int startOffset = lastStartOffset + 1; // +1 because we insert a space between tokens Entry entry = new Entry(name, new FastStringReader(text), startOffset, boost); entries.add(entry); }
@Override public boolean ready() throws IOException { return (current != null) && current.reader().ready(); }
@Override public void reset() { try { for (Entry entry : entries) { entry.reader().reset(); } } catch (IOException e) { throw new IllegalStateException("should not happen"); } it = entries.iterator(); if (it.hasNext()) { current = it.next(); itsSeparatorTime = true; } }
/** * Resets the stream to the most recent mark, or to the beginning of the * string if it has never been marked. * * @throws IOException If an I/O error occurs */ @Override public void reset() throws IOException { ensureOpen(); next = mark; }
/** * First call will return the original Reader provided. */ @Override public Reader giveAClone() { if (original != null) { Reader rtn = original; original = null; // no longer hold a reference return rtn; } return new FastStringReader(originalContent); }
/** * Resets the stream to the most recent mark, or to the beginning of the * string if it has never been marked. * * @throws IOException If an I/O error occurs */ @Override public void reset() throws IOException { ensureOpen(); next = mark; }
public static void spaceify(int spaces, String from, StringBuilder to) throws Exception { try (BufferedReader reader = new BufferedReader(new FastStringReader(from))) { String line; while ((line = reader.readLine()) != null) { for (int i = 0; i < spaces; i++) { to.append(' '); } to.append(line).append('\n'); } } }
/** * Tells whether this stream is ready to be read. * * @return True if the next read() is guaranteed not to block for input * @throws IOException If the stream is closed */ @Override public boolean ready() throws IOException { ensureOpen(); return true; }
public static void spaceify(int spaces, String from, StringBuilder to) throws Exception { try (BufferedReader reader = new BufferedReader(new FastStringReader(from))) { String line; while ((line = reader.readLine()) != null) { for (int i = 0; i < spaces; i++) { to.append(' '); } to.append(line).append('\n'); } } }
/** * Tells whether this stream is ready to be read. * * @return True if the next read() is guaranteed not to block for input * @throws IOException If the stream is closed */ @Override public boolean ready() throws IOException { ensureOpen(); return true; }
@Override public XContentParser createParser(NamedXContentRegistry xContentRegistry, String content) throws IOException { return new JsonXContentParser(xContentRegistry, jsonFactory.createParser(new FastStringReader(content))); }
/** * Tells whether this stream is ready to be read. * * @return True if the next read() is guaranteed not to block for input * @throws IOException If the stream is closed */ @Override public boolean ready() throws IOException { ensureOpen(); return true; }
@Override public Factory buildFactory() { try { String properties = Resources.toString(Resources.getResource("es-build.properties"), UTF_8); Properties props = new Properties(); props.load(new FastStringReader(properties)); clientVersion = props.getProperty("version", "2.x"); } catch (IOException ignored) { } return new Factory(this); } }
/** * Reads a single character. * * @return The character read, or -1 if the end of the stream has been * reached * @throws IOException If an I/O error occurs */ @Override public int read() throws IOException { ensureOpen(); if (next >= length) return -1; return str.charAt(next++); }
@Override public XContentParser createParser(NamedXContentRegistry xContentRegistry, String content) throws IOException { return new CborXContentParser(xContentRegistry, cborFactory.createParser(new FastStringReader(content))); }
/** * Reads a single character. * * @return The character read, or -1 if the end of the stream has been * reached * @throws IOException If an I/O error occurs */ @Override public int read() throws IOException { ensureOpen(); if (next >= length) return -1; return str.charAt(next++); }
@Override public XContentParser createParser(NamedXContentRegistry xContentRegistry, String content) throws IOException { return new SmileXContentParser(xContentRegistry, smileFactory.createParser(new FastStringReader(content))); }