datachunk.java
来自「jrobin,使用纯java实现的RRD数据库,使用RRD数据库来统计数据.」· Java 代码 · 共 65 行
JAVA
65 行
/*
* Copyright (C) 2001 Ciaran Treanor <ciaran@codeloop.com>
*
* Distributable under GPL license.
* See terms of license at gnu.org.
*
* $Id: DataChunk.java,v 1.1 2006/04/25 08:09:28 sasam Exp $
*/
package org.jrobin.core.jrrd;
/**
* Models a chunk of result data from an RRDatabase.
*
* @author <a href="mailto:ciaran@codeloop.com">Ciaran Treanor</a>
* @version $Revision: 1.1 $
*/
public class DataChunk {
private static final String NEWLINE = System.getProperty("line.separator");
long startTime;
int start;
int end;
long step;
int dsCount;
double[][] data;
int rows;
DataChunk(long startTime, int start, int end, long step, int dsCount, int rows) {
this.startTime = startTime;
this.start = start;
this.end = end;
this.step = step;
this.dsCount = dsCount;
this.rows = rows;
data = new double[rows][dsCount];
}
/**
* Returns a summary of the contents of this data chunk. The first column is
* the time (RRD format) and the following columns are the data source
* values.
*
* @return a summary of the contents of this data chunk.
*/
public String toString() {
StringBuffer sb = new StringBuffer();
long time = startTime;
for (int row = 0; row < rows; row++, time += step) {
sb.append(time);
sb.append(": ");
for (int ds = 0; ds < dsCount; ds++) {
sb.append(data[row][ds]);
sb.append(" ");
}
sb.append(NEWLINE);
}
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?