void compressPage(DataBuffer buff, int compressStart, int type, int typePos) { int expLen = buff.position() - compressStart; if (expLen > 16) { BTreeStorage storage = map.getBTreeStorage(); int compressionLevel = storage.getCompressionLevel(); if (compressionLevel > 0) { Compressor compressor; int compressType; if (compressionLevel == 1) { compressor = storage.getCompressorFast(); compressType = PageUtils.PAGE_COMPRESSED; } else { compressor = storage.getCompressorHigh(); compressType = PageUtils.PAGE_COMPRESSED_HIGH; } byte[] exp = new byte[expLen]; buff.position(compressStart).get(exp); byte[] comp = new byte[expLen * 2]; int compLen = compressor.compress(exp, expLen, comp, 0); int plus = DataUtils.getVarIntLen(compLen - expLen); if (compLen + plus < expLen) { buff.position(typePos).put((byte) (type + compressType)); buff.position(compressStart).putVarInt(expLen - compLen).put(comp, 0, compLen); } } } }