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


Java MarshalException类代码示例

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


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


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