Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonToken#END_OBJECT

The following examples show how to use org.apache.tinkerpop.shaded.jackson.core.JsonToken#END_OBJECT . 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: TraversalSerializersV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public TextP deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String predicate = null;
    String value = null;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.PREDICATE)) {
            jsonParser.nextToken();
            predicate = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            value = deserializationContext.readValue(jsonParser, String.class);
        }
    }

    try {
        return (TextP) TextP.class.getMethod(predicate, String.class).invoke(null, value);
    } catch (final Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example 2
Source File: TinkerIoRegistryV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example 3
Source File: TraversalSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public Traverser deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    long bulk = 1;
    Object v = null;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.BULK)) {
            jsonParser.nextToken();
            bulk = deserializationContext.readValue(jsonParser, Long.class);
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            v = deserializationContext.readValue(jsonParser, Object.class);
        }
    }

    return new DefaultRemoteTraverser<>(v, bulk);
}
 
Example 4
Source File: TraversalSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public TextP deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String predicate = null;
    String value = null;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.PREDICATE)) {
            jsonParser.nextToken();
            predicate = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            value = deserializationContext.readValue(jsonParser, String.class);
        }
    }

    try {
        return (TextP) TextP.class.getMethod(predicate, String.class).invoke(null, value);
    } catch (final Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example 5
Source File: TraversalSerializersV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public Traverser deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    long bulk = 1;
    Object v = null;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.BULK)) {
            jsonParser.nextToken();
            bulk = deserializationContext.readValue(jsonParser, Long.class);
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            v = deserializationContext.readValue(jsonParser, Object.class);
        }
    }

    return new DefaultRemoteTraverser<>(v, bulk);
}
 
Example 6
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public Property deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String key = null;
    Object value = null;
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) {
            jsonParser.nextToken();
            key = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            value = deserializationContext.readValue(jsonParser, Object.class);
        }
    }

    return new DetachedProperty<>(key, value);
}
 
Example 7
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public Path deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Path p = MutablePath.make();

    List<Object> labels = new ArrayList<>();
    List<Object> objects = new ArrayList<>();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.LABELS)) {
            jsonParser.nextToken();
            labels = deserializationContext.readValue(jsonParser, List.class);
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OBJECTS)) {
            jsonParser.nextToken();
            objects = deserializationContext.readValue(jsonParser, List.class);
        }
    }

    for (int i = 0; i < objects.size(); i++) {
        p.extend(objects.get(i), (Set<String>) labels.get(i));
    }

    return p;
}
 
Example 8
Source File: TinkerIoRegistryV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example 9
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertex.Builder v = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            v.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            v.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class));
                }
            }
        }
    }

    return v.create();
}
 
Example 10
Source File: TinkerIoRegistryV2d0.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example 11
Source File: TinkerIoRegistryV3d0.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example 12
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            vp.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            vp.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            vp.setValue(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                final String key = jsonParser.getCurrentName();
                jsonParser.nextToken();
                final Object val = deserializationContext.readValue(jsonParser, Object.class);
                vp.addProperty(new DetachedProperty(key, val));
            }
        }
    }

    return vp.create();
}
 
Example 13
Source File: TraversalSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Bytecode bytecode = new Bytecode();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        final String current = jsonParser.getCurrentName();
        if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) {
            jsonParser.nextToken();

            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {

                // there should be a list now and the first item in the list is always string and is the step name
                // skip the start array
                jsonParser.nextToken();
                
                final String stepName = jsonParser.getText();

                // iterate through the rest of the list for arguments until it gets to the end
                final List<Object> arguments = new ArrayList<>();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    // we don't know the types here, so let the deserializer figure that business out
                    arguments.add(deserializationContext.readValue(jsonParser, Object.class));
                }

                // if it's not a "source" then it must be a "step"
                if (current.equals(GraphSONTokens.SOURCE))
                    bytecode.addSource(stepName, arguments.toArray());
                else
                    bytecode.addStep(stepName, arguments.toArray());
            }
        }
    }
    return bytecode;
}
 
Example 14
Source File: HugeResource.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Override
public HugeResource deserialize(JsonParser parser,
                                DeserializationContext ctxt)
                                throws IOException {
    HugeResource res = new HugeResource();
    while (parser.nextToken() != JsonToken.END_OBJECT) {
        String key = parser.getCurrentName();
        if (key.equals("type")) {
            if (parser.nextToken() != JsonToken.VALUE_NULL) {
                res.type = ctxt.readValue(parser, ResourceType.class);
            } else {
                res.type = null;
            }
        } else if (key.equals("label")) {
            if (parser.nextToken() != JsonToken.VALUE_NULL) {
                res.label = parser.getValueAsString();
            } else {
                res.label = null;
            }
        } else if (key.equals("properties")) {
            if (parser.nextToken() != JsonToken.VALUE_NULL) {
                @SuppressWarnings("unchecked")
                Map<String, Object> prop = ctxt.readValue(parser,
                                                          Map.class);
                res.properties = prop;
            } else {
                res.properties = null;
            }
        }
    }
    res.checkFormat();
    return res;
}
 
Example 15
Source File: TraversalSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Lambda deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String script = null;
    String language = null;
    int arguments = -1;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.SCRIPT)) {
            jsonParser.nextToken();
            script = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LANGUAGE)) {
            jsonParser.nextToken();
            language = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.ARGUMENTS)) {
            jsonParser.nextToken();
            arguments = jsonParser.getIntValue();
        }
    }

    if (-1 == arguments || arguments > 2)
        return new Lambda.UnknownArgLambda(script, language, arguments);
    else if (0 == arguments)
        return new Lambda.ZeroArgLambda<>(script, language);
    else if (1 == arguments)
        return new Lambda.OneArgLambda<>(script, language);
    else
        return new Lambda.TwoArgLambda<>(script, language);
}
 
