Package org.tmatesoft.sqljet.core.internal

Examples of org.tmatesoft.sqljet.core.internal.ISqlJetMemoryPointer


        final ISqlJetMemoryPointer b = SqlJetUtility.put4byte(val);
        fd.write(b, b.remaining(), offset);
    }

    static void write32bitsUnsigned(ISqlJetFile fd, long offset, long val) throws SqlJetIOException {
        final ISqlJetMemoryPointer b = SqlJetUtility.put4byteUnsigned(val);
        fd.write(b, b.remaining(), offset);
    }
View Full Code Here


     */
    private void writeJournalHdr() throws SqlJetException {

        SqlJetException rc = null;

        ISqlJetMemoryPointer zHeader = tmpSpace;
        int nHeader = pageSize;
        int nWrite;
        int ii;

        if (nHeader > JOURNAL_HDR_SZ()) {
View Full Code Here

                long offset = (page.getPageNumber() - 1) * pageSize;

                PAGERTRACE("STORE %s page %d hash(%08x)\n", PAGERID(), pList.getPageNumber(), pageHash(pList));

                ISqlJetMemoryPointer pData = page.getData();

                fd.write(pData, pageSize, offset);
                if (page.getPageNumber() == 1) {
                    SqlJetUtility.memcpy(dbFileVers, 0, pData, 24, dbFileVers.remaining());
                }
View Full Code Here

        int len;
        int i;
        long jrnlOff;
        long jrnlSize;
        int cksum = 0;
        ISqlJetMemoryPointer zBuf = SqlJetUtility.allocatePtr(aJournalMagic.remaining() + 2 * 4);

        if (null == master || setMaster)
            return;
        if (journalMode == SqlJetPagerJournalMode.MEMORY)
            return;

        setMaster = true;

        final ISqlJetMemoryPointer zMaster = SqlJetUtility.wrapPtr(master.getBytes());

        len = zMaster.remaining();
        for (i = 0; i < len; i++) {
            cksum += SqlJetUtility.getUnsignedByte(zMaster, i);
        }

        /*
 
View Full Code Here

    }

    public byte[] getBlobAsArray(final String fieldName) throws SqlJetException {
        return (byte[]) db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                ISqlJetMemoryPointer buffer = getBtreeDataTable().getBlob(getFieldSafe(fieldName));
                return buffer != null ? SqlJetUtility.readByteBuffer(buffer) : null;
            }
        });
    }
View Full Code Here

    }

    public InputStream getBlobAsStream(final String fieldName) throws SqlJetException {
        return (InputStream) db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                ISqlJetMemoryPointer buffer = getBtreeDataTable().getBlob(getFieldSafe(fieldName));
                return buffer != null ? new ByteArrayInputStream(SqlJetUtility.readByteBuffer(buffer)) : null;
            }
        });
    }
View Full Code Here

     * @param row
     * @return
     * @throws SqlJetException
     */
    private void doInsert(SqlJetConflictAction onConflict, final long rowId, final Object[] row) throws SqlJetException {
        final ISqlJetMemoryPointer pData;
        final SqlJetEncoding encoding = btree.getDb().getOptions().getEncoding();
        if (!tableDef.isRowIdPrimaryKey()) {
            pData = SqlJetBtreeRecord.getRecord(encoding, row).getRawRecord();
        } else {
            final int primaryKeyColumnNumber = tableDef.getColumnNumber(tableDef.getRowIdPrimaryKeyColumnName());
            if (primaryKeyColumnNumber == -1 || primaryKeyColumnNumber >= row.length)
                throw new SqlJetException(SqlJetErrorCode.ERROR);
            row[primaryKeyColumnNumber] = null;
            pData = SqlJetBtreeRecord.getRecord(encoding, row).getRawRecord();
            row[primaryKeyColumnNumber] = rowId;
        }
        if (doActionWithIndexes(Action.INSERT, onConflict, rowId, row)) {
            getCursor().insert(null, rowId, pData, pData.remaining(), 0, true);
            goToRow(rowId);
        }
    }
View Full Code Here

        final Object[] rowCompleted = completeRow(row, currentRow);

        if (newRowId == currentRowId && Arrays.equals(rowCompleted, currentRow))
            return;

        final ISqlJetMemoryPointer pData;
        final SqlJetEncoding encoding = btree.getDb().getOptions().getEncoding();
        if (!tableDef.isRowIdPrimaryKey()) {
            pData = SqlJetBtreeRecord.getRecord(encoding, rowCompleted).getRawRecord();
        } else {
            final int primaryKeyColumnNumber = tableDef.getColumnNumber(tableDef.getRowIdPrimaryKeyColumnName());
            if (primaryKeyColumnNumber == -1 || primaryKeyColumnNumber >= rowCompleted.length)
                throw new SqlJetException(SqlJetErrorCode.ERROR);
            rowCompleted[primaryKeyColumnNumber] = null;
            pData = SqlJetBtreeRecord.getRecord(encoding, rowCompleted).getRawRecord();
            rowCompleted[primaryKeyColumnNumber] = newRowId;
        }
        if (doActionWithIndexes(Action.UPDATE, onConflict, newRowId, rowCompleted)) {
            final boolean changeRowId = newRowId != currentRowId;
            if (changeRowId) {
                getCursor().delete();
            }
            getCursor().insert(null, newRowId, pData, pData.remaining(), 0, changeRowId);
            goToRow(newRowId);
        }

    }
View Full Code Here

     * @throws SqlJetException
     */
    private long lookupSafe(boolean next, boolean near, boolean last, Object... values) throws SqlJetException {
        final SqlJetEncoding encoding = btree.getDb().getOptions().getEncoding();
        ISqlJetBtreeRecord key = SqlJetBtreeRecord.getRecord(encoding, values);
        final ISqlJetMemoryPointer k = key.getRawRecord();
        if (next) {
            if (!last) {
                next();
            } else {
                previous();
View Full Code Here

        return unpacked.recordCompare(record.remaining(), record);
    }

    public int compareKeys(Object[] firstKey, Object[] lastKey) throws SqlJetException {
        final SqlJetEncoding encoding = btree.getDb().getOptions().getEncoding();
        final ISqlJetMemoryPointer firstRec = SqlJetBtreeRecord.getRecord(encoding, firstKey).getRawRecord();
        final ISqlJetMemoryPointer lastRec = SqlJetBtreeRecord.getRecord(encoding, lastKey).getRawRecord();
        final SqlJetUnpackedRecord unpacked = getKeyInfo().recordUnpack(firstRec.remaining(), firstRec);
        unpacked.getFlags().add(SqlJetUnpackedRecordFlags.PREFIX_MATCH);
        return unpacked.recordCompare(lastRec.remaining(), lastRec);
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.internal.ISqlJetMemoryPointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.