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


Java Type.FIXED屬性代碼示例

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


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

示例1: getSerializer

@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Serializer<T> getSerializer(Type type) {
  Serializer serializer = null;
  if (type == Type.STRING) {
    serializer = CharSequenceSerializer.get();
  } else if (type == Type.BOOLEAN) {
    serializer = BooleanSerializer.get();
  } else if (type == Type.BYTES) {
    serializer = ByteBufferSerializer.get();
  } else if (type == Type.DOUBLE) {
    serializer = DoubleSerializer.get();
  } else if (type == Type.FLOAT) {
    serializer = FloatSerializer.get();
  } else if (type == Type.INT) {
    serializer = IntegerSerializer.get();
  } else if (type == Type.LONG) {
    serializer = LongSerializer.get();
  } else if (type == Type.FIXED) {
    serializer = SpecificFixedSerializer.get();
  } else {
    serializer = null;
  }
  return serializer;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:24,代碼來源:GoraSerializerTypeInferer.java

示例2: validate

public void validate(Schema schema) {
    if (schema.getType() != Type.FIXED)
        throw new IllegalArgumentException("Must be type " + Type.FIXED);
    nameCodec.validate(schema.getName());
    if(schema.getFixedSize() > MAX_FIXED_SIZE)
        throw new IllegalArgumentException("Only supports a fixed size up to " + MAX_FIXED_SIZE + ". Found " + schema.getFixedSize());
}
 
開發者ID:granthenke,項目名稱:avro-schema-compactor,代碼行數:7,代碼來源:FixedCodec.java

示例3: get

public static ListSerializer get(Type elementType, Class clazz) {
  if (elementType != Type.FIXED) {
    return null;
  }
  ListSerializer serializer = elementTypeToSerializerMap.get(clazz);
  if (serializer == null) {
    serializer = new ListSerializer(clazz);
    fixedClassToSerializerMap.put(clazz, serializer);
  }
  return serializer;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:11,代碼來源:ListSerializer.java

示例4: ListSerializer

@SuppressWarnings("unchecked")
public ListSerializer(Type elementType) {
  this.elementType = elementType;
  if (elementType != Type.FIXED) {
    elementSchema = Schema.create(elementType);
  }
  clazz = (Class<T>) TypeUtils.getClass(elementType);
  size = TypeUtils.getFixedSize(elementType);
  elementSerializer = GoraSerializerTypeInferer.getSerializer(elementType);
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:10,代碼來源:ListSerializer.java

示例5: getType

public static Type getType(Class<?> clazz) {
  if (clazz.equals(Utf8.class)) {
    return Type.STRING;
  } else if (clazz.equals(Boolean.class) || clazz.equals(boolean.class)) {
    return Type.BOOLEAN;
  } else if (clazz.equals(ByteBuffer.class)) {
    return Type.BYTES;
  } else if (clazz.equals(Double.class) || clazz.equals(double.class)) {
    return Type.DOUBLE;
  } else if (clazz.equals(Float.class) || clazz.equals(float.class)) {
    return Type.FLOAT;
  } else if (clazz.equals(Integer.class) || clazz.equals(int.class)) {
    return Type.INT;
  } else if (clazz.equals(Long.class) || clazz.equals(long.class)) {
    return Type.LONG;
  } else if (clazz.isAssignableFrom(List.class)) {
    return Type.ARRAY;
  } else if (clazz.isAssignableFrom(Map.class)) {
    return Type.MAP;
  } else if (clazz.equals(Persistent.class)) {
    return Type.RECORD;
  } else if (clazz.getSuperclass().equals(SpecificFixed.class)) {
    return Type.FIXED;
  } else {
    return null;
  }
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:27,代碼來源:TypeUtils.java

示例6: getClass

public static Class<?> getClass(Type type) {
  if (type == Type.STRING) {
    return Utf8.class;
  } else if (type == Type.BOOLEAN) {
    return Boolean.class;
  } else if (type == Type.BYTES) {
    return ByteBuffer.class;
  } else if (type == Type.DOUBLE) {
    return Double.class;
  } else if (type == Type.FLOAT) {
    return Float.class;
  } else if (type == Type.INT) {
    return Integer.class;
  } else if (type == Type.LONG) {
    return Long.class;
  } else if (type == Type.ARRAY) {
    return List.class;
  } else if (type == Type.MAP) {
    return Map.class;
  } else if (type == Type.RECORD) {
    return Persistent.class;
  } else if (type == Type.FIXED) {
    // return SpecificFixed.class;
    return null;
  } else {
    return null;
  }
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:28,代碼來源:TypeUtils.java

示例7: getFixedSize

public static int getFixedSize(Schema schema) {
  Type type = schema.getType();
  if (type == Type.FIXED) {
    return schema.getFixedSize();
  } else {
    return getFixedSize(type);
  }
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:8,代碼來源:TypeUtils.java

示例8: get

public static MapSerializer get(Type valueType, Class clazz) {
  if (valueType != Type.FIXED) {
    return null;
  }
  MapSerializer serializer = valueTypeToSerializerMap.get(clazz);
  if (serializer == null) {
    serializer = new MapSerializer(clazz);
    fixedClassToSerializerMap.put(clazz, serializer);
  }
  return serializer;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:11,代碼來源:MapSerializer.java

示例9: MapSerializer

@SuppressWarnings("unchecked")
public MapSerializer(Type valueType) {
  this.valueType = valueType;
  if (valueType != Type.FIXED) {
    valueSchema = Schema.create(valueType);
  }
  clazz = (Class<T>) TypeUtils.getClass(valueType);
  size = TypeUtils.getFixedSize(valueType);
  valueSerializer = GoraSerializerTypeInferer.getSerializer(valueType);
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:10,代碼來源:MapSerializer.java


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