public RawTableRecord(TableRecordInfoDigest info) { this.digest = info; this.buf = new byte[info.getByteFormLen()]; reset(); }
@Override public RawTableRecord next() { for (int col = 0; col < nColumns; col++) { containers[col].getValueAt(i, temp); rec.setValueBytes(col, temp); } i++; return rec; }
public Slice(TableRecordInfoDigest digest, short shard, long timestamp, ColumnValueContainer[] containers) { this.info = digest; this.nColumns = digest.getColumnCount(); this.shard = shard; this.timestamp = timestamp; this.nRecords = containers[0].getSize(); this.containers = containers; assert nColumns == containers.length; for (int i = 0; i < nColumns; i++) { assert nRecords == containers[i].getSize(); } }
@Override public int getColumnLength(TblColRef col) { int index = getTableRecordInfo().findColumn(col); return getTableRecordInfo().getDigest().length(index); }
public void setValueString(int col, String value) { if (rawRecord.isMetric(col)) { LongWritable v = rawRecord.codec(col).valueOf(value); setValueMetrics(col, v); } else { int id = info.dict(col).getIdFromValue(value); rawRecord.setValueID(col, id); } }
public TableRecord createTableRecord() { return new TableRecord(digest.createTableRecordBytes(), this); }
private TableRecordInfo getTableRecordInfo() { if (tableRecordInfo == null) tableRecordInfo = new TableRecordInfo(this); return tableRecordInfo; }
/** * get value of columns which belongs to the original table columns. * i.e. columns like min_xx, max_yy will never appear */ public String getValueString(int col) { if (rawRecord.isMetric(col)) return getValueMetric(col); else return info.dict(col).getValueFromId(rawRecord.getValueID(col)); }
private void addContainer(int col, ColumnValueContainer c) { if (containers == null) { containers = new ColumnValueContainer[info.getColumnCount()]; } containers[col] = c; }
public ShardingSliceBuilder(TableRecordInfo info) { int sharding = info.getDescriptor().getSharding(); builders = new SliceBuilder[sharding]; for (short i = 0; i < sharding; i++) { builders[i] = new SliceBuilder(info, i); } }
@Override public int compare(TableRecord a, TableRecord b) { long x = a.getTimestamp() - b.getTimestamp(); if (x > 0) return 1; else if (x == 0) return 0; else return -1; } });
@Override public int getMaxValueId(TblColRef col) { return slice.getColumnValueContainer(type.getColIndexByTblColRef(col)).getMaxValueId(); } }
@Override public String toString() { StringBuilder buf = new StringBuilder("["); for (int col = 0; col < rawRecord.getColumnCount(); col++) { if (col > 0) buf.append(","); buf.append(getValueString(col)); } buf.append("]"); return buf.toString(); }
public int getMetricCount() { int ret = 0; for (int i = 0; i < nColumns; ++i) { if (isMetrics(i)) { ret++; } } return ret; }
@Override public int hashCode() { if (rawRecord != null) { return rawRecord.hashCode(); } else { return 0; } }
public Slice close() { Slice doneSlice = doneSlice(); this.sliceTimestamp = Long.MIN_VALUE; this.nRecords = 0; return doneSlice; }
private ConciseSet getBitMap(int valueId) { if (valueId >= 0 && valueId <= getMaxValueId()) return sets[valueId]; else return sets[this.nValues]; }