• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ObjectMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.esotericsoftware.kryo.util.ObjectMap的典型用法代码示例。如果您正苦于以下问题:Java ObjectMap类的具体用法?Java ObjectMap怎么用?Java ObjectMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ObjectMap类属于com.esotericsoftware.kryo.util包,在下文中一共展示了ObjectMap类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
@Override
public Object read(Kryo kryo, Input input, Class type) {
    try {
        ObjectMap graphContext = kryo.getGraphContext();
        ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
        if (objectStream == null) {
            objectStream = new ObjectInputStream(input) {
                @Override
                protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
                    return ClassUtils.getClass(KryoSerialization.class.getClassLoader(), desc.getName());
                }
            };
            graphContext.put(this, objectStream);
        }
        return objectStream.readObject();
    } catch (Exception ex) {
        throw new KryoException("Error during Java deserialization.", ex);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:KryoSerialization.java


示例2: write

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void write(Kryo kryo, Output output, T o) {
	try {
		ObjectMap graphContext = kryo.getGraphContext();
		ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
		if (objectStream == null) {
			objectStream = new ObjectOutputStream(output);
			graphContext.put(this, objectStream);
		}
		objectStream.writeObject(o);
		objectStream.flush();
	} catch (Exception ex) {
		throw new KryoException("Error during Java serialization.", ex);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:JavaSerializer.java


示例3: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public T read(Kryo kryo, Input input, Class aClass) {
	try {
		ObjectMap graphContext = kryo.getGraphContext();
		ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
		if (objectStream == null) {
			// make sure we use Kryo's classloader
			objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader());
			graphContext.put(this, objectStream);
		}
		return (T) objectStream.readObject();
	} catch (Exception ex) {
		throw new KryoException("Error during Java deserialization.", ex);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:JavaSerializer.java


示例4: write

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
public void write (Kryo kryo, Output output, T object) {
	CachedField[] fields = getFields();
	ObjectMap context = kryo.getGraphContext();
	if (!context.containsKey(this)) {
		context.put(this, null);
		if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
		output.writeVarInt(fields.length, true);
		for (int i = 0, n = fields.length; i < n; i++)
			output.writeString(fields[i].field.getName());
	}

	OutputChunked outputChunked = new OutputChunked(output, 1024);
	for (int i = 0, n = fields.length; i < n; i++) {
		fields[i].write(outputChunked, object);
		outputChunked.endChunks();
	}
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:18,代码来源:CompatibleFieldSerializer.java


示例5: ObjectIntMap

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/** Creates a new map with the specified initial capacity and load factor. This map will hold initialCapacity * loadFactor items
 * before growing the backing table. */
public ObjectIntMap (int initialCapacity, float loadFactor) {
	if (initialCapacity < 0) throw new IllegalArgumentException("initialCapacity must be >= 0: " + initialCapacity);
	if (initialCapacity > 1 << 30) throw new IllegalArgumentException("initialCapacity is too large: " + initialCapacity);
	capacity = ObjectMap.nextPowerOfTwo(initialCapacity);

	if (loadFactor <= 0) throw new IllegalArgumentException("loadFactor must be > 0: " + loadFactor);
	this.loadFactor = loadFactor;

	threshold = (int)(capacity * loadFactor);
	mask = capacity - 1;
	hashShift = 31 - Integer.numberOfTrailingZeros(capacity);
	stashCapacity = Math.max(3, (int)Math.ceil(Math.log(capacity)) * 2);
	pushIterations = Math.max(Math.min(capacity, 8), (int)Math.sqrt(capacity) / 8);

	keyTable = (K[])new Object[capacity + stashCapacity];
	valueTable = new int[keyTable.length];
}
 
开发者ID:abejfehr,项目名称:magic-realm,代码行数:20,代码来源:ObjectIntMap.java


示例6: ObjectIntMap

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/**
 * Creates a new map with the specified initial capacity and load factor.
 * This map will hold initialCapacity * loadFactor items before growing the
 * backing table.
 */
@SuppressWarnings("unchecked")
   public ObjectIntMap(int initialCapacity, float loadFactor) {
	if (initialCapacity < 0)
		throw new IllegalArgumentException("initialCapacity must be >= 0: "
				+ initialCapacity);
	if (initialCapacity > 1 << 30)
		throw new IllegalArgumentException("initialCapacity is too large: "
				+ initialCapacity);
	capacity = ObjectMap.nextPowerOfTwo(initialCapacity);

	if (loadFactor <= 0)
		throw new IllegalArgumentException("loadFactor must be > 0: "
				+ loadFactor);
	this.loadFactor = loadFactor;

	threshold = (int) (capacity * loadFactor);
	mask = capacity - 1;
	hashShift = 31 - Integer.numberOfTrailingZeros(capacity);
	stashCapacity = Math.max(3, (int) Math.ceil(Math.log(capacity)) * 2);
	pushIterations = Math.max(Math.min(capacity, 8),
			(int) Math.sqrt(capacity) / 8);

	keyTable = (K[]) new Object[capacity + stashCapacity];
	valueTable = new int[keyTable.length];
}
 
开发者ID:MosaicOwl,项目名称:the-erder,代码行数:31,代码来源:ObjectIntMap.java


示例7: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
@Override
public Object read(Kryo kryo, Input input, Class type)
{
  try {
    ObjectMap graphContext = kryo.getGraphContext();
    ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
    if (objectStream == null) {
      objectStream = new ObjectInputStreamWithKryoClassLoader(input, kryo);
      graphContext.put(this, objectStream);
    }
    return objectStream.readObject();
  } catch (Exception ex) {
    throw new KryoException("Error during Java deserialization.", ex);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:KryoJavaSerializer.java


示例8: write

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
public void write (Kryo kryo, Output output, Object object) {
	try {
		ObjectMap graphContext = kryo.getGraphContext();
		ObjectOutputStream objectStream = (ObjectOutputStream)graphContext.get(this);
		if (objectStream == null) {
			objectStream = new ObjectOutputStream(output);
			graphContext.put(this, objectStream);
		}
		objectStream.writeObject(object);
		objectStream.flush();
	} catch (Exception ex) {
		throw new KryoException("Error during Java serialization.", ex);
	}
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:15,代码来源:JavaSerializer.java


示例9: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
public Object read (Kryo kryo, Input input, Class type) {
	try {
		ObjectMap graphContext = kryo.getGraphContext();
		ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this);
		if (objectStream == null) {
			objectStream = new ObjectInputStream(input);
			graphContext.put(this, objectStream);
		}
		return objectStream.readObject();
	} catch (Exception ex) {
		throw new KryoException("Error during Java deserialization.", ex);
	}
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:14,代码来源:JavaSerializer.java


示例10: buildValidFields

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
private List<Field> buildValidFields (boolean transientFields, List<Field> allFields, ObjectMap context, IntArray useAsm) {
	List<Field> result = new ArrayList(allFields.size());

	for (int i = 0, n = allFields.size(); i < n; i++) {
		Field field = allFields.get(i);

		int modifiers = field.getModifiers();
		if (Modifier.isTransient(modifiers) != transientFields) continue;
		if (Modifier.isStatic(modifiers)) continue;
		if (field.isSynthetic() && ignoreSyntheticFields) continue;

		if (!field.isAccessible()) {
			if (!setFieldsAsAccessible) continue;
			try {
				field.setAccessible(true);
			} catch (AccessControlException ex) {
				continue;
			}
		}

		Optional optional = field.getAnnotation(Optional.class);
		if (optional != null && !context.containsKey(optional.value())) continue;

		result.add(field);

		// BOZO - Must be public?
		useAsm.add(!Modifier.isFinal(modifiers) && Modifier.isPublic(modifiers)
			&& Modifier.isPublic(field.getType().getModifiers()) ? 1 : 0);
	}
	return result;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:32,代码来源:FieldSerializer.java


示例11: getCachedSerializer

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
private JavaSerializer getCachedSerializer (Class type) {
  if (javaSerializerByType == null) {
		javaSerializerByType = new ObjectMap<Class, JavaSerializer>();
		return null;
  }

  return javaSerializerByType.get(type);
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:9,代码来源:ExternalizableSerializer.java


示例12: buildValidFields

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
private List<Field> buildValidFields (boolean transientFields, List<Field> allFields, ObjectMap context, IntArray useAsm) {
	List<Field> result = new ArrayList(allFields.size());

	for (int i = 0, n = allFields.size(); i < n; i++) {
		Field field = allFields.get(i);

		int modifiers = field.getModifiers();
		if (Modifier.isTransient(modifiers) && !transientFields) continue;
		if (Modifier.isStatic(modifiers)) continue;
		if (field.isSynthetic() && ignoreSyntheticFields) continue;

		if (!field.isAccessible()) {
			if (!setFieldsAsAccessible) continue;
			try {
				field.setAccessible(true);
			} catch (AccessControlException ex) {
				continue;
			}
		}

		Optional optional = field.getAnnotation(Optional.class);
		if (optional != null && !context.containsKey(optional.value())) continue;

		result.add(field);

		// BOZO - Must be public?
		useAsm.add(!Modifier.isFinal(modifiers) && Modifier.isPublic(modifiers)
			&& Modifier.isPublic(field.getType().getModifiers()) ? 1 : 0);
	}
	return result;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:32,代码来源:FieldSerializer.java


示例13: shrink

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/** Reduces the size of the backing arrays to be the specified capacity or less. If the capacity is already less, nothing is
 * done. If the map contains more items than the specified capacity, the next highest power of two capacity is used instead. */
public void shrink (int maximumCapacity) {
	if (maximumCapacity < 0) throw new IllegalArgumentException("maximumCapacity must be >= 0: " + maximumCapacity);
	if (size > maximumCapacity) maximumCapacity = size;
	if (capacity <= maximumCapacity) return;
	maximumCapacity = ObjectMap.nextPowerOfTwo(maximumCapacity);
	resize(maximumCapacity);
}
 
开发者ID:abejfehr,项目名称:magic-realm,代码行数:10,代码来源:ObjectIntMap.java


示例14: shrink

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/**
 * Reduces the size of the backing arrays to be the specified capacity or
 * less. If the capacity is already less, nothing is done. If the map
 * contains more items than the specified capacity, the next highest power
 * of two capacity is used instead.
 */
public void shrink(int maximumCapacity) {
	if (maximumCapacity < 0)
		throw new IllegalArgumentException("maximumCapacity must be >= 0: "
				+ maximumCapacity);
	if (size > maximumCapacity)
		maximumCapacity = size;
	if (capacity <= maximumCapacity)
		return;
	maximumCapacity = ObjectMap.nextPowerOfTwo(maximumCapacity);
	resize(maximumCapacity);
}
 
开发者ID:MosaicOwl,项目名称:the-erder,代码行数:18,代码来源:ObjectIntMap.java


示例15: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
public T read (Kryo kryo, Input input, Class<T> type) {
	T object = create(kryo, input, type);
	kryo.reference(object);
	ObjectMap context = kryo.getGraphContext();
	CachedField[] fields = (CachedField[])context.get(this);
	if (fields == null) {
		int length = input.readVarInt(true);
		if (TRACE) trace("kryo", "Read " + length + " field names.");
		String[] names = new String[length];
		for (int i = 0; i < length; i++)
			names[i] = input.readString();

		fields = new CachedField[length];
		CachedField[] allFields = getFields();
		outer:
		for (int i = 0, n = names.length; i < n; i++) {
			String schemaName = names[i];
			for (int ii = 0, nn = allFields.length; ii < nn; ii++) {
				if (allFields[ii].field.getName().equals(schemaName)) {
					fields[i] = allFields[ii];
					continue outer;
				}
			}
			if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
		}
		context.put(this, fields);
	}

	InputChunked inputChunked = new InputChunked(input, 1024);
	boolean hasGenerics = getGenerics() != null;
	for (int i = 0, n = fields.length; i < n; i++) {
		CachedField cachedField = fields[i];
		if(cachedField != null && hasGenerics) {
			// Generic type used to instantiate this field could have 
			// been changed in the meantime. Therefore take the most 
			// up-to-date definition of a field
			cachedField = getField(cachedField.field.getName());
		}
		if (cachedField == null) {
			if (TRACE) trace("kryo", "Skip obsolete field.");
			inputChunked.nextChunks();
			continue;
		}
		cachedField.read(inputChunked, object);
		inputChunked.nextChunks();
	}
	return object;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:49,代码来源:CompatibleFieldSerializer.java


示例16: read

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
public T read (Kryo kryo, Input input, Class<T> type) {
	T object = create(kryo, input, type);
	kryo.reference(object);
	ObjectMap context = kryo.getGraphContext();
	CachedField[] fields = (CachedField[])context.get(this);
	if (fields == null) {
		int length = input.readVarInt(true);
		if (TRACE) trace("kryo", "Read " + length + " field names.");
		String[] names = new String[length];
		for (int i = 0; i < length; i++)
			names[i] = input.readString();

		fields = new CachedField[length];
		CachedField[] allFields = getFields();
		outer:
		for (int i = 0, n = names.length; i < n; i++) {
			String schemaName = names[i];
			for (int ii = 0, nn = allFields.length; ii < nn; ii++) {
				if (allFields[ii].field.getName().equals(schemaName)) {
					fields[i] = allFields[ii];
					continue outer;
				}
			}
			if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
		}
		context.put(this, fields);
	}

	InputChunked inputChunked = new InputChunked(input, 1024);
	for (int i = 0, n = fields.length; i < n; i++) {
		CachedField cachedField = fields[i];
		if (cachedField == null) {
			if (TRACE) trace("kryo", "Skip obsolete field.");
			inputChunked.nextChunks();
			continue;
		}
		cachedField.read(inputChunked, object);
		inputChunked.nextChunks();
	}
	return object;
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:42,代码来源:CompatibleFieldSerializer.java


示例17: ensureCapacity

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/** Increases the size of the backing array to acommodate the specified number of additional items. Useful before adding many
 * items to avoid multiple backing array resizes. */
public void ensureCapacity (int additionalCapacity) {
	int sizeNeeded = size + additionalCapacity;
	if (sizeNeeded >= threshold) resize(ObjectMap.nextPowerOfTwo((int)(sizeNeeded / loadFactor)));
}
 
开发者ID:abejfehr,项目名称:magic-realm,代码行数:7,代码来源:ObjectIntMap.java


示例18: ensureCapacity

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/**
 * Increases the size of the backing array to acommodate the specified
 * number of additional items. Useful before adding many items to avoid
 * multiple backing array resizes.
 */
public void ensureCapacity(int additionalCapacity) {
	int sizeNeeded = size + additionalCapacity;
	if (sizeNeeded >= threshold)
		resize(ObjectMap.nextPowerOfTwo((int) (sizeNeeded / loadFactor)));
}
 
开发者ID:MosaicOwl,项目名称:the-erder,代码行数:11,代码来源:ObjectIntMap.java


示例19: rebuildCachedFields

import com.esotericsoftware.kryo.util.ObjectMap; //导入依赖的package包/类
/** Called when the list of cached fields must be rebuilt. This is done any time settings are changed that affect which fields
 * will be used. It is called from the constructor for FieldSerializer, but not for subclasses. Subclasses must call this from
 * their constructor. */
protected void rebuildCachedFields () {
	if (TRACE && generics != null) trace("kryo", "generic type parameters are: " + Arrays.toString(generics));
	if (type.isInterface()) {
		fields = new CachedField[0]; // No fields to serialize.
		return;
	}

	hasObjectFields = false;

	// For generic classes, generate a mapping from type variable names to the concrete types
	// This mapping is the same for the whole class.
	Generics genScope = buildGenericsScope(type, generics);
	genericsScope = genScope;

	// Push proper scopes at serializer construction time
	if (genericsScope != null) kryo.pushGenericsScope(type, genericsScope);

	// Collect all fields.
	List<Field> allFields = new ArrayList();
	Class nextClass = type;
	while (nextClass != Object.class) {
		Field[] declaredFields = nextClass.getDeclaredFields();
		if (declaredFields != null) {
			for (Field f : declaredFields) {
				if (Modifier.isStatic(f.getModifiers())) continue;
				allFields.add(f);
			}
		}
		nextClass = nextClass.getSuperclass();
	}

	ObjectMap context = kryo.getContext();

	IntArray useAsm = new IntArray();

	// Sort fields by their offsets
	if (useMemRegions && !useAsmEnabled && unsafe() != null) {
		Field[] allFieldsArray = softFieldsByOffset(allFields);
		allFields = Arrays.asList(allFieldsArray);
	}

	// TODO: useAsm is modified as a side effect, this should be pulled out of buildValidFields
	List<Field> validFields = buildValidFields(false, allFields, context, useAsm);
	List<Field> validTransientFields = buildValidFields(true, allFields, context, useAsm);

	// Use ReflectASM for any public fields.
	if (useAsmEnabled && !Util.isAndroid && Modifier.isPublic(type.getModifiers()) && useAsm.indexOf(1) != -1) {
		try {
			access = FieldAccess.get(type);
		} catch (RuntimeException ignored) {
		}
	}

	List<CachedField> cachedFields = new ArrayList(validFields.size());
	List<CachedField> cachedTransientFields = new ArrayList(validTransientFields.size());

	createCachedFields(useAsm, validFields, cachedFields, 0);
	createCachedFields(useAsm, validTransientFields, cachedTransientFields, validFields.size());

	Collections.sort(cachedFields, this);
	fields = cachedFields.toArray(new CachedField[cachedFields.size()]);

	Collections.sort(cachedTransientFields, this);
	transientFields = cachedTransientFields.toArray(new CachedField[cachedTransientFields.size()]);

	initializeCachedFields();

	if (genericsScope != null) kryo.popGenericsScope();
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:73,代码来源:FieldSerializer.java



注:本文中的com.esotericsoftware.kryo.util.ObjectMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StepExecution类代码示例发布时间:2022-05-22
下一篇:
Java HttpConnectionMetrics类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap