/*
 * Copyright (c) 2016. emengjzs. All rights reserved.
 */

package emengjzs.emengdb.db;

import java.util.Arrays;

/**
 * Created by emengjzs on 2016/9/2.
 */
public class LookupKey implements InternalKey {


    byte[] key;
    long seqAndFlag;


    LookupKey(byte[] key, long seq) {
        this.key = Arrays.copyOf(key, key.length);
        this.seqAndFlag = seq << 8 | ValueType.VALUE.toByte();
    }

    @Override
    public Slice getUserKey() {
        return new Slice(key);
    }

    @Override
    public int getKeyLength() {
        return key.length;
    }

    @Override
    public long getSeq() {
        return seqAndFlag >>> 8;
    }

    @Override
    public ValueType getValueType() {
        return ValueType.values()[(int) (seqAndFlag & 0xFF)];
    }

    @Override
    public long getSeqFlag() {
        return seqAndFlag;
    }
}

@@ -244,16 +244,160 @@
 Flag;%0A%0A%0A
+%0A    LookupKey(Slice key, long seq) %7B%0A        this.key = key.toBytes();%0A        this.seqAndFlag = seq %3C%3C 8 %7C ValueType.DELETE.toByte();%0A    %7D%0A%0A%0A
     Look
@@ -414,32 +414,48 @@
 %5B%5D key, long seq
+, ValueType type
 ) %7B%0A        this
@@ -534,32 +534,14 @@
 8 %7C 
-ValueType.VALUE.toByte()
+type.v
 ;%0A  

Refactor the constructor