net.quasardb.qdb.ts.WritableRow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jni Show documentation
Show all versions of jni Show documentation
API for the JNI components of the QuasarDB API for Java. Should not be included directly.
package net.quasardb.qdb.ts;
import java.io.IOException;
import java.io.Serializable;
import java.nio.channels.SeekableByteChannel;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import net.quasardb.qdb.*;
import net.quasardb.qdb.jni.*;
import java.util.*;
/**
* Represents a timeseries row.
*/
public final class WritableRow extends Row implements Serializable {
protected Timespec timestamp;
/**
* Row with timestamp
*
* @param timestamp The Valid Time for the row. This timestamp will be the primary index
* that quasardb stores this row under.
* @param values All values for this row.
*/
public WritableRow(Timespec timestamp, Value[] values) {
super(values);
this.timestamp = timestamp;
}
/**
* Row with timestamp
*
* @param timestamp The Valid Time for the row. This timestamp will be the primary index
* that quasardb stores this row under.
* @param values All values for this row.
*/
public WritableRow(LocalDateTime timestamp, Value[] values) {
this(new Timespec(timestamp), values);
}
/**
* Row with timestamp
*
* @param timestamp The Valid Time for the row. This timestamp will be the primary index
* that quasardb stores this row under.
* @param values All values for this row.
*/
public WritableRow(Timestamp timestamp, Value[] values) {
this(new Timespec(timestamp), values);
}
/**
* Access to the timestamp of this row.
*
* @return The timestamp, or null if this row does not have a timestamp associated (in case
* of a query result, for example).
*/
public Timespec getTimestamp() {
return this.timestamp;
}
/**
* Comparison-by-value operator.
*
* @return Returns true when the object representations are equal.
*/
@Override
public boolean equals(Object obj) {
if (super.equals(obj) == false) return false;
if (!(obj instanceof WritableRow)) return false;
WritableRow rhs = (WritableRow)obj;
return this.timestamp.equals(rhs.getTimestamp());
}
/**
* Determine whether this row has any null values.
*
* @return Returns true when at least one value is a null value.
*/
public boolean hasNullValues() {
return Arrays.stream(this.values).anyMatch(Value::isNull);
}
public String toString() {
return "WritableRow (timestamp: " + this.timestamp.toString() + ", values = " + Arrays.toString(this.values) + ")";
}
}