当前位置: 首页>>代码示例>>Java>>正文


Java ProtobufIOUtil.mergeFrom方法代码示例

本文整理汇总了Java中io.protostuff.ProtobufIOUtil.mergeFrom方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufIOUtil.mergeFrom方法的具体用法?Java ProtobufIOUtil.mergeFrom怎么用?Java ProtobufIOUtil.mergeFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.protostuff.ProtobufIOUtil的用法示例。


在下文中一共展示了ProtobufIOUtil.mergeFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
private static FileFormat get(FileConfig fileConfig) {
  // TODO (Amit H) Remove after defining classes for tsv, csv, and psv
  FileType fileType = fileConfig.getType();
  if (fileType == FileType.CSV || fileType == FileType.TSV || fileType == FileType.PSV) {
    fileType = FileType.TEXT;
  }
  final Class<? extends FileFormat> fileFormatClass = FileFormatDefinitions.CLASS_TYPES.get(fileType);
  final Schema<FileFormat> schema = (Schema<FileFormat>) FileFormatDefinitions.SCHEMAS.get(fileFormatClass);

  final FileFormat fileFormat = schema.newMessage();
  if (fileConfig.getExtendedConfig() != null) {
    ProtobufIOUtil.mergeFrom(fileConfig.getExtendedConfig().toByteArray(), fileFormat, schema);
  }

  fileFormat.setCtime(fileConfig.getCtime());
  fileFormat.setName(fileConfig.getName());
  fileFormat.setOwner(fileConfig.getOwner());
  fileFormat.setFullPath(fileConfig.getFullPathList());
  fileFormat.setVersion(fileConfig.getVersion());
  fileFormat.setLocation(fileConfig.getLocation());
  return fileFormat;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:FileFormat.java

示例2: readInternal

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {

    MediaType contentType = inputMessage.getHeaders().getContentType();
    if (MEDIA_TYPE.isCompatibleWith(contentType)) {
        final Schema<?> schema = getSchema(clazz);
        final Object value = schema.newMessage();

        try (final InputStream stream = inputMessage.getBody()) {
            ProtobufIOUtil.mergeFrom(stream, value, (Schema<Object>) schema);
            return value;
        }
    }

    throw new HttpMessageNotReadableException(
            "Unrecognized HTTP media type " + inputMessage.getHeaders().getContentType().getType() + ".");
}
 
开发者ID:bobxwang,项目名称:springboot-scala-withswagger,代码行数:18,代码来源:ProtostuffHttpMessageConverter.java

示例3: getEmp

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
/**
 * 根据empId从redis中取emp
 * @param empId
 * @return
 * @throws Exception
 */
private Emp getEmp(int empId)throws Exception{
    String key = "emp" + empId;
    Jedis jedis = jedisPool.getResource();
    jedis.auth("redis");
    try  {
        byte[] bytes = jedis.get(key.getBytes());
        if (bytes != null) {
            Emp emp = schema.newMessage();
            ProtobufIOUtil.mergeFrom(bytes, emp, schema);
            return emp;
        }
    }finally {
        jedis.close();
    }
    return null;
}
 
开发者ID:chris-zh,项目名称:feeler,代码行数:23,代码来源:JedisTest.java

示例4: containsValue

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
/**
  * Returns <tt>true</tt> if this map maps one or more keys to the
  * specified value.
  *
  * @param value value whose presence in this map is to be tested
  * @return <tt>true</tt> if this map maps one or more keys to the
  *         specified value
  */
 public boolean containsValue(Object value) {
 	Set table = super.getHashSet(gvName,idLocalize);
 	for(Object k:table){
 		
Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);
ObjectWrap obj = scow.newMessage();
ProtobufIOUtil.mergeFrom(((ByteBuffer)k).getArray(), obj, scow);    		
 		K key = (K)obj.getobj();
 		
 		Object valueGV = DEFAULT_JCL.getValue(key.toString()+"�Map�"+gvName).getCorrectResult();
 		if(value.equals(valueGV)){
 			return true;
 		}
 	}
 	return false;
 }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:25,代码来源:JCLHashMapPacu.java

