// Path: src/main/java/com/jordanwilliams/heftydb/data/Key.java
// public class Key implements Comparable<Key> {
// 
//     private final ByteBuffer data;
//     private final long snapshotId;
// 
//     public Key(ByteBuffer data, long snapshotId) {
//         this.data = data;
//         this.snapshotId = snapshotId;
//     }
// 
//     public ByteBuffer data() {
//         return data;
//     }
// 
//     public long snapshotId() {
//         return snapshotId;
//     }
// 
//     public int size() {
//         return data.capacity();
//     }
// 
//     @Override
//     public int compareTo(Key o) {
//         int compared = data.compareTo(o.data);
// 
//         if (compared != 0) {
//             return compared;
//         }
// 
//         return Long.compare(snapshotId, o.snapshotId);
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Key key = (Key) o;
// 
//         if (snapshotId != key.snapshotId) return false;
//         if (data != null ? !data.equals(key.data) : key.data != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return data != null ? data.hashCode() : 0;
//     }
// 
//     @Override
//     public String toString() {
//         byte[] keyArray = new byte[data.capacity()];
//         data.rewind();
//         data.get(keyArray);
//         data.rewind();
// 
//         return "Key{" +
//                 "data=" + new String(keyArray) +
//                 ", snapshotId=" + snapshotId +
//                 '}';
//     }
// }
// 
// Path: src/main/java/com/jordanwilliams/heftydb/util/Sizes.java
// public class Sizes {
// 
//     public static int LONG_SIZE = 8;
// 
//     public static int INT_SIZE = 4;
// }


import com.jordanwilliams.heftydb.data.Key;
import com.jordanwilliams.heftydb.util.Sizes;
/*
 * Copyright (c) 2014. Jordan Williams
 *
 * 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 com.jordanwilliams.heftydb.index;


/**
 * Represents a single entry in an IndexBlock.
 */
public class IndexRecord {

    private final Key startKey;
    private final long blockOffset;
    private final int blockSize;
    private final boolean isLeaf;

    public IndexRecord(Key startKey, long blockOffset, int blockSize, boolean isLeaf) {
        this.startKey = startKey;
        this.blockOffset = blockOffset;
        this.blockSize = blockSize;
        this.isLeaf = isLeaf;
    }

// Path: src/main/java/com/jordanwilliams/heftydb/data/Key.java
// public class Key implements Comparable<Key> {
// 
//     private final ByteBuffer data;
//     private final long snapshotId;
// 
//     public Key(ByteBuffer data, long snapshotId) {
//         this.data = data;
//         this.snapshotId = snapshotId;
//     }
// 
//     public ByteBuffer data() {
//         return data;
//     }
// 
//     public long snapshotId() {
//         return snapshotId;
//     }
// 
//     public int size() {
//         return data.capacity();
//     }
// 
//     @Override
//     public int compareTo(Key o) {
//         int compared = data.compareTo(o.data);
// 
//         if (compared != 0) {
//             return compared;
//         }
// 
//         return Long.compare(snapshotId, o.snapshotId);
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Key key = (Key) o;
// 
//         if (snapshotId != key.snapshotId) return false;
//         if (data != null ? !data.equals(key.data) : key.data != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return data != null ? data.hashCode() : 0;
//     }
// 
//     @Override
//     public String toString() {
//         byte[] keyArray = new byte[data.capacity()];
//         data.rewind();
//         data.get(keyArray);
//         data.rewind();
// 
//         return "Key{" +
//                 "data=" + new String(keyArray) +
//                 ", snapshotId=" + snapshotId +
//                 '}';
//     }
// }
// 
// Path: src/main/java/com/jordanwilliams/heftydb/util/Sizes.java
// public class Sizes {
// 
//     public static int LONG_SIZE = 8;
// 
//     public static int INT_SIZE = 4;
// }


// Path: src/main/java/com/jordanwilliams/heftydb/index/IndexRecord.java
import com.jordanwilliams.heftydb.data.Key;
import com.jordanwilliams.heftydb.util.Sizes;

/*
 * Copyright (c) 2014. Jordan Williams
 *
 * 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 com.jordanwilliams.heftydb.index;


/**
 * Represents a single entry in an IndexBlock.
 */
public class IndexRecord {

    private final Key startKey;
    private final long blockOffset;
    private final int blockSize;
    private final boolean isLeaf;

    public IndexRecord(Key startKey, long blockOffset, int blockSize, boolean isLeaf) {
        this.startKey = startKey;
        this.blockOffset = blockOffset;
        this.blockSize = blockSize;
        this.isLeaf = isLeaf;
    }

    public IndexRecord(Key startKey, long blockOffset, int blockSize) {