org.msgpack.value.ImmutableValue Java Examples
The following examples show how to use
org.msgpack.value.ImmutableValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessagePackDeserializer.java From attic-polygene-java with Apache License 2.0 | 6 votes |
@Override public <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream state ) { try( MessageUnpacker unpacker = MessagePack.newDefaultUnpacker( state ) ) { if( !unpacker.hasNext() ) { return null; } ImmutableValue value = unpacker.unpackValue(); return doDeserialize( module, valueType, value ); } catch( IOException ex ) { throw new SerializationException( "Unable to deserialize " + valueType, ex ); } }
Example #2
Source File: BufferForFluentdTest.java From fluency with Apache License 2.0 | 4 votes |
private void analyzeResult(String tag, ImmutableValue timestamp, Map<String, Object> data, long start, long end, boolean eventTime) { Integer count = tagCounts.get(tag); if (count == null) { count = 0; } tagCounts.put(tag, count + 1); if (eventTime) { assertThat(timestamp.isExtensionValue(), is(true)); ExtensionValue tsInEventTime = timestamp.asExtensionValue(); assertThat(tsInEventTime.getType(), CoreMatchers.is((byte) 0x00)); ByteBuffer secondsAndNanoSeconds = ByteBuffer.wrap(tsInEventTime.getData()); int seconds = secondsAndNanoSeconds.getInt(); int nanoSeconds = secondsAndNanoSeconds.getInt(); assertTrue(start / 1000 <= seconds && seconds <= end / 1000); assertThat(nanoSeconds, is(999999999)); } else { assertThat(timestamp.isIntegerValue(), is(true)); long tsInEpochMilli = timestamp.asIntegerValue().asLong(); assertTrue(start <= tsInEpochMilli && tsInEpochMilli <= end); } assertEquals(3, data.size()); String name = (String) data.get("name"); int age = (Integer) data.get("age"); String comment = (String) data.get("comment"); if (name.compareTo(minName) < 0) { minName = name; } if (name.compareTo(maxName) > 0) { maxName = name; } if (age < minAge) { minAge = age; } if (age > maxAge) { maxAge = age; } if (comment.equals("hello")) { // expected } else if (comment.equals(longStr)) { longCommentCount++; } else { assertTrue(false); } }
Example #3
Source File: MsgpackGenerator.java From protostuff with Apache License 2.0 | 4 votes |
@Override public ImmutableValue immutableValue() { return new ImmutableArrayValueImpl(list.toArray(new Value[list.size()])); }