Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/add_comment' into add_comment
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/cn/edu/tsinghua/tsfile/timeseries/read/PageReader.java
  • Loading branch information
mdf369 committed Nov 6, 2018
2 parents c03cc3c + e46c4b5 commit eabf414
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
* PageReader is used to read a page in a column.
*/
public class PageReader {
/** ByteArrayInputStream that contains some Pages, this PageReader read from it **/

// constructed when reading one column data in one rowGroup
private ByteArrayInputStream bis;
/** current PageHeader **/

// PageHeader of the page to be read
private PageHeader pageHeader = null;
/** UnCompressor for Page **/

// used to uncompress the page
private UnCompressor unCompressor = null;

/**
Expand All @@ -42,9 +45,9 @@ public boolean hasNextPage() {
}

/**
* get next PageHeader
* @return
* @throws IOException
* get next PageHeader from cache or read from disk
* @return next PageHeader
* @throws IOException exception in reading PageHeader
*/
public PageHeader getNextPageHeader() throws IOException {
// if current PageHeader exists, return it
Expand All @@ -60,20 +63,24 @@ public PageHeader getNextPageHeader() throws IOException {
return null;
}


/**
* get next Page
* @return
* @throws IOException
* read next page(PageHeader, Page data) from disk
* @return uncompressed page data in a stream
* @throws IOException exception when read page from disk
*/
public ByteArrayInputStream getNextPage() throws IOException {
if (bis.available() > 0) {
// get PageHeader first
pageHeader = getNextPageHeader();
// read Page in bytes array form
int pageSize = pageHeader.getCompressed_page_size();

// the raw data read from disk
byte[] pageContent = new byte[pageSize];
bis.read(pageContent, 0, pageSize);
// uncompress

// uncompress the raw data
pageContent = unCompressor.uncompress(pageContent);
// reset current PageHeader to null
pageHeader = null;
Expand All @@ -95,7 +102,7 @@ public void readPage(InputStream in, byte[] buf, int pageSize) throws IOExceptio
}

/**
* skip next page
* skip the current page to next page
*/
public void skipCurrentPage() {
long skipSize = this.pageHeader.getCompressed_page_size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cn.edu.tsinghua.tsfile.timeseries.write.exception;

/**
* This exception is throw if the json of schema in writing process is invalid, like missing necessary fields.
* This exception is throw if the file schema in json format is invalid, like missing necessary fields.
*
* @author kangrong
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package cn.edu.tsinghua.tsfile.timeseries.write.exception;

/**
* This exception means it finds a data point's measurement doesn't exist while writing a TSRecord
*
* @author kangrong
* This exception means it can not find the measurement while writing a TSRecord
*/
public class NoMeasurementException extends WriteProcessException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package cn.edu.tsinghua.tsfile.timeseries.write.exception;

/**
* This exception means the the page size exceeding threshold what user setting.
*
* @author kangrong
* Exception occurs when writing a page
*/
public class PageException extends WriteProcessException {

Expand Down

0 comments on commit eabf414

Please sign in to comment.