com.infomaximum.database.utils.key.KeyUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rdao Show documentation
Show all versions of rdao Show documentation
Library for creating a light cluster
The newest version!
package com.infomaximum.database.utils.key;
import com.infomaximum.database.exception.KeyCorruptedException;
import com.infomaximum.database.schema.BaseIndex;
public class KeyUtils {
/**
* Заполняет начало байтового массива названием индекса и хэшем индексируемых полей: [index_name][fields_hash]...
*/
public static void putAttendantBytes(byte[] destination, final byte[] indexName, final byte[] fieldsHash) {
if (destination.length < BaseIndex.ATTENDANT_BYTE_SIZE) {
throw new IllegalArgumentException("Attendant size more than buffer size");
}
System.arraycopy(indexName, 0, destination, 0, indexName.length);
System.arraycopy(fieldsHash, 0, destination, indexName.length, fieldsHash.length);
}
static byte[] allocateAndPutIndexAttendant(int size, byte[] attendant) {
if (size < attendant.length) {
throw new IllegalArgumentException("Attendant size more than buffer size");
}
byte[] result = new byte[size];
System.arraycopy(attendant, 0, result, 0, attendant.length);
return result;
}
public static byte[] getIndexAttendant(byte[] src) {
if (src.length < BaseIndex.ATTENDANT_BYTE_SIZE) {
throw new KeyCorruptedException(src);
}
byte[] result = new byte[BaseIndex.ATTENDANT_BYTE_SIZE];
System.arraycopy(src, 0, result, 0, BaseIndex.ATTENDANT_BYTE_SIZE);
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy