Class Stream

java.lang.Object
dev.frostlake.metastore.model.Stream

public class Stream extends Object
Represents a Snowflake Stream - Change Data Capture (CDC) mechanism Streams record DML changes (INSERT, UPDATE, DELETE) made to a table
  • Constructor Details

  • Method Details

    • isAppend

      public static boolean isAppend(StreamRecord record)
      Whether a change record APPENDED a row: an INSERT that no UPDATE produced. The insert half of an update pair carries the same change type and is deliberately not an append — live-verified, a row that already existed contributes nothing to an append-only view however often it is rewritten.
    • addRecord

      public void addRecord(StreamRecord record)
    • getUnconsumedRecords

      public List<StreamRecord> getUnconsumedRecords()
    • getUnconsumedNetRecords

      public List<StreamRecord> getUnconsumedNetRecords()
      The unconsumed change records consolidated to the NET delta per logical row, which is what a SELECT from a stream returns in Snowflake: a row inserted then updated inside the window is a single INSERT of its final image (ISUPDATE false); inserted then deleted cancels out entirely; a pre-existing row updated repeatedly nets to one DELETE(original)+INSERT(final) pair (ISUPDATE true); updated then deleted nets to a plain DELETE of the original image. Logical rows are chained by value image (an update pair's DELETE half matches the entry whose current image it removes), since change records carry per-operation — not per-row — ids. APPEND_ONLY streams record only true INSERTs, so they are returned as-is.
    • getUnconsumedNetRecordsWith

      public List<StreamRecord> getUnconsumedNetRecordsWith(List<StreamRecord> extraRaw)
      The net unconsumed records as getUnconsumedNetRecords(), but with extraRaw transient change records (e.g. the current transaction's not-yet-committed base-table changes) folded in AFTER the committed unconsumed ones, so a stream read inside a transaction reflects that transaction's own uncommitted DML — the deferred-apply equivalent of read-your-writes for streams. The extras are never added to the stream, so a rollback (which just discards the write set) needs no undo here. Extras that an addRecord(dev.frostlake.metastore.model.StreamRecord) would drop (an APPEND_ONLY stream keeps only true INSERTs) are filtered the same way before consolidation.
    • getUnconsumedAppendsWith

      public List<StreamRecord> getUnconsumedAppendsWith(List<StreamRecord> extraRaw)
      The unconsumed records that APPENDED a row, in the order the appends happened, with the values each row was appended WITH — the append-only view of the change window.

      This is not the net delta filtered to its inserts, and the difference is visible three ways, all live-verified: a row inserted and then updated inside the window reports the value it was inserted with rather than its current one; a row inserted and then deleted inside the window is still reported, because a later delete does not un-append it; and a row that already existed reports nothing however it is rewritten, because rewriting is not appending.

      extraRaw folds in transient records the same way getUnconsumedNetRecordsWith(java.util.List<dev.frostlake.metastore.model.StreamRecord>) does.

    • consume

      public void consume()
    • recordCount

      public long recordCount()
      Total records ever captured (consumed + unconsumed) — the read-time cut for scoped consumption.
    • consumeSeen

      public void consumeSeen(long committedCut, List<StreamRecord> seenTransient)
      Consume exactly what a reader SAW, not everything present at commit: advance past the committed prefix visible at read time (committedCut records) and remove the records this transaction's commit re-emitted for changes that were already buffered when the read happened (seenTransient — matched by change kind, values and capture tag, at or after the cut). Records appended after the read — by another transaction, or by this transaction's own LATER DML — stay unconsumed. This mirrors Snowflake, where the common flush-then-load procedure pattern runs each statement in its own autocommit transaction: a mid-procedure stream flush must not consume rows the procedure inserts after it.
    • reset

      public void reset()
    • getBaseTableName

      public String getBaseTableName()
      First base table, or null if none — kept for callers and persistence that assume a single table.
    • setBaseTableName

      public void setBaseTableName(String baseTableName)
    • getBaseTableNames

      public List<String> getBaseTableNames()
      All base tables backing a VIEW-sourced stream (one per UNION ALL branch); empty for table streams.
    • setBaseTableNames

      public void setBaseTableNames(List<String> names)
    • getName

      public String getName()
    • getOwner

      public String getOwner()
    • setOwner

      public void setOwner(String owner)
    • getSourceTableName

      public String getSourceTableName()
    • getSourceType

      public StreamSourceType getSourceType()
    • getStreamType

      public StreamType getStreamType()
    • isShowInitialRows

      public boolean isShowInitialRows()
    • getRecords

      public List<StreamRecord> getRecords()
    • getCreatedAt

      public LocalDateTime getCreatedAt()
    • getCurrentOffset

      public long getCurrentOffset()
    • isStale

      public boolean isStale()
    • setStale

      public void setStale(boolean stale)
    • getUnconsumedCount

      public int getUnconsumedCount()
    • getComment

      public String getComment()
    • setComment

      public void setComment(String comment)