// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IdentifierEncoding.java
// public class IdentifierEncoding {
//     public static byte[] encode(byte[] bytes) {
//         byte[] result = new byte[bytes.length + Bytes.SIZEOF_INT];
//         System.arraycopy(bytes, 0, result, 0, bytes.length);
//         Bytes.putInt(result, bytes.length, bytes.length);
//         return result;
//     }
// 
//     /**
//      * Extracts the identifier from an index row key.
//      *
//      * @param bytes byte array containing an encoded row key at its end (and arbitrary bytes before that).
//      *              Note that this method modifies the bytes in case inverted is true!
//      * @param inverted indicates if the bits in the row key are inverted (can be the case for descending ordering)
//      */
//     public static byte[] decode(byte[] bytes, boolean inverted) {
//         if (inverted) {
//             for (int i = 0; i < Bytes.SIZEOF_INT; i++) {
//                 int pos = bytes.length - i - 1;
//                 bytes[pos] = bytes[pos] ^= 0xFF;
//             }
//         }
// 
//         int keyLength = Bytes.toInt(bytes, bytes.length - Bytes.SIZEOF_INT);
//         byte[] result = new byte[keyLength];
//         System.arraycopy(bytes, bytes.length - keyLength - Bytes.SIZEOF_INT, result, 0, keyLength);
//         
//         if (inverted) {
//             for (int j = 0; j < result.length; j++) {
//                 result[j] ^= 0xFF;
//             }
//         }
// 
//         return result;
//     }
// }


import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.IdentifierEncoding;
import static org.junit.Assert.*;
package org.lilycms.hbaseindex.test;



public class IdentifierEncodingTest {
    @Test
    public void test() {
        byte[] key = Bytes.toBytes("foobar");
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IdentifierEncoding.java
// public class IdentifierEncoding {
//     public static byte[] encode(byte[] bytes) {
//         byte[] result = new byte[bytes.length + Bytes.SIZEOF_INT];
//         System.arraycopy(bytes, 0, result, 0, bytes.length);
//         Bytes.putInt(result, bytes.length, bytes.length);
//         return result;
//     }
// 
//     /**
//      * Extracts the identifier from an index row key.
//      *
//      * @param bytes byte array containing an encoded row key at its end (and arbitrary bytes before that).
//      *              Note that this method modifies the bytes in case inverted is true!
//      * @param inverted indicates if the bits in the row key are inverted (can be the case for descending ordering)
//      */
//     public static byte[] decode(byte[] bytes, boolean inverted) {
//         if (inverted) {
//             for (int i = 0; i < Bytes.SIZEOF_INT; i++) {
//                 int pos = bytes.length - i - 1;
//                 bytes[pos] = bytes[pos] ^= 0xFF;
//             }
//         }
// 
//         int keyLength = Bytes.toInt(bytes, bytes.length - Bytes.SIZEOF_INT);
//         byte[] result = new byte[keyLength];
//         System.arraycopy(bytes, bytes.length - keyLength - Bytes.SIZEOF_INT, result, 0, keyLength);
//         
//         if (inverted) {
//             for (int j = 0; j < result.length; j++) {
//                 result[j] ^= 0xFF;
//             }
//         }
// 
//         return result;
//     }
// }


// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/IdentifierEncodingTest.java
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.IdentifierEncoding;
import static org.junit.Assert.*;

package org.lilycms.hbaseindex.test;



public class IdentifierEncodingTest {
    @Test
    public void test() {
        byte[] key = Bytes.toBytes("foobar");
        assertEquals("foobar", Bytes.toString(IdentifierEncoding.decode(IdentifierEncoding.encode(key), false)));