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 DbIndexInput extends IndexInput {
 
     protected long position = 0L, length = 0L;
     protected DbDirectory directory;
     protected Block block;
     protected File file;
 
     protected DbIndexInput(DbDirectory directoryString name)
         throws IOException
     {
         super();
 
         this. = directory;
 
         this. = new File(name);
         if (!.exists(directory))
             throw new IOException("File does not exist: " + name);
 
          = .getLength();
 
          = new Block();
         .get(directory);
     }
 
     @Override
     public Object clone()
     {
         try {
             DbIndexInput clone = (DbIndexInputsuper.clone();
 
             clone.block = new Block();
             clone.block.seek();
             clone.block.get();
 
             return clone;
         } catch (IOException e) {
             throw new RuntimeException(e.getMessage());
         }
     }
 
     @Override
     public void close()
         throws IOException
     {
     }
 
     @Override
     public long length()
     {
         return ;
     }
 
     @Override
     public byte readByte()
         throws IOException
     {
         if ( + 1 > )
             throw new IOException("Reading past end of file");
 
         int blockPos = (int) (++ & .);
         byte b = .getData()[blockPos];
 
         if (blockPos + 1 == .)
         {
             .seek();
             .get();
         }
 
         return b;
     }
 
     @Override
     public void readBytes(byte[] bint offsetint len)
         throws IOException
    {
        if ( + len > )
            throw new IOException("Reading past end of file");
        else
        {
            int blockPos = (int) ( & .);
            while (blockPos + len >= .) {
                int blockLen = . - blockPos;
                System.arraycopy(.getData(), blockPos,
                                 boffsetblockLen);
                len -= blockLen;
                offset += blockLen;
                 += blockLen;
                .seek();
                .get();
                blockPos = 0;
            }
            if (len > 0)
            {
                System.arraycopy(.getData(), blockPosboffsetlen);
                 += len;
            }
        }
    }
    @Override
    public void seek(long pos)
        throws IOException
    {
        if (pos > )
            throw new IOException("seeking past end of file");
        if ((pos >>> .) !=
            ( >>> .))
        {
            .seek(pos);
            .get();
        }
         = pos;
    }
    @Override
    public long getFilePointer()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X