use of io.questdb.cairo.map.MapKey in project questdb by bluestreak01.
the class SampleByFillNoneRecordCursor method updateValueWhenClockMovesBack.
@Override
protected void updateValueWhenClockMovesBack(MapValue value, int n) {
final MapKey key = map.withKey();
keyMapSink.copy(baseRecord, key);
super.updateValueWhenClockMovesBack(key.createValue(), n);
}
use of io.questdb.cairo.map.MapKey in project questdb by bluestreak01.
the class SampleByFillPrevRecordCursor method hasNext.
@Override
public boolean hasNext() {
//
if (mapCursor.hasNext()) {
// next() will return record that uses current map position
return true;
}
if (baseRecord == null) {
return false;
}
// the next sample epoch could be different from current sample epoch due to DST transition,
// e.g. clock going backward
// we need to ensure we do not fill time transition
final long expectedLocalEpoch = timestampSampler.nextTimestamp(nextSampleLocalEpoch);
// is data timestamp ahead of next expected timestamp?
if (expectedLocalEpoch < localEpoch) {
this.sampleLocalEpoch = expectedLocalEpoch;
this.nextSampleLocalEpoch = expectedLocalEpoch;
// reset iterator on map and stream contents
map.getCursor().hasNext();
return true;
}
long next = timestampSampler.nextTimestamp(localEpoch);
this.sampleLocalEpoch = localEpoch;
this.nextSampleLocalEpoch = localEpoch;
// looks like we need to populate key map
int n = groupByFunctions.size();
while (true) {
long timestamp = getBaseRecordTimestamp();
if (timestamp < next) {
adjustDSTInFlight(timestamp - tzOffset);
final MapKey key = map.withKey();
keyMapSink.copy(baseRecord, key);
final MapValue value = key.findValue();
assert value != null;
if (value.getLong(0) != localEpoch) {
value.putLong(0, localEpoch);
GroupByUtils.updateNew(groupByFunctions, n, value, baseRecord);
} else {
GroupByUtils.updateExisting(groupByFunctions, n, value, baseRecord);
}
// carry on with the loop if we still have data
if (base.hasNext()) {
interruptor.checkInterrupted();
continue;
}
// we ran out of data, make sure hasNext() returns false at the next
// opportunity, after we stream map that is.
baseRecord = null;
} else {
// timestamp changed, make sure we keep the value of 'lastTimestamp'
// unchanged. Timestamp columns uses this variable
// When map is exhausted we would assign 'next' to 'lastTimestamp'
// and build another map
timestamp = adjustDST(timestamp, n, null, next);
if (timestamp != Long.MIN_VALUE) {
nextSamplePeriod(timestamp);
}
}
return this.map.getCursor().hasNext();
}
}
use of io.questdb.cairo.map.MapKey in project questdb by bluestreak01.
the class SampleByFillPrevRecordCursor method updateValueWhenClockMovesBack.
@Override
protected void updateValueWhenClockMovesBack(MapValue value, int n) {
final MapKey key = map.withKey();
keyMapSink.copy(baseRecord, key);
super.updateValueWhenClockMovesBack(key.createValue(), n);
}
use of io.questdb.cairo.map.MapKey in project questdb by bluestreak01.
the class SampleByInterpolateRecordCursorFactory method findDataMapValue3.
private MapValue findDataMapValue3(Record record, long timestamp) {
final MapKey key = dataMap.withKey();
mapSink2.copy(record, key);
key.putLong(timestamp);
return key.findValue3();
}
use of io.questdb.cairo.map.MapKey in project questdb by bluestreak01.
the class HashOuterJoinRecordCursorFactory method buildMap.
static void buildMap(RecordCursor slaveCursor, Record record, Map joinKeyMap, RecordSink slaveKeySink, RecordChain slaveChain, SqlExecutionInterruptor interruptor) {
joinKeyMap.clear();
slaveChain.clear();
while (slaveCursor.hasNext()) {
interruptor.checkInterrupted();
MapKey key = joinKeyMap.withKey();
key.put(record, slaveKeySink);
MapValue value = key.createValue();
if (value.isNew()) {
long offset = slaveChain.put(record, -1);
value.putLong(0, offset);
value.putLong(1, offset);
} else {
value.putLong(1, slaveChain.put(record, value.getLong(1)));
}
}
}
Aggregations