Skip to content

Commit

Permalink
Merge pull request #1722 from cmu-phil/development
Browse files Browse the repository at this point in the history
Updating to 7.6.2
  • Loading branch information
jdramsey authored Feb 4, 2024
2 parents 47ed6a7 + 9e91d3a commit 8eb3d34
Show file tree
Hide file tree
Showing 1,164 changed files with 10,009 additions and 9,655 deletions.
10 changes: 5 additions & 5 deletions data-reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<parent>
<groupId>io.github.cmu-phil</groupId>
<artifactId>tetrad</artifactId>
<version>7.6.1</version>
<version>7.6.2-SNAPSHOT</version>
</parent>
<!-- <groupId>io.github.cmu-phil</groupId>-->
<artifactId>data-reader</artifactId>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<build>
Expand All @@ -24,8 +24,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@
*/
public interface ContinuousData extends Data {

/**
* Get the data columns.
*
* @return the data columns.
*/
DataColumn[] getDataColumns();

/**
* Get the data.
*
* @return the data.
*/
double[][] getData();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ public interface DataColumn {
/**
* Get the column's name.
*
* @return
* @return the column's name.
*/
String getName();

/**
* Get the column's number.
*
* @return
* @return the column's number.
*/
int getColumnNumber();

/**
* True if this column was not read in from source such as file.
*
* @return
* @return true if this column was not read in from source such as file.
*/
boolean isGenerated();

/**
* True if the datatype is discrete.
*
* @return
* @return true if the datatype is discrete.
*/
boolean isDiscrete();

/**
* Set true for discrete datatype.
*
* @param discrete
* @param discrete true for discrete datatype.
*/
void setDiscrete(boolean discrete);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public final class DataColumns {
private DataColumns() {
}

/**
* Update data columns with metadata.
*
* @param dataColumns data columns
* @param metadata metadata
* @return updated data columns
*/
public static DataColumn[] update(DataColumn[] dataColumns, Metadata metadata) {
Map<String, ColumnMetadata> columnMetadataMap = DataColumns.getColumnMetadataMap(metadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,52 @@
*/
public abstract class DataFileReader implements DataReader {

/**
* The buffer size for reading data file.
*/
protected static final int BUFFER_SIZE = 1024 * 1024;

/**
* The newline character.
*/
protected static final byte LINE_FEED = '\n';

/**
* The carriage return character.
*/
protected static final byte CARRIAGE_RETURN = '\r';

/**
* The space character.
*/
protected static final byte SPACE_CHAR = Delimiter.SPACE.getByteValue();

/**
* The data file.
*/
protected final Path dataFile;

/**
* The delimiter.
*/
protected final Delimiter delimiter;

/**
* The quote character.
*/
protected byte quoteCharacter;

/**
* The comment marker.
*/
protected String commentMarker;

/**
* Constructor.
*
* @param dataFile the data file
* @param delimiter the delimiter
*/
public DataFileReader(Path dataFile, Delimiter delimiter) {
this.dataFile = dataFile;
this.delimiter = delimiter;
Expand All @@ -52,7 +88,7 @@ public DataFileReader(Path dataFile, Delimiter delimiter) {
* Counts number of column from the first non-blank line.
*
* @return the number of column from the first non-blank line
* @throws IOException
* @throws IOException if an I/O error occurs
*/
protected int countNumberOfColumns() throws IOException {
int count = 0;
Expand Down Expand Up @@ -148,7 +184,7 @@ protected int countNumberOfColumns() throws IOException {
* Counts number of non-blank lines.
*
* @return the number of non-blank and non-commented lines
* @throws IOException
* @throws IOException if an I/O error occurs
*/
protected int countNumberOfLines() throws IOException {
int count = 0;
Expand Down Expand Up @@ -214,13 +250,23 @@ protected int countNumberOfLines() throws IOException {
return count;
}

/**
* Sets the quote character.
*
* @param quoteCharacter the quote character
*/
@Override
public void setQuoteCharacter(char quoteCharacter) {
this.quoteCharacter = Character.isDefined(quoteCharacter)
? (byte) quoteCharacter
: (byte) -1;
}

/**
* Sets the comment marker.
*
* @param commentMarker the comment marker
*/
@Override
public void setCommentMarker(String commentMarker) {
this.commentMarker = (commentMarker == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public interface DataReader {
/**
* Set the character that is used to group multiple words as one.
*
* @param quoteCharacter
* @param quoteCharacter the quote character.
*/
void setQuoteCharacter(char quoteCharacter);

/**
* Set the value to indicate a line is a comment to be ignored.
*
* @param commentMarker
* @param commentMarker the comment marker.
*/
void setCommentMarker(String commentMarker);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
*/
package edu.pitt.dbmi.data.reader;

import java.io.Serial;

/**
* Nov 6, 2018 2:26:59 PM
*
* @author Kevin V. Bui ([email protected])
*/
public class DataReaderException extends RuntimeException {

@Serial
private static final long serialVersionUID = 1123054334542973950L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,28 @@
*/
public abstract class DatasetFileReader extends DataFileReader implements DatasetReader {

/**
* The missing data marker.
*/
protected String missingDataMarker;

/**
* Constructor.
*
* @param dataFile the data file
* @param delimiter the delimiter
*/
public DatasetFileReader(Path dataFile, Delimiter delimiter) {
super(dataFile, delimiter);

this.missingDataMarker = "";
}

/**
* Get the missing data marker.
*
* @param missingDataMarker the missing data marker
*/
@Override
public void setMissingDataMarker(String missingDataMarker) {
this.missingDataMarker = (missingDataMarker == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@
*/
public interface DatasetReader extends DataReader {

/**
* The missing data marker for continuous data.
*/
double CONTINUOUS_MISSING_VALUE = Double.NaN;

/**
* The missing data marker for discrete data.
*/
int DISCRETE_MISSING_VALUE = -99;

/**
* Set the value to indicate missing data.
*
* @param missingDataMarker
* @param missingDataMarker the missing data marker.
*/
void setMissingDataMarker(String missingDataMarker);

Expand Down
48 changes: 48 additions & 0 deletions data-reader/src/main/java/edu/pitt/dbmi/data/reader/Delimiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,80 @@
*/
public enum Delimiter {

/**
* The tab delimiter.
*/
TAB("tab", '\t'),

/**
* The space delimiter.
*/
SPACE("space", ' '),

/**
* The whitespace delimiter.
*/
WHITESPACE("whitespace", ' '),

/**
* The comma delimiter.
*/
COMMA("comma", ','),

/**
* The colon delimiter.
*/
COLON("colon", ':'),

/**
* The semicolon delimiter.
*/
SEMICOLON("semicolon", ';'),

/**
* The pipe delimiter.
*/
PIPE("pipe", '|');

private final String name;
private final char value;
private final byte byteValue;

/**
* Constructor.
*
* @param name the name of the delimiter.
* @param value the value of the delimiter.
*/
Delimiter(String name, char value) {
this.name = name;
this.value = value;
this.byteValue = (byte) value;
}

/**
* Get the name of the delimiter.
*
* @return the name of the delimiter.
*/
public String getName() {
return this.name;
}

/**
* Get the value of the delimiter.
*
* @return the value of the delimiter.
*/
public char getValue() {
return this.value;
}

/**
* Get the byte value of the delimiter.
*
* @return the byte value of the delimiter.
*/
public byte getByteValue() {
return this.byteValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@
*/
public interface DiscreteData extends Data {

/**
* Get the discrete data columns.
*
* @return the discrete data columns.
*/
DiscreteDataColumn[] getDataColumns();

/**
* Get the discrete data.
*
* @return the discrete data.
*/
int[][] getData();

}
Loading

0 comments on commit 8eb3d34

Please sign in to comment.