Examples of LogBuffer


Examples of com.sleepycat.je.log.LogBuffer

         */
        private boolean fillFromLogBuffer(long windowFileNum,
                                          long targetOffset)
            throws DatabaseException {

            LogBuffer logBuffer = null;

            try {
                long fileLocation = DbLsn.makeLsn(windowFileNum, targetOffset);
                logBuffer = logManager.getReadBufferByLsn(fileLocation);
                if (logBuffer == null) {
                    return false;
                }

                /*
                 * Copy at much as we can of the logBuffer into the window's
                 * readBuffer. We don't call ByteBuffer.put(ByteBuffer) because
                 * the logBuffer may be larger than the window readBuffer, and
                 * we don't want to get an overflow. Instead, we convert to an
                 * array and carefully size the copy. A LogBuffer is positioned
                 * for writing, and hasn't yet been flipped.  LogManager.get()
                 * does an absolute retrieval of bytes from the buffer, because
                 * it knows that the log entry exists, and is only reading one
                 * entry. We need to flip the buffer, because we don't know
                 * apriori how much is in the buffer, and we want to scan it.
                 */

                /*
                 * Put the logBuffer's contents into wholeContents, and
                 * position wholeContents at the desired target offset. If
                 * this logBuffer had been the currentWriteBuffer, it's
                 * positioned for writing and must be flipped for reading.
                 */
                ByteBuffer wholeContents =
                    logBuffer.getDataBuffer().duplicate();
                if (wholeContents.position() != 0) {
                    wholeContents.flip();
                }
                long firstOffset =
                    DbLsn.getFileOffset(logBuffer.getFirstLsn());
                wholeContents.position((int) (targetOffset - firstOffset));

                /* Make a buffer which starts at target. */
                ByteBuffer startAtTarget = wholeContents.slice();
                byte[] data = startAtTarget.array();
                int availableContentLen = startAtTarget.limit();
                int copyLength =
                    (availableContentLen > readBuffer.capacity()) ?
                    readBuffer.capacity() : availableContentLen;

                readBuffer.clear();
                readBuffer.put(data, startAtTarget.arrayOffset(), copyLength);
                readBuffer.flip();

                /* LogBuffers were just written and use the current version. */
                setFileNum(windowFileNum, LogEntryType.LOG_VERSION);
                startOffset = targetOffset;
                endOffset = startOffset + readBuffer.limit();
                readBuffer.position(0);
                return true;
            } finally {
                if (logBuffer != null) {
                    logBuffer.release();
                }
            }
        }
View Full Code Here

