private void readColumnMetaData(InputBuffer in) throws IOException { for (int i = 0; i < columnCount; i++) { ColumnMetaData meta = ColumnMetaData.read(in, this); meta.setDefaults(this.metaData); ColumnDescriptor column = new ColumnDescriptor(file, meta); columns[i] = column; meta.setNumber(i); columnsByName.put(meta.getName(), column); } }
@Override public boolean hasNext() { return block < column.blockCount()-1 || row < column.lastRow(block); }
/** Seek to the named row. */ public void seek(long r) throws IOException { if (r < row || r >= column.lastRow(block)) // not in current block startBlock(column.findBlock(r)); // seek to block start while (r > row && hasNext()) { // skip within block values.skipValue(type); row++; } previous = null; }
/** Seek to the named value. */ public void seek(T v) throws IOException { if (!column.metaData.hasIndexValues()) throw new TrevniRuntimeException ("Column does not have value index: " +column.metaData.getName()); if (previous == null // not in current block? || previous.compareTo(v) > 0 || (block != column.blockCount()-1 && column.firstValues[block+1].compareTo(v) <= 0)) startBlock(column.findBlock(v)); // seek to block start while (hasNext()) { // scan block long savedPosition = values.tell(); T savedPrevious = previous; if (next().compareTo(v) >= 0) { values.seek(savedPosition); previous = savedPrevious; row--; return; } } }
ColumnValues(ColumnDescriptor column) throws IOException { this.column = column; this.type = column.metaData.getType(); this.codec = Codec.get(column.metaData); this.checksum = Checksum.get(column.metaData); this.in = new InputBuffer(column.file); column.ensureBlocksRead(); }
/** Seek to the named value. */ public void seek(T v) throws IOException { if (!column.metaData.hasIndexValues()) throw new TrevniRuntimeException ("Column does not have value index: " +column.metaData.getName()); if (previous == null // not in current block? || previous.compareTo(v) > 0 || (block != column.blockCount()-1 && column.firstValues[block+1].compareTo(v) <= 0)) startBlock(column.findBlock(v)); // seek to block start while (hasNext()) { // scan block long savedPosition = values.tell(); T savedPrevious = previous; if (next().compareTo(v) >= 0) { values.seek(savedPosition); previous = savedPrevious; row--; return; } } }
ColumnValues(ColumnDescriptor column) throws IOException { this.column = column; this.type = column.metaData.getType(); this.codec = Codec.get(column.metaData); this.checksum = Checksum.get(column.metaData); this.in = new InputBuffer(column.file); column.ensureBlocksRead(); }
/** Expert: Must be called before any calls to {@link #nextLength()} or * {@link #nextValue()}. */ public void startRow() throws IOException { if (row >= column.lastRow(block)) { if (block >= column.blockCount()) throw new TrevniRuntimeException("Read past end of column."); startBlock(block+1); } row++; }
/** Seek to the named row. */ public void seek(long r) throws IOException { if (r < row || r >= column.lastRow(block)) // not in current block startBlock(column.findBlock(r)); // seek to block start while (r > row && hasNext()) { // skip within block values.skipValue(type); row++; } previous = null; }
private void readColumnMetaData(InputBuffer in) throws IOException { for (int i = 0; i < columnCount; i++) { ColumnMetaData meta = ColumnMetaData.read(in, this); meta.setDefaults(this.metaData); ColumnDescriptor column = new ColumnDescriptor(file, meta); columns[i] = column; meta.setNumber(i); columnsByName.put(meta.getName(), column); } }
@Override public boolean hasNext() { return block < column.blockCount()-1 || row < column.lastRow(block); }
/** Expert: Must be called before any calls to {@link #nextLength()} or * {@link #nextValue()}. */ public void startRow() throws IOException { if (row >= column.lastRow(block)) { if (block >= column.blockCount()) throw new TrevniRuntimeException("Read past end of column."); startBlock(block+1); } row++; }