Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.apache.lucene.store.db;

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 
 
 
 
 public class DbIndexOutput extends IndexOutput {

    
The size of data blocks, currently 16k (2^14), is determined by this constant.
 
     static public final int BLOCK_SHIFT = 14;
     static public final int BLOCK_LEN = 1 << ;
     static public final int BLOCK_MASK =  - 1;
 
     protected long position = 0L, length = 0L;
     protected DbDirectory directory;
     protected Block block;
     protected File file;
 
     protected DbIndexOutput(DbDirectory directoryString nameboolean create)
         throws IOException
     {
         super();
 
         this. = directory;
 
          = new File(directorynamecreate);
          = new Block();
          = .getLength();
 
         seek();
         .get(directory);
 
         directory.openFiles.add(this);
     }
 
     @Override
     public void close()
         throws IOException
     {
         flush();
         .modify(, System.currentTimeMillis());
 
         ..remove(this);
     }
 
     @Override
     public void flush()
         throws IOException
     {
         if ( > 0)
             .put();
     }
 
     @Override
     public void writeByte(byte b)
         throws IOException
     {
         int blockPos = (int) (++ & );
 
         .getData()[blockPos] = b;
 
         if (blockPos + 1 == )
         {
             .put();
             .seek();
             .get();
         }
 
         if ( > )
              = ;
     }
 
     @Override
     public void writeBytes(byte[] bint offsetint len)
         throws IOException
     {
         int blockPos = (int) ( & );
        while (blockPos + len >= ) {
            int blockLen =  - blockPos;
            System.arraycopy(boffset.getData(), blockPosblockLen);
            .put();
            len -= blockLen;
            offset += blockLen;
             += blockLen;
            .seek();
            .get();
            blockPos = 0;
        }
        if (len > 0)
        {
            System.arraycopy(boffset.getData(), blockPoslen);
             += len;
        }
        if ( > )
             = ;
    }
    @Override
    public long length()
        throws IOException
    {
        return ;
    }
    @Override
    public void seek(long pos)
        throws IOException
    {
        if (pos > )
            throw new IOException("seeking past end of file");
        if ((pos >>> ) == ( >>> ))
             = pos;
        else
        {
            .put();
            .seek(pos);
            .get();
             = pos;
        }
    }
    @Override
    public long getFilePointer()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X