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

Java MarshalException类代码示例

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

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



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

示例1: getTimestamp

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public long getTimestamp(long now, QueryOptions options) throws InvalidRequestException
{
    if (timestamp == null)
        return now;

    ByteBuffer tval = timestamp.bindAndGet(options);
    if (tval == null)
        throw new InvalidRequestException("Invalid null value of timestamp");

    if (tval == ByteBufferUtil.UNSET_BYTE_BUFFER)
        return now;

    try
    {
        LongType.instance.validate(tval);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException("Invalid timestamp value: " + tval);
    }

    return LongType.instance.compose(tval);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:24,代码来源:Attributes.java


示例2: fromSerialized

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, SetType type, ProtocolVersion version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        Set<?> s = type.getSerializer().deserializeForNativeProtocol(value, version);
        SortedSet<ByteBuffer> elements = new TreeSet<>(type.getElementsType());
        for (Object element : s)
            elements.add(type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:Sets.java


示例3: add

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
private static Builder add(Builder builder, long number, String symbol)
{
    switch (symbol.toLowerCase())
    {
        case "y": return builder.addYears(number);
        case "mo": return builder.addMonths(number);
        case "w": return builder.addWeeks(number);
        case "d": return builder.addDays(number);
        case "h": return builder.addHours(number);
        case "m": return builder.addMinutes(number);
        case "s": return builder.addSeconds(number);
        case "ms": return builder.addMillis(number);
        case "us":
        case "µs": return builder.addMicros(number);
        case "ns": return builder.addNanos(number);
    }
    throw new MarshalException(String.format("Unknown duration symbol '%s'", symbol));
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:Duration.java


示例4: fromSerialized

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type, ProtocolVersion version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = type.getSerializer().deserializeForNativeProtocol(value, version);
        List<ByteBuffer> elements = new ArrayList<>(l.size());
        for (Object element : l)
            // elements can be null in lists that represent a set of IN values
            elements.add(element == null ? null : type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:Lists.java


示例5: parsedValue

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException
{
    if (validator instanceof ReversedType<?>)
        validator = ((ReversedType<?>) validator).baseType;
    try
    {
        if (type == Type.HEX)
            // Note that validator could be BytesType, but it could also be a custom type, so
            // we hardcode BytesType (rather than using 'validator') in the call below.
            // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring.
            return BytesType.instance.fromString(text.substring(2));

        if (validator instanceof CounterColumnType)
            return LongType.instance.fromString(text);
        return validator.fromString(text);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:22,代码来源:Constants.java


示例6: fromSerialized

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, MapType type, ProtocolVersion version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        Map<?, ?> m = type.getSerializer().deserializeForNativeProtocol(value, version);
        Map<ByteBuffer, ByteBuffer> map = new LinkedHashMap<>(m.size());
        for (Map.Entry<?, ?> entry : m.entrySet())
            map.put(type.getKeysType().decompose(entry.getKey()), type.getValuesType().decompose(entry.getValue()));
        return new Value(map);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:Maps.java


示例7: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    if (parsed instanceof Long)
        return new Constants.Value(ByteBufferUtil.bytes((Long) parsed));

    try
    {
        return new Constants.Value(TimestampType.instance.fromString((String) parsed));
    }
    catch (ClassCastException exc)
    {
        throw new MarshalException(String.format(
                "Expected a long or a datestring representation of a date value, but got a %s: %s",
                parsed.getClass().getSimpleName(), parsed));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:DateType.java


示例8: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    try
    {
        String parsedString = (String) parsed;
        if (!parsedString.startsWith("0x"))
            throw new MarshalException(String.format("String representation of blob is missing 0x prefix: %s", parsedString));

        return new Constants.Value(BytesType.instance.fromString(parsedString.substring(2)));
    }
    catch (ClassCastException | MarshalException exc)
    {
        throw new MarshalException(String.format("Value '%s' is not a valid blob representation: %s", parsed, exc.getMessage()));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:17,代码来源:BytesType.java


示例9: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
    // Return an empty ByteBuffer for an empty string.
    if (source.isEmpty())
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    long longType;

    try
    {
        longType = Long.parseLong(source);
    }
    catch (Exception e)
    {
        throw new MarshalException(String.format("Unable to make long from '%s'", source), e);
    }

    return decompose(longType);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:LongType.java


示例10: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    try
    {
        if (parsed instanceof String)
            return new Constants.Value(fromString((String) parsed));

        Number parsedNumber = (Number) parsed;
        if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long))
            throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));

        return new Constants.Value(getSerializer().serialize(parsedNumber.longValue()));
    }
    catch (ClassCastException exc)
    {
        throw new MarshalException(String.format(
                "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:LongType.java


示例11: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
    // Return an empty ByteBuffer for an empty string.
    if (source.isEmpty())
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    InetAddress address;

    try
    {
        address = InetAddress.getByName(source);
    }
    catch (Exception e)
    {
        throw new MarshalException(String.format("Unable to make inet address from '%s'", source), e);
    }

    return decompose(address);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:InetAddressType.java


示例12: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
    // Return an empty ByteBuffer for an empty string.
    if (source.isEmpty())
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    int int32Type;

    try
    {
        int32Type = Integer.parseInt(source);
    }
    catch (Exception e)
    {
        throw new MarshalException(String.format("Unable to make int from '%s'", source), e);
    }

    return decompose(int32Type);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:Int32Type.java


示例13: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    try
    {
        if (parsed instanceof String)
            return new Constants.Value(fromString((String) parsed));

        Number parsedNumber = (Number) parsed;
        if (!(parsedNumber instanceof Integer))
            throw new MarshalException(String.format("Expected an int value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));

        return new Constants.Value(getSerializer().serialize(parsedNumber.intValue()));
    }
    catch (ClassCastException exc)
    {
        throw new MarshalException(String.format(
                "Expected an int value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:Int32Type.java


示例14: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
  // Return an empty ByteBuffer for an empty string.
  if (source.isEmpty())
      return ByteBufferUtil.EMPTY_BYTE_BUFFER;

  Double d;
  try
  {
      d = Double.valueOf(source);
  }
  catch (NumberFormatException e1)
  {
      throw new MarshalException(String.format("Unable to make double from '%s'", source), e1);
  }

  return decompose(d);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:DoubleType.java


示例15: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    try
    {
        if (parsed instanceof String)
            return new Constants.Value(fromString((String) parsed));
        else
            return new Constants.Value(getSerializer().serialize(((Number) parsed).doubleValue()));
    }
    catch (ClassCastException exc)
    {
        throw new MarshalException(String.format(
                "Expected a double value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:17,代码来源:DoubleType.java


示例16: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
    // Return an empty ByteBuffer for an empty string.
    if (source.isEmpty())
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    short s;

    try
    {
        s = Short.parseShort(source);
    }
    catch (Exception e)
    {
        throw new MarshalException(String.format("Unable to make short from '%s'", source), e);
    }

    return decompose(s);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:ShortType.java


示例17: fromString

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
public ByteBuffer fromString(String source) throws MarshalException
{
    // Return an empty ByteBuffer for an empty string.
    if (source.isEmpty())
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    byte b;

    try
    {
        b = Byte.parseByte(source);
    }
    catch (Exception e)
    {
        throw new MarshalException(String.format("Unable to make byte from '%s'", source), e);
    }

    return decompose(b);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:ByteType.java


示例18: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    if (parsed instanceof String)
        parsed = Json.decodeJson((String) parsed);

    if (!(parsed instanceof List))
        throw new MarshalException(String.format(
                "Expected a list (representing a set), but got a %s: %s", parsed.getClass().getSimpleName(), parsed));

    List list = (List) parsed;
    Set<Term> terms = new HashSet<>(list.size());
    for (Object element : list)
    {
        if (element == null)
            throw new MarshalException("Invalid null element in set");
        terms.add(elements.fromJSONObject(element));
    }

    return new Sets.DelayedValue(elements, terms);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:22,代码来源:SetType.java


示例19: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    if (parsed instanceof Long)
        return new Constants.Value(ByteBufferUtil.bytes((Long) parsed));

    try
    {
        return new Constants.Value(TimestampType.instance.fromString((String) parsed));
    }
    catch (ClassCastException exc)
    {
        throw new MarshalException(String.format(
                "Expected a long or a datestring representation of a timestamp value, but got a %s: %s",
                parsed.getClass().getSimpleName(), parsed));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:TimestampType.java


示例20: fromJSONObject

import org.apache.cassandra.serializers.MarshalException; //导入依赖的package包/类
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
    if (parsed instanceof String)
        parsed = Json.decodeJson((String) parsed);

    if (!(parsed instanceof List))
        throw new MarshalException(String.format(
                "Expected a list, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));

    List list = (List) parsed;
    List<Term> terms = new ArrayList<>(list.size());
    for (Object element : list)
    {
        if (element == null)
            throw new MarshalException("Invalid null element in list");
        terms.add(elements.fromJSONObject(element));
    }

    return new Lists.DelayedValue(terms);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:22,代码来源:ListType.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java LevelDB类代码示例发布时间:2022-05-22
下一篇:
Java DocWriteResponse类代码示例发布时间: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