Examples of com.sleepycat.je.log.LogBuffer

         */
        private boolean fillFromLogBuffer(long windowFileNum,
                                          long targetOffset)
            throws DatabaseException {

            LogBuffer logBuffer = null;

            try {
                long fileLocation = DbLsn.makeLsn(windowFileNum, targetOffset);
                logBuffer = logManager.getReadBufferByLsn(fileLocation);
                if (logBuffer == null) {
                    return false;
                }

                /*
                 * Copy at much as we can of the logBuffer into the window's
                 * readBuffer. We don't call ByteBuffer.put(ByteBuffer) because
                 * the logBuffer may be larger than the window readBuffer, and
                 * we don't want to get an overflow. Instead, we convert to an
                 * array and carefully size the copy. A LogBuffer is positioned
                 * for writing, and hasn't yet been flipped.  LogManager.get()
                 * does an absolute retrieval of bytes from the buffer, because
                 * it knows that the log entry exists, and is only reading one
                 * entry. We need to flip the buffer, because we don't know
                 * apriori how much is in the buffer, and we want to scan it.
                 */

                /*
                 * Put the logBuffer's contents into wholeContents, and
                 * position wholeContents at the desired target offset. If
                 * this logBuffer had been the currentWriteBuffer, it's
                 * positioned for writing and must be flipped for reading.
                 */
                ByteBuffer wholeContents =
                    logBuffer.getDataBuffer().duplicate();
                if (wholeContents.position() != 0) {
                    wholeContents.flip();
                }
                long firstOffset =
                    DbLsn.getFileOffset(logBuffer.getFirstLsn());
                wholeContents.position((int) (targetOffset - firstOffset));

                /* Make a buffer which starts at target. */
                ByteBuffer startAtTarget = wholeContents.slice();
                byte[] data = startAtTarget.array();
                int availableContentLen = startAtTarget.limit();
                int copyLength =
                    (availableContentLen > readBuffer.capacity()) ?
                    readBuffer.capacity() : availableContentLen;

                readBuffer.clear();
                readBuffer.put(data, startAtTarget.arrayOffset(), copyLength);
                readBuffer.flip();

                /* LogBuffers were just written and use the current version. */
                setFileNum(windowFileNum, LogEntryType.LOG_VERSION);
                startOffset = targetOffset;
                endOffset = startOffset + readBuffer.limit();
                readBuffer.position(0);
                return true;
            } finally {
                if (logBuffer != null) {
                    logBuffer.release();
                }
            }
        }
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogBuffer

    public void testSigned()
    {
        byte[] array = { 0, 0, 0, (byte) 0xff };

        LogBuffer buffer = new LogBuffer(array, 0, array.length);

        System.out.println(buffer.getInt32(0));
        System.out.println(buffer.getUint32(0));

        System.out.println(buffer.getInt24(1));
        System.out.println(buffer.getUint24(1));
    }
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogBuffer

    public void testBigInteger()
    {
        byte[] array = { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff };

        LogBuffer buffer = new LogBuffer(array, 0, array.length);

        long tt1 = 0;
        long l1 = 0;
        for (int i = 0; i < LOOP; i++)
        {
            final long t1 = System.nanoTime();
            l1 = buffer.getLong64(0);
            tt1 += System.nanoTime() - t1;
        }
        System.out.print(tt1 / LOOP);
        System.out.print("ns >> ");
        System.out.println(l1);

        long tt2 = 0;
        BigInteger l2 = null;
        for (int i = 0; i < LOOP; i++)
        {
            final long t2 = System.nanoTime();
            l2 = buffer.getUlong64(0);
            tt2 += System.nanoTime() - t2;
        }
        System.out.print(tt2 / LOOP);
        System.out.print("ns >> ");
        System.out.println(l2);
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogBuffer

        do
        {
            System.out.println("new extract decimal: ");

            LogBuffer buffer1 = new LogBuffer(array2, 0, array2.length);
            LogBuffer buffer2 = new LogBuffer(array1, 0, array1.length);
            LogBuffer buffer3 = new LogBuffer(array3, 0, array3.length);
            LogBuffer buffer4 = new LogBuffer(array4, 0, array4.length);
            LogBuffer buffer5 = new LogBuffer(array5, 0, array5.length);

            long tt1 = 0;
            BigDecimal bd1 = null;
            for (int i = 0; i < LOOP; i++)
            {
                final long t1 = System.nanoTime();
                bd1 = buffer1.getDecimal(0, 19, 10);
                tt1 += System.nanoTime() - t1;
            }
            System.out.print(tt1 / LOOP);
            System.out.print("ns >> ");
            System.out.println(bd1);

            long tt2 = 0;
            BigDecimal bd2 = null;
            for (int i = 0; i < LOOP; i++)
            {
                final long t2 = System.nanoTime();
                bd2 = buffer2.getDecimal(0, 19, 10);
                tt2 += System.nanoTime() - t2;
            }
            System.out.print(tt2 / LOOP);
            System.out.print("ns >> ");
            System.out.println(bd2);

            long tt3 = 0;
            BigDecimal bd3 = null;
            for (int i = 0; i < LOOP; i++)
            {
                final long t3 = System.nanoTime();
                bd3 = buffer3.getDecimal(0, 18, 6);
                tt3 += System.nanoTime() - t3;
            }
            System.out.print(tt3 / LOOP);
            System.out.print("ns >> ");
            System.out.println(bd3);

            long tt4 = 0;
            BigDecimal bd4 = null;
            for (int i = 0; i < LOOP; i++)
            {
                final long t4 = System.nanoTime();
                bd4 = buffer4.getDecimal(0, 18, 6);
                tt4 += System.nanoTime() - t4;
            }
            System.out.print(tt4 / LOOP);
            System.out.print("ns >> ");
            System.out.println(bd4);

            long tt5 = 0;
            BigDecimal bd5 = null;
            for (int i = 0; i < LOOP; i++)
            {
                final long t5 = System.nanoTime();
                bd5 = buffer5.getDecimal(0, 18, 6);
                tt5 += System.nanoTime() - t5;
            }
            System.out.print(tt5 / LOOP);
            System.out.print("ns >> ");
            System.out.println(bd5);
View Full Code Here

Examples of edu.stanford.genetics.treeview.LogBuffer

    txtField.setText(TreeViewApp.globalConfigName());
    txtField.setEditable(false);
    JButton testButton = new JButton("Test!");
    testButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        LogBuffer lb = LogBuffer.getSingleton();
        boolean origStatus = lb.getLog();
        lb.setLog(true);
        lb.addObserver(GlobalPrefInfo.this);
        app.getGlobalConfig().getNode("Test").setAttribute("Hello", "Hello", "");
        app.getGlobalConfig().getNode("Test").setAttribute("Hello", "World", "");
        app.getGlobalConfig().store();
       
        lb.deleteObserver(GlobalPrefInfo.this);
        lb.setLog(origStatus);
      }
    });
    msgPanel.add(new JLabel("Global preferences are stored in "));
    msgPanel.add(txtField);
    msgPanel.add(testButton);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.