@Override public SampledValue read(long timestamp) throws IOException { // TODO Search the special value if (!canRead) { enableInput(); } long startpos = headerend; fis.getChannel().position(startpos); byte[] b = new byte[(int) (dataFile.length() - headerend)]; dis.read(b, 0, b.length); ByteBuffer bb = ByteBuffer.wrap(b); ((Buffer) bb).rewind(); int countOfDataSets = (int) ((dataFile.length() - headerend) / 17); for (int i = 0; i < countOfDataSets; i++) { long timestamp2 = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (timestamp < timestamp2) { return null; } if (!Double.isNaN(d) && timestamp == timestamp2) { return new SampledValue(DoubleValues.of(d), timestamp2, s); } } return null; }
.append("<time>").append(time).append("</time>") .append(linebreak).append(separator).append(separator) .append("<quality>").append(sv.getQuality().toString()).append("</quality>") .append(linebreak).append(separator).append(separator) .append("<value>") sb.append(',') .append(linebreak).append(separator).append(separator) .append("\"quality\":\"").append(sv.getQuality().toString()).append('\"').append(',') .append(linebreak).append(separator).append(separator) .append("\"value\":").append(val instanceof BooleanValue ? val.getBooleanValue() :
void write(SampledValue val, JsonGenerator jGen) throws IOException { jGen.writeStartObject(); jGen.writeNumberField("time", val.getTimestamp()); jGen.writeStringField("quality", val.getQuality().name()); writeValue(val, jGen); jGen.writeEndObject(); }
private static Quality qualityFromToken(JsonParser p) throws IOException { try { return Quality.valueOf(p.getText()); } catch (IllegalArgumentException iae) { throw new IOException("malformed document, illegal quality value at " + p.getCurrentLocation()); } }
@Override public SampledValue readNextValue(long timestamp) throws IOException { if (!canRead) { enableInput(); } long startpos = headerend; fis.getChannel().position(startpos); byte[] b = new byte[(int) (dataFile.length() - headerend)]; dis.read(b, 0, b.length); ByteBuffer bb = ByteBuffer.wrap(b); ((Buffer) bb).rewind(); int countOfDataSets = (int) ((dataFile.length() - headerend) / getDataSetSize()); for (int i = 0; i < countOfDataSets; i++) { long timestamp2 = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (!Double.isNaN(d) && timestamp <= timestamp2) { return new SampledValue(DoubleValues.of(d), timestamp2, s); } } return null; }
@Override public void writeJson(Writer writer, Resource res, RecordedData data, long startTime, long endTime, long interval, ReductionMode mode) throws IOException { try (@SuppressWarnings("deprecation") JsonGenerator jg = new JsonFactory().createJsonGenerator(writer).useDefaultPrettyPrinter()) { jg.writeStartObject(); jg.writeStringField("@type", "RecordedData"); jg.writeStringField("resource", res.getLocation()); //FIXME: getInterpolationMode not supported jg.writeStringField("interpolationMode", "NONE"); jg.writeNumberField("startTime", startTime); jg.writeNumberField("endTime", endTime); jg.writeNumberField("interval", interval); jg.writeStringField("reductionMode", mode.toString()); jg.writeArrayFieldStart("entry"); for (SampledValue sv : data.getValues(startTime, endTime, interval, mode)) { jg.writeStartObject(); jg.writeNumberField("time", sv.getTimestamp()); jg.writeStringField("quality", sv.getQuality().toString()); jg.writeStringField("value", sv.getValue().getStringValue()); jg.writeEndObject(); } jg.writeEndArray(); jg.writeEndObject(); jg.flush(); } }
void write(SampledValue val, JsonGenerator jGen) throws IOException { jGen.writeStartObject(); jGen.writeNumberField("time", val.getTimestamp()); jGen.writeStringField("quality", val.getQuality().name()); writeValue(val, jGen); jGen.writeEndObject(); }
@Override public SampledValue read(long timestamp) throws IOException { // TODO Search the special value if (!canRead) { enableInput(); } long startpos = headerend; fis.getChannel().position(startpos); byte[] b = new byte[(int) (dataFile.length() - headerend)]; dis.read(b, 0, b.length); ByteBuffer bb = ByteBuffer.wrap(b); // casting is a hack to avoid incompatibility when building this on Java 9 and run on Java 8 // ByteBuffer#rewind used to return a Buffer in Jdk8, but from Java 9 on returns a ByteBuffer ((Buffer) bb).rewind(); int countOfDataSets = (int) ((dataFile.length() - headerend) / 17); for (int i = 0; i < countOfDataSets; i++) { long timestamp2 = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (timestamp < timestamp2) { return null; } if (!Double.isNaN(d) && timestamp == timestamp2) { return new SampledValue(DoubleValues.of(d), timestamp2, s); } } return null; }
xw.writeCharacters(sv.getQuality().toString()); xw.writeEndElement();
@Override public SampledValue readNextValue(long timestamp) throws IOException { if (!canRead) { enableInput(); } long startpos = headerend; fis.getChannel().position(startpos); byte[] b = new byte[(int) (dataFile.length() - headerend)]; dis.read(b, 0, b.length); ByteBuffer bb = ByteBuffer.wrap(b); // casting is a hack to avoid incompatibility when building this on Java 9 and run on Java 8 // ByteBuffer#rewind used to return a Buffer in Jdk8, but from Java 9 on returns a ByteBuffer ((Buffer) bb).rewind(); int countOfDataSets = (int) ((dataFile.length() - headerend) / getDataSetSize()); for (int i = 0; i < countOfDataSets; i++) { long timestamp2 = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (!Double.isNaN(d) && timestamp <= timestamp2) { return new SampledValue(DoubleValues.of(d), timestamp2, s); } } return null; }
@Override public SampledValue read(long timestamp) throws IOException { if ((timestamp - startTimeStamp) % storagePeriod == 0) { if (timestamp >= startTimeStamp && timestamp <= getTimestampForLatestValueInternal()) { if (!canRead) { enableInput(); } fis.getChannel().position(getBytePosition(timestamp)); Double toReturn = dis.readDouble(); if (!Double.isNaN(toReturn)) { return new SampledValue(DoubleValues.of(toReturn), timestamp, Quality.getQuality(dis.readByte())); } } } return null; }
@Override public SampledValue read(long timestamp) throws IOException { if ((timestamp - startTimeStamp) % storagePeriod == 0) { if (timestamp >= startTimeStamp && timestamp <= getTimestampForLatestValueInternal()) { if (!canRead) { enableInput(); } fis.getChannel().position(getBytePosition(timestamp)); Double toReturn = dis.readDouble(); if (!Double.isNaN(toReturn)) { return new SampledValue(DoubleValues.of(toReturn), timestamp, Quality.getQuality(dis.readByte())); } } } return null; }
long timestamp = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (!Double.isNaN(d)) { if (timestamp >= start && timestamp <= end) {
long timestamp2 = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (!Double.isNaN(d) && timestamp >= timestamp2) { tcand = timestamp2;
long timestamp = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get());
@Override public Void run() throws Exception { lock.writeLock().lock(); try { if (configuration != null) { for (SampledValue value : values) { recorder.getProxy().appendValue(id, value.getValue().getDoubleValue(), value.getTimestamp(), (byte) value.getQuality().getQuality(), configuration); } } } catch (IOException e) { logger.error("", e); } catch (IllegalConversionException e) { logger.error("", e); } finally { lock.writeLock().unlock(); } return null; }
long timestamp = bb.getLong(); double d = bb.getDouble(); Quality s = Quality.getQuality(bb.get()); if (!Double.isNaN(d)) { if (timestamp >= start && timestamp <= end) {
@Override public Void run() throws Exception { lock.writeLock().lock(); try { if (configuration != null) { for (SampledValue value : values) { recorder.getProxy().appendValue(idEncoded, value.getValue().getDoubleValue(), value.getTimestamp(), (byte) value.getQuality().getQuality(), configuration); } } } catch (IOException e) { logger.error("", e); } catch (IllegalConversionException e) { logger.error("", e); } finally { lock.writeLock().unlock(); } return null; }
dos.writeByte(Quality.BAD.getQuality()); // TODO:
@Override public Void run() throws Exception { lock.writeLock().lock(); try { if (configuration != null) { recorder.getProxy().appendValue(id, value.getValue().getDoubleValue(), value.getTimestamp(), (byte) value.getQuality().getQuality(), configuration); } } catch (IOException e) { logger.error("", e); } catch (IllegalConversionException e) { logger.error("", e); } catch (NullPointerException e) { logger.error("NPE in SlotsdbStorage - recorder: {}, proxy: {}, id: {}, config: {}, value: {}", recorder, (recorder!=null? recorder.getProxy(): null), id, configuration, value,e); } finally { lock.writeLock().unlock(); } return null; }