Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2011 the original author or authors. See the 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 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;
import static org.iq80.leveldb.table.BlockHandle.readBlockHandle;
import static org.iq80.leveldb.table.BlockHandle.writeBlockHandleTo;
import static org.iq80.leveldb.util.SizeOf.SIZE_OF_LONG;
public class Footer
    public static final int ENCODED_LENGTH = (. * 2) + ;
    private final BlockHandle metaindexBlockHandle;
    private final BlockHandle indexBlockHandle;
    Footer(BlockHandle metaindexBlockHandleBlockHandle indexBlockHandle)
        this. = metaindexBlockHandle;
        this. = indexBlockHandle;
        return ;
        return ;
    public static Footer readFooter(Slice slice)
        Preconditions.checkNotNull(slice"slice is null");
        Preconditions.checkArgument(slice.length() == "Expected slice.size to be %s but was %s"slice.length());
        SliceInput sliceInput = slice.input();
        // read metaindex and index handles
        BlockHandle metaindexBlockHandle = readBlockHandle(sliceInput);
        BlockHandle indexBlockHandle = readBlockHandle(sliceInput);
        // skip padding
        sliceInput.setPosition( - );
        // verify magic number
        long magicNumber = sliceInput.readUnsignedInt() | (sliceInput.readUnsignedInt() << 32);
        Preconditions.checkArgument(magicNumber == ."File is not a table (bad magic number)");
        return new Footer(metaindexBlockHandleindexBlockHandle);
    public static Slice writeFooter(Footer Footer)
        Slice slice = Slices.allocate();
        return slice;
    public static void writeFooter(Footer footerSliceOutput sliceOutput)
        // remember the starting write index so we can calculate the padding
        int startingWriteIndex = sliceOutput.size();
        // write metaindex and index handles
        writeBlockHandleTo(footer.getMetaindexBlockHandle(), sliceOutput);
        writeBlockHandleTo(footer.getIndexBlockHandle(), sliceOutput);
        // write padding
        sliceOutput.writeZero( -  - (sliceOutput.size() - startingWriteIndex));
        // write magic number as two (little endian) integers
        sliceOutput.writeInt((int) (. >>> 32));
New to GrepCode? Check out our FAQ X