while (cursor.hasNext()) { VPackSlice aDocument = cursor.next(); HashMap<String, ByteIterator> aMap = new HashMap<String, ByteIterator>(aDocument.size()); if (!this.fillMap(aMap, aDocument)) { return Status.ERROR;
@Override public boolean hasNext() { return pos < result.getResult().size() || result.getHasMore(); }
private Object readMap(final TypeInformation<?> type, final VPackSlice source) { if (!source.isObject()) { throw new MappingException( String.format("Can't read map type %s from VPack type %s!", type, source.getType())); } final Class<?> keyType = getNonNullComponentType(type).getType(); final TypeInformation<?> valueType = getNonNullMapValueType(type); final Map<Object, Object> map = CollectionFactory.createMap(type.getType(), keyType, source.size()); final Iterator<Entry<String, VPackSlice>> iterator = source.objectIterator(); while (iterator.hasNext()) { final Entry<String, VPackSlice> entry = iterator.next(); if (typeMapper.isTypeKey(entry.getKey())) { continue; } final Object key = convertIfNecessary(entry.getKey(), keyType); final VPackSlice value = entry.getValue(); map.put(key, readInternal(valueType, value)); } return map; }
private Object readMap(final TypeInformation<?> type, final VPackSlice source) { if (!source.isObject()) { throw new MappingException( String.format("Can't read map type %s from VPack type %s!", type, source.getType())); } final Class<?> keyType = getNonNullComponentType(type).getType(); final TypeInformation<?> valueType = getNonNullMapValueType(type); final Map<Object, Object> map = CollectionFactory.createMap(type.getType(), keyType, source.size()); final Iterator<Entry<String, VPackSlice>> iterator = source.objectIterator(); while (iterator.hasNext()) { final Entry<String, VPackSlice> entry = iterator.next(); if (typeMapper.isTypeKey(entry.getKey())) { continue; } final Object key = convertIfNecessary(entry.getKey(), keyType); final VPackSlice value = entry.getValue(); map.put(key, readInternal(valueType, value)); } return map; }
@Override public VPackSlice deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException { if (p instanceof VPackParser) { final VPackSlice vpack = ((VPackParser) p).getVPack(); // consume each element if (vpack.isArray() || vpack.isObject()) { for (int i = 0; i < vpack.size() + 1; i++) { p.nextToken(); } } return vpack; } return new VPackSlice(p.getBinaryValue()); } };
@Override public T next() { if (pos >= result.getResult().size() && result.getHasMore()) { result = execute.next(cursor.getId()); pos = 0; } if (!hasNext()) { throw new NoSuchElementException(); } return deserialize(result.getResult().get(pos++), cursor.getType()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Response deserialize( final VPackSlice parent, final VPackSlice vpack, final VPackDeserializationContext context) throws VPackException { final Response response = new Response(); response.setVersion(vpack.get(0).getAsInt()); response.setType(vpack.get(1).getAsInt()); response.setResponseCode(vpack.get(2).getAsInt()); if (vpack.size() > 3) { response.setMeta((Map) context.deserialize(vpack.get(3), Map.class)); } return response; } };