public RowSetEntry pTree; /* Binary tree of entries */ public RowSet(sqlite3 db, int N) { pChunk = null; this.db = db; pEntry = null; pLast = null; pFresh = new RowSetEntry[N]; pTree = null; nFresh = N; isSorted = true; iBatch = 0; }
public u8 iBatch; /* Current insert batch */ public RowSet(sqlite3 db, int N) { this.pChunk = null; this.db = db; this.pEntry = null; this.pLast = null; this.pFresh = new RowSetEntry[N]; this.pTree = null; this.nFresh = N; this.isSorted = true; this.iBatch = 0; }
/* ** Insert a new value into a RowSet. ** ** The mallocFailed flag of the database connection is set if a ** memory allocation fails. */ private static void sqlite3RowSetInsert(RowSet p, long rowid) { RowSetEntry pEntry; /* The new entry */ RowSetEntry pLast; /* The last prior entry */ Debug.Assert(p != null); if (p.nFresh == 0) { RowSetChunk pNew; pNew = new RowSetChunk(); //sqlite3DbMallocRaw(p.db, sizeof(*pNew)); if (pNew == null) { return; } pNew.pNextChunk = p.pChunk; p.pChunk = pNew; p.pFresh = pNew.aEntry; p.nFresh = ROWSET_ENTRY_PER_CHUNK; } p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; p.nFresh--; pEntry.v = rowid; pEntry.pRight = null; pLast = p.pLast; if (pLast != null) { if (p.isSorted && rowid <= pLast.v) { p.isSorted = false; } pLast.pRight = pEntry; } else { Debug.Assert(p.pEntry == null); /* Fires if INSERT after SMALLEST */ p.pEntry = pEntry; } p.pLast = pEntry; }
public RowSetEntry pTree; /* Binary tree of entries */ #endregion Fields #region Constructors public RowSet( sqlite3 db, int N ) { this.pChunk = null; this.db = db; this.pEntry = null; this.pLast = null; this.pFresh = new RowSetEntry[N]; this.pTree = null; this.nFresh = N; this.isSorted = true; this.iBatch = 0; }
/* ** Insert a new value into a RowSet. ** ** The mallocFailed flag of the database connection is set if a ** memory allocation fails. */ static void sqlite3RowSetInsert( RowSet p, i64 rowid ) { RowSetEntry pEntry; /* The new entry */ RowSetEntry pLast; /* The last prior entry */ Debug.Assert( p != null ); if ( p.nFresh == 0 ) { RowSetChunk pNew; pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew)); if ( pNew == null ) { return; } pNew.pNextChunk = p.pChunk; p.pChunk = pNew; p.pFresh = pNew.aEntry; p.nFresh = ROWSET_ENTRY_PER_CHUNK; } p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry(); pEntry = p.pFresh[p.pFresh.Length - p.nFresh]; p.nFresh--; pEntry.v = rowid; pEntry.pRight = null; pLast = p.pLast; if ( pLast != null ) { if ( p.isSorted && rowid <= pLast.v ) { p.isSorted = false; } pLast.pRight = pEntry; } else { Debug.Assert( p.pEntry == null );/* Fires if INSERT after SMALLEST */ p.pEntry = pEntry; } p.pLast = pEntry; }