示例5: nextEntry

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
final Entry<K,V> nextEntry() {
        	current = queue.poll();
        	
        	double pag = size/(queue.size()+size);
        	if(((pag>0.4) || (gvList.size()==1)) && (intGvList.hasNext())){
    			java.util.Map.Entry<Integer, JCL_message_generic> entHost = intGvList.next();
    			ticket.add(JCLHashMapPacu.super.getHashValues(queue, entHost.getValue(), entHost.getKey()));        	
        	}
        	
        	
        	size++;
        	        	
			Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);
			ObjectWrap obj = scow.newMessage();
			ProtobufIOUtil.mergeFrom(((ByteBuffer)current.getKey()).getArray(), obj, scow);    		
    		K key = (K)obj.getobj();
 
			ProtobufIOUtil.mergeFrom((byte[])current.getValue(), obj, scow);    		
    		V value = (V)obj.getobj();
        	
        	return new implementations.util.Entry<K, V>(key,value);
//            return current;
        }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:24,代码来源:JCLHashMapPacu.java

示例6: containsValue

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
/**
 * Returns <tt>true</tt> if this map maps one or more keys to the
 * specified value.
 *
 * @param value value whose presence in this map is to be tested
 * @return <tt>true</tt> if this map maps one or more keys to the
 *         specified value
 */
public boolean containsValue(Object value) {
    Set table = super.getHashSet(gvName,idLocalize);
    for(Object k:table){

        Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);
        ObjectWrap obj = scow.newMessage();
        ProtobufIOUtil.mergeFrom(((ByteBuffer)k).getArray(), obj, scow);
        K key = (K)obj.getobj();

        Object valueGV = DEFAULT_JCL.getValue(key.toString()+"¬Map¬"+gvName).getCorrectResult();
        if(value.equals(valueGV)){
            return true;
        }
    }
    return false;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:25,代码来源:JCLHashMapPacu.java

示例7: nextEntry

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
final Entry<K,V> nextEntry() {
            current = queue.poll();

            double pag = size/(queue.size()+size);
            if(((pag>0.4) || (gvList.size()==1)) && (intGvList.hasNext())){
                java.util.Map.Entry<Integer, JCL_message_generic> entHost = intGvList.next();
                ticket.add(JCLHashMapPacu.super.getHashValues(queue, entHost.getValue(), entHost.getKey()));
            }


            size++;

            Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);
            ObjectWrap obj = scow.newMessage();
            ProtobufIOUtil.mergeFrom(((ByteBuffer)current.getKey()).getArray(), obj, scow);
            K key = (K)obj.getobj();

            ProtobufIOUtil.mergeFrom((byte[])current.getValue(), obj, scow);
            V value = (V)obj.getobj();

            return new implementations.util.Entry<K, V>(key,value);
//            return current;
        }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:24,代码来源:JCLHashMapPacu.java

