FileDocCategorySizeDatePackage
Block.javaAPI DocApache Lucene 2.1.02959Wed Feb 14 10:46:08 GMT 2007org.apache.lucene.store.db

Block

public class Block extends Object
author
Andi Vajda

Fields Summary
protected com.sleepycat.db.DatabaseEntry
key
protected com.sleepycat.db.DatabaseEntry
data
Constructors Summary
protected Block(File file)

        byte[] fileKey = file.getKey();

        key = new DatabaseEntry(new byte[fileKey.length + 8]);
        key.setUserBuffer(fileKey.length + 8, true);

        data = new DatabaseEntry(new byte[DbIndexOutput.BLOCK_LEN]);
        data.setUserBuffer(data.getSize(), true);

        System.arraycopy(fileKey, 0, key.getData(), 0, fileKey.length);
        seek(0L);
    
Methods Summary
protected voidget(DbDirectory directory)

        try {
            directory.blocks.get(directory.txn, key, data, directory.flags);
        } catch (DatabaseException e) {
            throw new IOException(e.getMessage());
        }
    
protected byte[]getData()

        return data.getData();
    
protected byte[]getKey()

        return key.getData();
    
protected voidput(DbDirectory directory)

        try {
            directory.blocks.put(directory.txn, key, data, 0);
        } catch (DatabaseException e) {
            throw new IOException(e.getMessage());
        }
    
protected voidseek(long position)

        byte[] data = key.getData();
        int index = data.length - 8;

        position >>>= DbIndexOutput.BLOCK_SHIFT;

        data[index + 0] = (byte) (0xff & (position >>> 56));
        data[index + 1] = (byte) (0xff & (position >>> 48));
        data[index + 2] = (byte) (0xff & (position >>> 40));
        data[index + 3] = (byte) (0xff & (position >>> 32));
        data[index + 4] = (byte) (0xff & (position >>> 24));
        data[index + 5] = (byte) (0xff & (position >>> 16));
        data[index + 6] = (byte) (0xff & (position >>>  8));
        data[index + 7] = (byte) (0xff & (position >>>  0));