/** Expert: Called after all values are written to a row. */ public void endRow() throws IOException { for (int column = 0; column < columnCount; column++) columns[column].endRow(); rowCount++; }
public long size() throws IOException { flushBuffer(); return size; }
private long[] computeStarts(long start) throws IOException { long[] result = new long[columnCount]; start += columnCount * 8; // room for starts for (int column = 0; column < columnCount; column++) { result[column] = start; start += columns[column].size(); } return result; }
/** Expert: Declare a count of items to be written to an array column or a * column whose parent is an array. */ public void writeLength(int length, int column) throws IOException { columns[column].writeLength(length); }
private void writeHeader(OutputStream out) throws IOException { OutputBuffer header = new OutputBuffer(); header.write(MAGIC); // magic header.writeFixed64(rowCount); // row count header.writeFixed32(columnCount); // column count metaData.write(header); // file metadata for (ColumnOutputBuffer column : columns) column.getMeta().write(header); // column metadata for (long start : computeStarts(header.size())) header.writeFixed64(start); // column starts header.writeTo(out); }
/** Expert: Called before any values are written to a row. */ public void startRow() throws IOException { for (int column = 0; column < columnCount; column++) columns[column].startRow(); }
/** Expert: Add a value to a row. For values in array columns or whose * parents are array columns, this must be preceded by a call to {@link * #writeLength(int, int)} and must be called that many times. For normal * columns this is called once for each row in the column. */ public void writeValue(Object value, int column) throws IOException { columns[column].writeValue(value); }
/** Write all rows added to the named output stream. */ public void writeTo(OutputStream out) throws IOException { writeHeader(out); for (int column = 0; column < columnCount; column++) columns[column].writeTo(out); }
/** Construct given metadata for each column in the file. */ public ColumnFileWriter(ColumnFileMetaData fileMeta, ColumnMetaData... columnMeta) throws IOException { checkColumns(columnMeta); this.metaData = fileMeta; this.columnCount = columnMeta.length; this.columns = new ColumnOutputBuffer[columnCount]; for (int i = 0; i < columnCount; i++) { ColumnMetaData c = columnMeta[i]; c.setDefaults(metaData); columns[i] = c.isArray() ? new ArrayColumnOutputBuffer(this, c) : new ColumnOutputBuffer(this, c); size += OutputBuffer.BLOCK_SIZE; // over-estimate } }
/** Expert: Declare a count of items to be written to an array column or a * column whose parent is an array. */ public void writeLength(int length, int column) throws IOException { columns[column].writeLength(length); }
private void writeHeader(OutputStream out) throws IOException { OutputBuffer header = new OutputBuffer(); header.write(MAGIC); // magic header.writeFixed64(rowCount); // row count header.writeFixed32(columnCount); // column count metaData.write(header); // file metadata for (ColumnOutputBuffer column : columns) column.getMeta().write(header); // column metadata for (long start : computeStarts(header.size())) header.writeFixed64(start); // column starts header.writeTo(out); }
/** Expert: Called before any values are written to a row. */ public void startRow() throws IOException { for (int column = 0; column < columnCount; column++) columns[column].startRow(); }
/** Expert: Add a value to a row. For values in array columns or whose * parents are array columns, this must be preceded by a call to {@link * #writeLength(int, int)} and must be called that many times. For normal * columns this is called once for each row in the column. */ public void writeValue(Object value, int column) throws IOException { columns[column].writeValue(value); }
/** Write all rows added to the named output stream. */ public void writeTo(OutputStream out) throws IOException { writeHeader(out); for (int column = 0; column < columnCount; column++) columns[column].writeTo(out); }
/** Construct given metadata for each column in the file. */ public ColumnFileWriter(ColumnFileMetaData fileMeta, ColumnMetaData... columnMeta) throws IOException { checkColumns(columnMeta); this.metaData = fileMeta; this.columnCount = columnMeta.length; this.columns = new ColumnOutputBuffer[columnCount]; for (int i = 0; i < columnCount; i++) { ColumnMetaData c = columnMeta[i]; c.setDefaults(metaData); columns[i] = c.isArray() ? new ArrayColumnOutputBuffer(this, c) : new ColumnOutputBuffer(this, c); size += OutputBuffer.BLOCK_SIZE; // over-estimate } }
public void startRow() throws IOException { if (buffer.isFull()) flushBuffer(); }
/** Expert: Called after all values are written to a row. */ public void endRow() throws IOException { for (int column = 0; column < columnCount; column++) columns[column].endRow(); rowCount++; }
private long[] computeStarts(long start) throws IOException { long[] result = new long[columnCount]; start += columnCount * 8; // room for starts for (int column = 0; column < columnCount; column++) { result[column] = start; start += columns[column].size(); } return result; }
@Override void flushBuffer() throws IOException { flushRun(); super.flushBuffer(); }
public long size() throws IOException { flushBuffer(); return size; }