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; }
for (Object x : (Object[]) obj) { if (x != null) { size += elementType.getMemory(x);
/** * Switch the last remembered type to match the type of the given object. * * @param obj the object * @return the auto-detected type used */ StorageDataTypeBase switchType(Object obj) { int typeId = getTypeId(obj); StorageDataTypeBase l = last; if (typeId != l.getType()) { last = l = newType(typeId); } return l; }
} else if (obj == null) { return TYPE_NULL; } else if (isDate(obj)) { return TYPE_DATE; } else if (isTime(obj)) { return TYPE_TIME; } else if (isTimestamp(obj)) { return TYPE_TIMESTAMP; } else if (isBigInteger(obj)) { return TYPE_BIG_INTEGER; } else if (isBigDecimal(obj)) { return TYPE_BIG_DECIMAL; } else if (obj.getClass().isArray()) {
Class<?> bType = bObj.getClass().getComponentType(); if (type != bType) { Integer classA = ObjectDataType.getCommonClassId(type); Integer classB = ObjectDataType.getCommonClassId(bType); if (classA != null) { if (classB != null) { byte[] a = (byte[]) aObj; byte[] b = (byte[]) bObj; return ObjectDataType.compareNotNull(a, b); Object[] b = (Object[]) bObj; for (int i = 0; i < len; i++) { int comp = elementType.compare(a[i], b[i]); if (comp != 0) { return comp;
@Override public void write(DataBuffer buff, Object obj) { Class<?> type = obj.getClass().getComponentType(); Integer classId = ObjectDataType.getCommonClassId(type); if (classId != null) { if (type.isPrimitive()) { buff.putVarInt(len); for (Object x : array) { elementType.write(buff, x);
@SuppressWarnings("unchecked") @Override public int compare(Object aObj, Object bObj) { if (aObj == bObj) { return 0; } StorageDataType ta = getType(aObj); StorageDataType tb = getType(bObj); if (ta != this || tb != this) { if (ta == tb) { return ta.compare(aObj, bObj); } } // TODO ensure comparable type (both may be comparable but not // with each other) if (aObj instanceof Comparable) { if (aObj.getClass().isAssignableFrom(bObj.getClass())) { return ((Comparable<Object>) aObj).compareTo(bObj); } } if (bObj instanceof Comparable) { if (bObj.getClass().isAssignableFrom(aObj.getClass())) { return -((Comparable<Object>) bObj).compareTo(aObj); } } byte[] a = serialize(aObj); byte[] b = serialize(bObj); return ObjectDataType.compareNotNull(a, b); }
@SuppressWarnings("unchecked") @Override public <K, V> MVCCTransactionMap<K, V> openMap(String name, StorageDataType keyType, StorageDataType valueType, Storage storage, Map<String, String> parameters) { checkNotClosed(); if (keyType == null) keyType = new ObjectDataType(); if (valueType == null) valueType = new ObjectDataType(); valueType = new TransactionalValueType(valueType); StorageMap<K, TransactionalValue> map = storage.openMap(name, keyType, valueType, parameters); if (!map.isInMemory()) { TransactionalLogRecord.redo(map, logSyncService.getAndRemovePendingRedoLog(map.getName())); } transactionEngine.addMap((StorageMap<Object, TransactionalValue>) map); boolean isShardingMode = parameters == null ? false : Boolean.parseBoolean(parameters.get("isShardingMode")); return createTransactionMap(map, isShardingMode); }
Storage storage = map.getStorage(); String tmpMapName = storage.nextTemporaryMapName(); StorageMap<Object, Integer> temp = storage.openMap(tmpMapName, new ObjectDataType(), new ObjectDataType(), null); try {