Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2011 the original author or authors. See the notice.md file distributed with this work for additional information regarding copyright ownership. Licensed 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.
 
 package org.iq80.leveldb.table;
 
 
 public class BlockHandle
 {
     public static final int MAX_ENCODED_LENGTH = 10 + 10;
 
     private final long offset;
     private final int dataSize;
 
     BlockHandle(long offsetint dataSize)
     {
         this. = offset;
         this. = dataSize;
     }
 
     public long getOffset()
     {
         return ;
     }
 
     public int getDataSize()
     {
         return ;
     }
 
     public int getFullBlockSize() {
         return  + .;
     }
 
     @Override
     public boolean equals(Object o)
     {
         if (this == o) {
             return true;
         }
         if (o == null || getClass() != o.getClass()) {
             return false;
         }
 
         BlockHandle that = (BlockHandleo;
 
         if ( != that.offset) {
             return false;
         }
         if ( != that.dataSize) {
             return false;
         }
 
         return true;
     }
 
     @Override
     public int hashCode()
     {
         int result = (int) ( ^ ( >>> 32));
         result = 31 * result + (int) ( ^ ( >>> 32));
         return result;
     }
 
     @Override
     public String toString()
     {
         final StringBuilder sb = new StringBuilder();
         sb.append("BlockHandle");
         sb.append("{offset=").append();
         sb.append(", dataSize=").append();
         sb.append('}');
         return sb.toString();
     }
 
     public static BlockHandle readBlockHandle(SliceInput sliceInput)
     {
         long offset = VariableLengthQuantity.readVariableLengthLong(sliceInput);
         long size = VariableLengthQuantity.readVariableLengthLong(sliceInput);
 
         if (size > .) {
            throw new IllegalArgumentException("Blocks can not be larger than Integer.MAX_VALUE");
        }
        return new BlockHandle(offset, (intsize);
    }
    public static Slice writeBlockHandle(BlockHandle blockHandle)
    {
        Slice slice = Slices.allocate();
        SliceOutput sliceOutput = slice.output();
        writeBlockHandleTo(blockHandlesliceOutput);
        return slice.slice();
    }
    public static void writeBlockHandleTo(BlockHandle blockHandleSliceOutput sliceOutput)
    {
        VariableLengthQuantity.writeVariableLengthLong(blockHandle.offsetsliceOutput);
        VariableLengthQuantity.writeVariableLengthLong(blockHandle.dataSizesliceOutput);
    }
New to GrepCode? Check out our FAQ X