/** * Fragments a value to fit into a node which is splitting. */ private static void fragmentValueForSplit(Tree tree, FragParams params) throws IOException { byte[] value = params.value; // Compute the encoded key length by subtracting off the value length. This properly // handles the case where the key has been fragmented. int encodedKeyLen = params.encodedLen - calculateLeafValueLength(value); LocalDatabase db = tree.mDatabase; // Maximum allowed size for fragmented value is limited by available node space // (accounting for the entry pointer), the maximum allowed fragmented entry size, and // the space occupied by the key. int max = Math.min(params.available - 2, db.mMaxFragmentedEntrySize) - encodedKeyLen; value = db.fragment(value, value.length, max); if (value == null) { // This shouldn't happen with a properly defined maximum key size. throw new AssertionError("Frag max: " + max); } params.value = value; params.encodedLen = encodedKeyLen + calculateFragmentedValueLength(value); if ((params.available -= params.encodedLen + 2) < 0) { // Miscalculated the maximum allowed size. throw new AssertionError(); } }
/** * Fragments a value to fit into a node which is splitting. */ private static void fragmentValueForSplit(Tree tree, FragParams params) throws IOException { byte[] value = params.value; // Compute the encoded key length by subtracting off the value length. This properly // handles the case where the key has been fragmented. int encodedKeyLen = params.encodedLen - calculateLeafValueLength(value); LocalDatabase db = tree.mDatabase; // Maximum allowed size for fragmented value is limited by available node space // (accounting for the entry pointer), the maximum allowed fragmented entry size, and // the space occupied by the key. int max = Math.min(params.available - 2, db.mMaxFragmentedEntrySize) - encodedKeyLen; value = db.fragment(value, value.length, max); if (value == null) { // This shouldn't happen with a properly defined maximum key size. throw new AssertionError("Frag max: " + max); } params.value = value; params.encodedLen = encodedKeyLen + calculateFragmentedValueLength(value); if ((params.available -= params.encodedLen + 2) < 0) { // Miscalculated the maximum allowed size. throw new AssertionError(); } }
/** * Fragments a value to fit into a node which is splitting. */ private static void fragmentValueForSplit(Tree tree, FragParams params) throws IOException { byte[] value = params.value; // Compute the encoded key length by subtracting off the value length. This properly // handles the case where the key has been fragmented. int encodedKeyLen = params.encodedLen - calculateLeafValueLength(value); LocalDatabase db = tree.mDatabase; // Maximum allowed size for fragmented value is limited by available node space // (accounting for the entry pointer), the maximum allowed fragmented entry size, and // the space occupied by the key. int max = Math.min(params.available - 2, db.mMaxFragmentedEntrySize) - encodedKeyLen; value = db.fragment(value, value.length, max); if (value == null) { // This shouldn't happen with a properly defined maximum key size. throw new AssertionError("Frag max: " + max); } params.value = value; params.encodedLen = encodedKeyLen + calculateFragmentedValueLength(value); if ((params.available -= params.encodedLen + 2) < 0) { // Miscalculated the maximum allowed size. throw new AssertionError(); } }
int encodedLen = encodedKeyLen + calculateLeafValueLength(value);
int encodedLen = encodedKeyLen + calculateLeafValueLength(value);
long longEncodedLen = encodedKeyLen + calculateLeafValueLength(vlength); int encodedLen;
long longEncodedLen = encodedKeyLen + calculateLeafValueLength(vlength); int encodedLen;
int encodedLen = encodedKeyLen + calculateLeafValueLength(value);
long longEncodedLen = encodedKeyLen + calculateLeafValueLength(vlength); int encodedLen;
int encodedLen = encodedKeyLen + calculateLeafValueLength(value);
} else { LocalDatabase db = tree.mDatabase; encodedLen = keyLen + calculateLeafValueLength(value); if (encodedLen > db.mMaxEntrySize) { value = db.fragment(value, value.length, db.mMaxFragmentedEntrySize - keyLen);
} else { LocalDatabase db = tree.mDatabase; encodedLen = keyLen + calculateLeafValueLength(value); if (encodedLen > db.mMaxEntrySize) { value = db.fragment(value, value.length, db.mMaxFragmentedEntrySize - keyLen);
} else { LocalDatabase db = tree.mDatabase; encodedLen = keyLen + calculateLeafValueLength(value); if (encodedLen > db.mMaxEntrySize) { value = db.fragment(value, value.length, db.mMaxFragmentedEntrySize - keyLen);