⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datachunk.java

📁 jrobin,使用纯java实现的RRD数据库,使用RRD数据库来统计数据.
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -