* @return True if an event was read.
*/
public boolean advance() {
- /*
- * Index the
- */
/*
* Remove the reader from the top of the priority queue.
*/
}
/**
- * Seeks to a given timestamp It will go to the event just after the
- * timestamp or the timestamp itself. if a if a trace is 10 20 30 40 and
- * you're looking for 19, it'll give you 20, it you want 20, you'll get 20,
- * if you want 21, you'll get 30. You want -inf, you'll get the first
- * element, you want +inf, you'll get the end of the file with no events.
+ * Seeks to a given timestamp. It will seek to the nearest event greater or
+ * equal to timestamp. If a trace is [10 20 30 40] and you are looking for
+ * 19, it will give you 20. If you want 20, you will get 20, if you want 21,
+ * you will get 30. The value -inf will seek to the first element and the
+ * value +inf will seek to the end of the file (past the last event).
*
* @param timestamp
* the timestamp to seek to
- * @return true if the trace has more events following the timestamp
+ * @return true if there are events above or equal the seek timestamp,
+ * false if seek at the end of the trace (no valid event).
*/
public boolean seek(long timestamp) {
/*
/*
* Add it to the priority queue if there is a current event.
*/
-
- }
- for (StreamInputReader streamInputReader : this.streamInputReaders) {
if (streamInputReader.getCurrentEvent() != null) {
this.prio.add(streamInputReader);
-
}
}
return hasMoreEvents();
}
/**
- * gets the stream with the oldest event
+ * Gets the stream with the oldest event
*
* @return the stream with the oldest event
*/
}
/**
- * gets the last event timestamp that was read. This is NOT necessarily the
+ * Gets the last event timestamp that was read. This is NOT necessarily the
* last event in a trace, just the last one read so far.
*
* @return the last event
private boolean isPacketBased(FileChannel metadataFileChannel)
throws CTFReaderException {
/*
- * Create a ByteBuffer to read the TSDL magic number (default is big
- * endian)
+ * Create a ByteBuffer to read the TSDL magic number (default is
+ * big-endian)
*/
ByteBuffer magicByteBuffer = ByteBuffer.allocate(Utils.TSDL_MAGIC_LEN);
return true;
}
- /* Try the same thing, but with little endian */
+ /* Try the same thing, but with little-endian */
magicByteBuffer.order(ByteOrder.LITTLE_ENDIAN);
magic = magicByteBuffer.getInt(0);
}
/**
- * the common streamInput Index
+ * The common streamInput Index
*
* @return the stream input Index
*/
/**
* Gets the filechannel of the streamInput. This is a limited Java
- * ressource.
+ * resource.
*
* @return the filechannel
*/
}
/**
- * gets the last read timestamp of a stream. (this is not necessarily the
+ * Gets the last read timestamp of a stream. (this is not necessarily the
* last time in the stream.)
*
* @return the last read timestamp
}
/**
- * useless for streaminputs
+ * Useless for streaminputs
*/
@Override
public String getPath() {
throw new CTFReaderException(
"CTF magic mismatch " + Integer.toHexString(magic) + " vs " + Integer.toHexString(Utils.CTF_MAGIC)); //$NON-NLS-1$//$NON-NLS-2$
}
-
}
/*
/* Read the end timestamp */
if (tsEnd != null) {
- if( tsEnd == -1 ) {
+ if (tsEnd == -1) {
tsEnd = Long.MAX_VALUE;
}
packetIndex.setTimestampEnd(tsEnd.longValue());
}
/**
- * gets the current packet context
+ * Gets the current packet context
*
* @return the current packet context (size, lost events and such)
*/
if (this.streamInput.addPacketHeaderIndex()) {
packetIndex = getPacketSize() - 1;
this.packetReader.setCurrentPacket(getPacket());
-
} else {
this.packetReader.setCurrentPacket(null);
}
/**
* Changes the location of the trace file reader so that the current event
- * is the first event with a timestamp greater than the given timestamp.
+ * is the first event with a timestamp greater or equal the given timestamp.
*
* @param timestamp
* The timestamp to seek to.
}
/*
- * Advance until A. we reached the end of the trace file (which means
- * the given timestamp is after the last event), or B. we found the
- * first event with a timestamp greater than the given timestamp.
+ * Advance until either of these conditions are met
+ * <ul>
+ * <li> reached the end of the trace file (the given timestamp is after the last event), </li>
+ * <li> found the first event with a timestamp greater or equal the given timestamp. </li>
+ * </ul>
*/
readNextEvent();
boolean done = (this.getCurrentEvent() == null);
}
/**
- * Sets the id of am event declaration
+ * Sets the id of an event declaration
*
* @param id
* the id
}
/**
- * Sets the stream of am event declaration
+ * Sets the stream of an event declaration
*
* @param stream
* the stream
// ------------------------------------------------------------------------
/**
- * Constuctor
+ * Constructor
*
* @param tree
* the tree (ANTLR generated) with the parsed TSDL data.
for (CommonTree child : children) {
String left;
- /* this is a regex to find the leading and trailing quotes*/
+ /* this is a regex to find the leading and trailing quotes */
final String regex = "^\"|\"$"; //$NON-NLS-1$
/* this is to replace the previous quotes with nothing... effectively deleting them */
final String nullString = ""; //$NON-NLS-1$
/**
* Constructor
*
- * @param message (to be sent to logs
+ * @param message to be sent to logs
*/
public ParseException(String message) {
super(message);
public void addEntry(StreamInputPacketIndexEntry entry)
throws CTFReaderException {
assert (entry.getContentSizeBits() != 0);
- assert (entry.getContentSizeBits() != 0);
+ /* Validate consistent entry. */
if (entry.getTimestampBegin() > entry.getTimestampEnd()) {
throw new CTFReaderException("Packet begin timestamp is after end timestamp"); //$NON-NLS-1$
}
+ /* Validate entries are inserted in monotonic increasing timestamp order. */
if (!this.entries.isEmpty()) {
if (entry.getTimestampBegin() < this.entries.lastElement()
.getTimestampBegin()) {
throw new CTFReaderException("Packets begin timestamp decreasing"); //$NON-NLS-1$
}
}
-
this.entries.add(entry);
}
/**
- * This method returns the first packet with the end timestamp greater
- * or equal to the given timestamp. The returned packet is the first one
- * that could include the timestamp.
+ * Returns the first PacketIndexEntry that could include the timestamp,
+ * that is the last packet with a begin timestamp smaller than the given timestamp.
*
* @param timestamp
* The timestamp to look for.
private final HT_IO treeIO;
// ------------------------------------------------------------------------
- // Variable Fields (will change throughout the existance of the SHT)
+ // Variable Fields (will change throughout the existence of the SHT)
// ------------------------------------------------------------------------
/** Latest timestamp found in the tree (at any given moment) */
} else {
setUnknownLocation();
}
-
}
/**
this.advance();
}
} else {
- ret= false;
+ ret = false;
}
/* Seek the current location accordingly */
if (ret) {
} else {
curLocation = NULL_LOCATION;
}
+
return ret;
}
@Override
public void increaseRank() {
/* Only increase the rank if it's valid */
- if(hasValidRank()) {
+ if (hasValidRank()) {
curRank++;
}
}
*
* @param context
* the context to look up
- * @return the iterator refering to the context
+ * @return the iterator referring to the context
*/
public CtfIterator getIterator(final CtfTmfContext context) {
/*
@Override
public void serialize(ByteBuffer bufferOut) {
getLocationInfo().serialize(bufferOut);
-
}
}
public void serialize(ByteBuffer bufferOut) {
bufferOut.putLong(timestamp);
bufferOut.putLong(index);
-
}
}
* @param fileName
* The name of the trace file from which this event comes
* @param cpu
- * The CPU on which this event happend
+ * The CPU on which this event happened
* @param declaration
* The CTF Event Declaration object that created this event
* @param timeRange
return fNbLost;
}
-
}