6 package com.vesoft.nebula.client.storage.scan;
8 import com.vesoft.nebula.DataSet;
9 import com.vesoft.nebula.client.graph.data.ValueWrapper;
10 import com.vesoft.nebula.client.storage.data.ScanStatus;
11 import com.vesoft.nebula.client.storage.data.VertexRow;
12 import com.vesoft.nebula.client.storage.data.VertexTableRow;
13 import com.vesoft.nebula.client.storage.processor.VertexProcessor;
14 import java.io.Serializable;
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.List;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
24 private static final Logger LOGGER = LoggerFactory.getLogger(
ScanVertexResult.class);
25 private static final long serialVersionUID = -2446261806893848521L;
27 private final List<DataSet> dataSets;
34 private List<VertexTableRow> vertexTableRows =
new ArrayList<>();
39 private List<String> propNames =
new ArrayList<>();
44 private List<VertexRow> verticeRows =
new ArrayList<>();
46 private Map<ValueWrapper, VertexRow> vidVertices =
new HashMap<>();
48 private String decodeType =
"utf-8";
50 private boolean isEmpty;
53 this.dataSets = dataSets;
54 this.scanStatus = status;
55 this.isEmpty = isDatasetEmpty();
64 if (!isEmpty && vertexTableRows.isEmpty()) {
65 constructVertexTableRow();
67 return vertexTableRows;
76 if (!isEmpty && propNames.isEmpty()) {
89 if (!isEmpty && vidVertices.isEmpty()) {
92 if (vidVertices.isEmpty()) {
95 return vidVertices.get(vid);
104 if (!isEmpty && verticeRows.isEmpty()) {
105 constructVertexRow();
117 if (!isEmpty && vidVertices.isEmpty()) {
118 constructVertexRow();
147 private boolean isDatasetEmpty() {
148 if (dataSets ==
null || dataSets.isEmpty()) {
151 for (DataSet dataSet : dataSets) {
152 if (dataSet.getRows().size() > 0) {
162 private void constructVertexRow() {
166 synchronized (
this) {
167 if (vidVertices.isEmpty()) {
168 vidVertices = VertexProcessor.constructVertexRow(dataSets, decodeType);
169 verticeRows =
new ArrayList<>(vidVertices.values());
177 private void constructVertexTableRow() {
181 synchronized (
this) {
182 if (vertexTableRows.isEmpty()) {
183 vertexTableRows = VertexProcessor.constructVertexTableRow(dataSets, decodeType);
191 private void constructPropNames() {
195 synchronized (
this) {
196 if (propNames.isEmpty()) {
197 List<byte[]> colNames = dataSets.get(0).getColumn_names();
198 for (
byte[] colName : colNames) {
199 String propName =
new String(colName);
200 if (!propName.contains(
".")) {
203 propNames.add(propName.split(
"\\.")[1]);
List< String > getPropNames()
get the result's property names
boolean isAllSuccess()
get the result status
List< VertexTableRow > getVertexTableRows()
get vertex table rows
Map< ValueWrapper, VertexRow > getVidVertices()
get the map of vid and vertex row
boolean isEmpty()
whether result data is empty
List< VertexRow > getVertices()
get all vertex row
VertexRow getVertex(ValueWrapper vid)
get vertex row with id
ALL_SUCCESS
all parts succeed