示例8: testProtobuf

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
public void testProtobuf() throws Exception
{
    Schema<Zoo> schema = RuntimeSchema.getSchema(Zoo.class);
    Zoo p = filledZoo();

    byte[] data = ProtobufIOUtil.toByteArray(p, schema, buf());
    // System.err.println("protobuf: " + data.length);

    Zoo p2 = new Zoo();
    ProtobufIOUtil.mergeFrom(data, p2, schema);

    assertEquals(p, p2);

    List<Zoo> list = new ArrayList<Zoo>();
    list.add(p);
    list.add(p2);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ProtobufIOUtil.writeListTo(out, list, schema, buf());
    byte[] listData = out.toByteArray();

    ByteArrayInputStream in = new ByteArrayInputStream(listData);
    List<Zoo> parsedList = ProtobufIOUtil.parseListFrom(in, schema);

    assertEquals(list, parsedList);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:27,代码来源:PolymorphicSerializationTest.java

示例9: parseObject

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
protected <T> void parseObject(InputStream in, T template, Schema<T> schema) {
	try {
		ProtobufIOUtil.mergeFrom(in, template, schema);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:8,代码来源:ProtobufSerializer.java

示例10: fromSource

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
private static <S extends Source> S fromSource(Schema<S> schema, ByteString config) {
  final S source = schema.newMessage();
  if (config != null) {
    ProtobufIOUtil.mergeFrom(config.toByteArray(), source, schema);
  }
  return source;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:Source.java

示例11: keySet

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
/**
   * Returns a {@link Set} view of the keys contained in this map.
   * The set is backed by the map, so changes to the map are
   * reflected in the set, and vice-versa.  If the map is modified
   * while an iteration over the set is in progress (except through
   * the iterator's own <tt>remove</tt> operation), the results of
   * the iteration are undefined.  The set supports element removal,
   * which removes the corresponding mapping from the map, via the
   * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
   * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
   * operations.  It does not support the <tt>add</tt> or <tt>addAll</tt>
   * operations.
   */
  public Set<K> keySet(){
      Set ks = super.getHashSet(gvName,idLocalize);
      
      Set<K> retSet = new HashSet<K>();
Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);        
ObjectWrap obj = scow.newMessage();

for(Object key:ks){
	ProtobufIOUtil.mergeFrom(((ByteBuffer)key).getArray(), obj, scow);    		
          retSet.add((K)obj.getobj());        	
      }
      
      return retSet;
  }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:28,代码来源:JCLHashMapPacu.java

示例12: keySet

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
/**
 * Returns a {@link Set} view of the keys contained in this map.
 * The set is backed by the map, so changes to the map are
 * reflected in the set, and vice-versa.  If the map is modified
 * while an iteration over the set is in progress (except through
 * the iterator's own <tt>remove</tt> operation), the results of
 * the iteration are undefined.  The set supports element removal,
 * which removes the corresponding mapping from the map, via the
 * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
 * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
 * operations.  It does not support the <tt>add</tt> or <tt>addAll</tt>
 * operations.
 */
public Set<K> keySet(){
    Set ks = super.getHashSet(gvName,idLocalize);

    Set<K> retSet = new HashSet<K>();
    Schema<ObjectWrap> scow = RuntimeSchema.getSchema(ObjectWrap.class);
    ObjectWrap obj = scow.newMessage();

    for(Object key:ks){
        ProtobufIOUtil.mergeFrom(((ByteBuffer)key).getArray(), obj, scow);
        retSet.add((K)obj.getobj());
    }

    return retSet;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:28,代码来源:JCLHashMapPacu.java

示例13: unknownEnumValue_toString

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Test
void unknownEnumValue_toString() {
    TestUnknownEnumValue2 source = TestUnknownEnumValue2.newBuilder()
            .setField(TestUnknownEnumValue2.E2.C)
            .build();
    byte[] data = ProtobufIOUtil.toByteArray(source, TestUnknownEnumValue2.getSchema(), LinkedBuffer.allocate());
    Schema<TestUnknownEnumValue1> schema = TestUnknownEnumValue1.getSchema();
    TestUnknownEnumValue1 message = schema.newMessage();
    ProtobufIOUtil.mergeFrom(data, message, schema);
    Assertions.assertEquals("TestUnknownEnumValue1{field=UNRECOGNIZED(2)}", message.toString());
}
 
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:12,代码来源:EnumTest.java

示例14: readContent

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
private static Object readContent(final EventType eventType, final byte[] content) {
    final Class<?> targetClass = eventType.getTargetClass();
    if (targetClass == null) {
        LOG.error("Cannot read clazz header for given EventType value {}, missing mapping", eventType.getValue());
        throw new MessageConversionException("Missing mapping of EventType for value " + eventType.getValue());
    }
    @SuppressWarnings("unchecked")
    final Schema<Object> schema = (Schema<Object>) RuntimeSchema.getSchema(targetClass);
    final Object deserializeEvent = schema.newMessage();
    ProtobufIOUtil.mergeFrom(content, deserializeEvent, schema);
    return deserializeEvent;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:13,代码来源:BusProtoStuffMessageConverter.java

示例15: testInheritanceProtobuf

import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
public void testInheritanceProtobuf() throws IOException
{
    if (skipTests)
    {
        System.err
                .println("RuntimeSchema.MORPH_NON_FINAL_POJOS was not enabled.");
        return;
    }
    System.err.println("executing inheritance test for protobuf ... ");

    Schema<InputSystem> schema = RuntimeSchema.getSchema(InputSystem.class);
    InputSystem sys = new InputSystem();
    KeyBoard kb = new KeyBoard();
    Mouse ms = new Mouse();
    kb.setName("Test");
    kb.setNumberOfKeys(10);
    ms.setName("Test1");
    ms.setNumberOfButtons(2);
    List<InputDevice> devices = new ArrayList<InputDevice>();
    devices.add(ms);
    devices.add(kb);
    sys.setInputDevices(devices);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ProtobufIOUtil.writeTo(out, sys, schema, buf());
    byte[] listData = out.toByteArray();
    InputSystem deserSystem = new InputSystem();
    ByteArrayInputStream in = new ByteArrayInputStream(listData);
    ProtobufIOUtil.mergeFrom(in, deserSystem, schema, buf());

    assertEquals(sys, deserSystem);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:32,代码来源:InheritanceTest.java


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