Example 16
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Edge deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedEdge.Builder e = DetachedEdge.build();
    final DetachedVertex.Builder inV = DetachedVertex.build();
    final DetachedVertex.Builder outV = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            e.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            e.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT)) {
            jsonParser.nextToken();
            outV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT_LABEL)) {
            jsonParser.nextToken();
            outV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN)) {
            jsonParser.nextToken();
            inV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN_LABEL)) {
            jsonParser.nextToken();
            inV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                e.addProperty(deserializationContext.readValue(jsonParser, Property.class));
            }
        }
    }

    e.setInV(inV.create());
    e.setOutV(outV.create());

    return e.create();
}
 
Example 17
Source File: TraversalSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Bytecode bytecode = new Bytecode();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        final String current = jsonParser.getCurrentName();
        if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) {
            jsonParser.nextToken();

            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {

                // there should be a list now and the first item in the list is always string and is the step name
                // skip the start array
                jsonParser.nextToken();

                final String stepName = jsonParser.getText();

                // iterate through the rest of the list for arguments until it gets to the end
                final List<Object> arguments = new ArrayList<>();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    // we don't know the types here, so let the deserializer figure that business out
                    arguments.add(deserializationContext.readValue(jsonParser, Object.class));
                }

                // if it's not a "source" then it must be a "step"
                if (current.equals(GraphSONTokens.SOURCE))
                    bytecode.addSource(stepName, arguments.toArray());
                else
                    bytecode.addStep(stepName, arguments.toArray());
            }
        }
    }
    return bytecode;
}
 
Example 18
Source File: TraversalSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Lambda deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String script = null;
    String language = null;
    int arguments = -1;

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.SCRIPT)) {
            jsonParser.nextToken();
            script = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LANGUAGE)) {
            jsonParser.nextToken();
            language = jsonParser.getText();
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.ARGUMENTS)) {
            jsonParser.nextToken();
            arguments = jsonParser.getIntValue();
        }
    }

    if (-1 == arguments || arguments > 2)
        return new Lambda.UnknownArgLambda(script, language, arguments);
    else if (0 == arguments)
        return new Lambda.ZeroArgLambda<>(script, language);
    else if (1 == arguments)
        return new Lambda.OneArgLambda<>(script, language);
    else
        return new Lambda.TwoArgLambda<>(script, language);
}
 
Example 19
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            vp.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            vp.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            vp.setValue(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                final String key = jsonParser.getCurrentName();
                jsonParser.nextToken();
                final Object val = deserializationContext.readValue(jsonParser, Object.class);
                vp.addProperty(new DetachedProperty(key, val));
            }
        }
    }

    return vp.create();
}
 
Example 20
Source File: AtlasGraphSONReader.java    From atlas with Apache License 2.0 4 votes vote down vote up
public void readGraph(final InputStream inputStream) throws IOException {
    counter = new AtomicLong(0);

    final long        startIndex = initStatusManager();
    final JsonFactory factory    = mapper.getFactory();

    LOG.info("AtlasGraphSONReader.readGraph: numWorkers: {}: batchSize: {}: startIndex: {}", numWorkers, batchSize, startIndex);

    try (JsonParser parser = factory.createParser(inputStream)) {
        if (parser.nextToken() != JsonToken.START_OBJECT) {
            throw new IOException("Expected data to start with an Object");
        }

        readerStatusManager.update(bulkLoadGraph, counter.get(), ReaderStatusManager.STATUS_IN_PROGRESS);

        while (parser.nextToken() != JsonToken.END_OBJECT) {
            final String fieldName = parser.getCurrentName() == null ? "" : parser.getCurrentName();

            switch (fieldName) {
                case GraphSONTokensTP2.MODE:
                    parser.nextToken();

                    final String mode = parser.getText();

                    if (!mode.equals("EXTENDED")) {
                        throw new IllegalStateException("The legacy GraphSON must be generated with GraphSONMode.EXTENDED");
                    }

                    counter.getAndIncrement();
                    break;

                case GraphSONTokensTP2.VERTICES:
                    processElement(parser, new JsonNodeParsers.ParseVertex(), startIndex);
                    break;

                case GraphSONTokensTP2.EDGES:
                    processElement(parser, new JsonNodeParsers.ParseEdge(), startIndex);
                    break;

                case GraphSONTokensTP2.VERTEX_COUNT:
                    parser.nextToken();
                    LOG.info("Vertex count: {}", parser.getLongValue());
                    break;

                case GraphSONTokensTP2.EDGE_COUNT:
                    parser.nextToken();
                    LOG.info("Edge count: {}", parser.getLongValue());
                    break;

                default:
                    throw new IllegalStateException(String.format("Unexpected token in GraphSON - %s", fieldName));
            }
        }

        postProcess(startIndex);

        readerStatusManager.end(bulkLoadGraph, counter.get(), ReaderStatusManager.STATUS_SUCCESS);
    } catch (Exception ex) {
        readerStatusManager.end(bulkLoadGraph, counter.get(), ReaderStatusManager.STATUS_FAILED);
        throw new IOException(ex);
    } finally {
        LOG.info("AtlasGraphSONReader.readGraph: Done!: {}", counter.get());
    }
}