public SpatialDataType(int dimensions) { // Because of how we are storing the // min-max-flag in the read/write method // the number of dimensions must be < 32. DataUtils.checkArgument(dimensions >= 1 && dimensions < 32, "Dimensions must be between 1 and 31, is {0}", dimensions); this.dimensions = dimensions; }
DroppedMapRedoLogRecord(String mapName) { DataUtils.checkArgument(mapName != null, "The mapName may not be null"); this.mapName = mapName; }
/** * Try to update the value for the given key. * <p> * This will fail if the row is locked by another transaction * (that means, if another open transaction changed the row). * * @param key the key * @param value the new value * @return whether the entry could be updated */ public boolean tryPut(K key, V value) { DataUtils.checkArgument(value != null, "The value may not be null"); return trySet(key, value); }
/** * Set the maximum memory this cache should use. This will not * immediately cause entries to get removed however; it will only change * the limit. To resize the internal array, call the clear method. * * @param maxMemory the maximum size (1 or larger) in bytes */ public void setMaxMemory(long maxMemory) { DataUtils.checkArgument(maxMemory > 0, "Max memory must be larger than 0, is {0}", maxMemory); this.maxMemory = maxMemory; if (segments != null) { long max = 1 + maxMemory / segments.length; for (Segment<V> s : segments) { s.setMaxMemory(max); } } }
/** * Update the value for the given key. * <p> * If the row is locked, this method will retry until the row could be * updated or until a lock timeout. * * @param key the key * @param value the new value (not null) * @return the old value * @throws IllegalStateException if a lock timeout occurs */ @Override public V put(K key, V value) { DataUtils.checkArgument(value != null, "The value may not be null"); return set(key, value); }
@Override @SuppressWarnings("unchecked") public V putCommitted(K key, V value) { DataUtils.checkArgument(value != null, "The value may not be null"); TransactionalValue newValue = TransactionalValue.createCommitted(value); TransactionalValue oldValue = map.put(key, newValue); return (V) (oldValue == null ? null : oldValue.value); }
/** * Create a new cache with the given memory size. * * @param config the configuration */ @SuppressWarnings("unchecked") public CacheLongKeyLIRS(Config config) { setMaxMemory(config.maxMemory); this.nonResidentQueueSize = config.nonResidentQueueSize; DataUtils.checkArgument(Integer.bitCount(config.segmentCount) == 1, "The segment count must be a power of 2, is {0}", config.segmentCount); this.segmentCount = config.segmentCount; this.segmentMask = segmentCount - 1; this.stackMoveDistance = config.stackMoveDistance; segments = new Segment[segmentCount]; clear(); // use the high bits for the segment this.segmentShift = 32 - Integer.bitCount(segmentMask); }
protected StorageMapBase(String name, StorageDataType keyType, StorageDataType valueType, Storage storage) { DataUtils.checkArgument(name != null, "The name may not be null"); if (keyType == null) { keyType = new ObjectDataType(); } if (valueType == null) { valueType = new ObjectDataType(); } this.name = name; this.keyType = keyType; this.valueType = valueType; this.storage = storage; }
AOStorage aoStorage) { super(name, keyType, valueType, aoStorage); DataUtils.checkArgument(config != null, "The config may not be null"); if (isShardingMode) { String initReplicationEndpoints = (String) config.get("initReplicationEndpoints"); DataUtils.checkArgument(initReplicationEndpoints != null, "The initReplicationEndpoints may not be null"); String[] replicationEndpoints = StringUtils.arraySplit(initReplicationEndpoints, '&');
AOStorage(Map<String, Object> config) { super(config); this.db = (IDatabase) config.get("db"); String storagePath = getStoragePath(); DataUtils.checkArgument(storagePath != null, "The storage path may not be null"); if (!FileUtils.exists(storagePath)) FileUtils.createDirectories(storagePath); FilePath dir = FilePath.get(storagePath); for (FilePath fp : dir.newDirectoryStream()) { String mapFullName = fp.getName(); if (mapFullName.startsWith(TEMP_NAME_PREFIX)) { fp.delete(); } } }
@Override @SuppressWarnings("unchecked") public synchronized V put(K key, V value) { DataUtils.checkArgument(value != null, "The value may not be null"); beforeWrite(); BTreePage p = root.copy(); boolean split = false; if (p.needSplit()) { p = splitRoot(p); split = true; } Object result = put(p, key, value); if (split && isShardingMode && root.isLeaf()) { PageKey pk = new PageKey(p.getKey(0), false); // 移动右边的Page moveLeafPageLazy(pk); } newRoot(p); return (V) result; }