當前位置: 首頁>>代碼示例>>Java>>正文


Java DataUtils.newIllegalArgumentException方法代碼示例

本文整理匯總了Java中org.h2.mvstore.DataUtils.newIllegalArgumentException方法的典型用法代碼示例。如果您正苦於以下問題:Java DataUtils.newIllegalArgumentException方法的具體用法?Java DataUtils.newIllegalArgumentException怎麽用?Java DataUtils.newIllegalArgumentException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.h2.mvstore.DataUtils的用法示例。


在下文中一共展示了DataUtils.newIllegalArgumentException方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: put

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
/**
 * Add an entry to the cache. The entry may or may not exist in the
 * cache yet. This method will usually mark unknown entries as cold and
 * known entries as hot.
 *
 * @param key the key (may not be null)
 * @param hash the hash
 * @param value the value (may not be null)
 * @param memory the memory used for the given entry
 * @return the old value, or null if there was no resident entry
 */
synchronized V put(long key, int hash, V value, int memory) {
    if (value == null) {
        throw DataUtils.newIllegalArgumentException(
                "The value may not be null");
    }
    V old;
    Entry<V> e = find(key, hash);
    if (e == null) {
        old = null;
    } else {
        old = e.value;
        remove(key, hash);
    }
    if (memory > maxMemory) {
        // the new entry is too big to fit
        return old;
    }
    e = new Entry<V>();
    e.key = key;
    e.value = value;
    e.memory = memory;
    int index = hash & mask;
    e.mapNext = entries[index];
    entries[index] = e;
    usedMemory += memory;
    if (usedMemory > maxMemory) {
        // old entries needs to be removed
        evict();
        // if the cache is full, the new entry is
        // cold if possible
        if (stackSize > 0) {
            // the new cold entry is at the top of the queue
            addToQueue(queue, e);
        }
    }
    mapSize++;
    // added entries are always added to the stack
    addToStack(e);
    return old;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:52,代碼來源:CacheLongKeyLIRS.java

示例2: serialize

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
/**
 * Serialize the object to a byte array.
 *
 * @param obj the object to serialize
 * @return the byte array
 */
public static byte[] serialize(Object obj) {
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream os = new ObjectOutputStream(out);
        os.writeObject(obj);
        return out.toByteArray();
    } catch (Throwable e) {
        throw DataUtils.newIllegalArgumentException(
                "Could not serialize {0}", obj, e);
    }
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:18,代碼來源:ObjectDataType.java

示例3: deserialize

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
/**
 * De-serialize the byte array to an object.
 *
 * @param data the byte array
 * @return the object
 */
public static Object deserialize(byte[] data) {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(data);
        ObjectInputStream is = new ObjectInputStream(in);
        return is.readObject();
    } catch (Throwable e) {
        throw DataUtils.newIllegalArgumentException(
                "Could not deserialize {0}", Arrays.toString(data), e);
    }
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:17,代碼來源:ObjectDataType.java

示例4: addMap

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
/**
 * Add the given shard.
 *
 * @param map the map
 * @param min the lowest key, or null if no limit
 * @param max the highest key, or null if no limit
 */
public void addMap(Map<K, V> map, K min, K max) {
    if (min != null && max != null && keyType.compare(min, max) > 0) {
        DataUtils.newIllegalArgumentException("Invalid range: {0} .. {1}", min, max);
    }
    int len = shards.length + 1;
    Shard<K, V>[] newShards = Arrays.copyOf(shards, len);
    Shard<K, V> newShard = new Shard<K, V>();
    newShard.map = map;
    newShard.minIncluding = min;
    newShard.maxExcluding = max;
    newShards[len - 1] = newShard;
    shards = newShards;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:21,代碼來源:ShardedMap.java

示例5: FreeSpaceList

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
public FreeSpaceList(int firstFreeBlock, int blockSize) {
    this.firstFreeBlock = firstFreeBlock;
    if (Integer.bitCount(blockSize) != 1) {
        throw DataUtils.newIllegalArgumentException("Block size is not a power of 2");
    }
    this.blockSize = blockSize;
    clear();
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:9,代碼來源:FreeSpaceList.java

示例6: FreeSpaceTree

import org.h2.mvstore.DataUtils; //導入方法依賴的package包/類
public FreeSpaceTree(int firstFreeBlock, int blockSize) {
    this.firstFreeBlock = firstFreeBlock;
    if (Integer.bitCount(blockSize) != 1) {
        throw DataUtils.newIllegalArgumentException("Block size is not a power of 2");
    }
    this.blockSize = blockSize;
    clear();
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:9,代碼來源:FreeSpaceTree.java


注:本文中的org.h2.mvstore.DataUtils.newIllegalArgumentException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。