Update of /cvsroot/jrobin/src/org/jrobin/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12848/org/jrobin/core
Modified Files:
Robin.java RrdDef.java
Log Message:
Bug fixes and API enhancements to Robin class.
Index: RrdDef.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDef.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** RrdDef.java 21 Jul 2004 08:27:40 -0000 1.14
--- RrdDef.java 18 Aug 2004 08:02:17 -0000 1.15
***************
*** 546,551 ****
static long calculateSize(int dsCount, int arcCount, int rowsCount) {
! return 64L + 128L * dsCount + 56L * arcCount +
! 20L * dsCount * arcCount + 8L * dsCount * rowsCount;
}
--- 546,554 ----
static long calculateSize(int dsCount, int arcCount, int rowsCount) {
! // return 64L + 128L * dsCount + 56L * arcCount +
! // 20L * dsCount * arcCount + 8L * dsCount * rowsCount;
! return (24L + 48L * dsCount + 16L * arcCount +
! 20L * dsCount * arcCount + 8L * dsCount * rowsCount) +
! (1L + 2L * dsCount + arcCount) * 2L * RrdPrimitive.STRING_LENGTH;
}
Index: Robin.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/Robin.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Robin.java 20 May 2004 10:29:32 -0000 1.12
--- Robin.java 18 Aug 2004 08:02:17 -0000 1.13
***************
*** 91,102 ****
}
- // updates Robin values in bulk
void update(double[] newValues) throws IOException {
! assert rows == newValues.length: "Invalid number of values supplied: " + newValues.length +
! " rows=" + rows;
pointer.set(0);
values.writeDouble(0, newValues);
}
String dump() throws IOException {
StringBuffer buffer = new StringBuffer("Robin " + pointer.get() + "/" + rows + ": ");
--- 91,129 ----
}
void update(double[] newValues) throws IOException {
! assert rows == newValues.length: "Invalid number of robin values supplied (" + newValues.length +
! "), exactly " + rows + " needed";
pointer.set(0);
values.writeDouble(0, newValues);
}
+ /**
+ * Updates archived values in bulk.
+ * @param newValues Array of double values to be stored in the archive
+ * @throws IOException Thrown in case of I/O error
+ * @throws RrdException Thrown if the length of the input array is different from the length of
+ * this archive
+ */
+ public void setValues(double[] newValues) throws IOException, RrdException {
+ if(rows != newValues.length) {
+ throw new RrdException("Invalid number of robin values supplied (" + newValues.length +
+ "), exactly " + rows + " needed");
+ }
+ update(newValues);
+ }
+
+ /**
+ * (Re)sets all values in this archive to the same value.
+ * @param newValue New value
+ * @throws IOException Thrown in case of I/O error
+ */
+ public void setValues(double newValue) throws IOException {
+ double[] values = new double[rows];
+ for(int i = 0; i < values.length; i++) {
+ values[i] = newValue;
+ }
+ update(values);
+ }
+
String dump() throws IOException {
StringBuffer buffer = new StringBuffer("Robin " + pointer.get() + "/" + rows + ": ");
***************
*** 188,192 ****
}
! void filterValues(double minValue, double maxValue) throws IOException {
for(int i = 0; i < rows; i++) {
double value = values.get(i);
--- 215,227 ----
}
! /**
! * Filters values stored in this archive based on the given boundary.
! * Archived values found to be outside of <code>[minValue, maxValue]</code> interval (inclusive)
! * will be silently replaced with <code>NaN</code>.
! * @param minValue lower boundary
! * @param maxValue upper boundary
! * @throws IOException Thrown in case of I/O error
! */
! public void filterValues(double minValue, double maxValue) throws IOException {
for(int i = 0; i < rows; i++) {
double value = values.get(i);
|