Skip to content

Commit

Permalink
Update ga thrift files and modify the version (#278)
Browse files Browse the repository at this point in the history
* update ga thrift files and modiry version

* Add interface description

* modify version
  • Loading branch information
laura-ding authored Mar 23, 2021
1 parent c4ce908 commit 15e2845
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ There are the version correspondence between client and Nebula:
| 1.1.0 | 1.1.0,1.2.0 |
| 2.0.0-beta | 2.0.0-beta |
| 2.0.0-rc1 | 2.0.0-rc1 |
| 2.0.0-ga | 2.0.0-ga |
| 2.0.0-SNAPSHOT| 2.0.0-nightly |

## Graph client example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ErrorCode {
public static final int E_BAD_PERMISSION = -11;
public static final int E_SEMANTIC_ERROR = -12;
public static final int E_TOO_MANY_CONNECTIONS = -13;
public static final int E_PARTIAL_SUCCEEDED = -14;

public static final IntRangeSet VALID_VALUES;
public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,21 @@ public class PlanDescription implements TBase, java.io.Serializable, Cloneable,
private static final TField PLAN_NODE_DESCS_FIELD_DESC = new TField("plan_node_descs", TType.LIST, (short)1);
private static final TField NODE_INDEX_MAP_FIELD_DESC = new TField("node_index_map", TType.MAP, (short)2);
private static final TField FORMAT_FIELD_DESC = new TField("format", TType.STRING, (short)3);
private static final TField OPTIMIZE_TIME_IN_US_FIELD_DESC = new TField("optimize_time_in_us", TType.I32, (short)4);

public List<PlanNodeDescription> plan_node_descs;
public Map<Long,Long> node_index_map;
public byte[] format;
public int optimize_time_in_us;
public static final int PLAN_NODE_DESCS = 1;
public static final int NODE_INDEX_MAP = 2;
public static final int FORMAT = 3;
public static final int OPTIMIZE_TIME_IN_US = 4;
public static boolean DEFAULT_PRETTY_PRINT = true;

// isset id assignments
private static final int __OPTIMIZE_TIME_IN_US_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);

public static final Map<Integer, FieldMetaData> metaDataMap;
static {
Expand All @@ -55,6 +60,8 @@ public class PlanDescription implements TBase, java.io.Serializable, Cloneable,
new FieldValueMetaData(TType.I64))));
tmpMetaDataMap.put(FORMAT, new FieldMetaData("format", TFieldRequirementType.REQUIRED,
new FieldValueMetaData(TType.STRING)));
tmpMetaDataMap.put(OPTIMIZE_TIME_IN_US, new FieldMetaData("optimize_time_in_us", TFieldRequirementType.REQUIRED,
new FieldValueMetaData(TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
}

Expand All @@ -68,18 +75,23 @@ public PlanDescription() {
public PlanDescription(
List<PlanNodeDescription> plan_node_descs,
Map<Long,Long> node_index_map,
byte[] format)
byte[] format,
int optimize_time_in_us)
{
this();
this.plan_node_descs = plan_node_descs;
this.node_index_map = node_index_map;
this.format = format;
this.optimize_time_in_us = optimize_time_in_us;
setOptimize_time_in_usIsSet(true);
}

/**
* Performs a deep copy on <i>other</i>.
*/
public PlanDescription(PlanDescription other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetPlan_node_descs()) {
this.plan_node_descs = TBaseHelper.deepCopy(other.plan_node_descs);
}
Expand All @@ -89,6 +101,7 @@ public PlanDescription(PlanDescription other) {
if (other.isSetFormat()) {
this.format = TBaseHelper.deepCopy(other.format);
}
this.optimize_time_in_us = TBaseHelper.deepCopy(other.optimize_time_in_us);
}

public PlanDescription deepCopy() {
Expand Down Expand Up @@ -172,6 +185,29 @@ public void setFormatIsSet(boolean value) {
}
}

public int getOptimize_time_in_us() {
return this.optimize_time_in_us;
}

public PlanDescription setOptimize_time_in_us(int optimize_time_in_us) {
this.optimize_time_in_us = optimize_time_in_us;
setOptimize_time_in_usIsSet(true);
return this;
}

public void unsetOptimize_time_in_us() {
__isset_bit_vector.clear(__OPTIMIZE_TIME_IN_US_ISSET_ID);
}

// Returns true if field optimize_time_in_us is set (has been assigned a value) and false otherwise
public boolean isSetOptimize_time_in_us() {
return __isset_bit_vector.get(__OPTIMIZE_TIME_IN_US_ISSET_ID);
}

public void setOptimize_time_in_usIsSet(boolean value) {
__isset_bit_vector.set(__OPTIMIZE_TIME_IN_US_ISSET_ID, value);
}

@SuppressWarnings("unchecked")
public void setFieldValue(int fieldID, Object value) {
switch (fieldID) {
Expand Down Expand Up @@ -199,6 +235,14 @@ public void setFieldValue(int fieldID, Object value) {
}
break;

case OPTIMIZE_TIME_IN_US:
if (value == null) {
unsetOptimize_time_in_us();
} else {
setOptimize_time_in_us((Integer)value);
}
break;

default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
}
Expand All @@ -215,6 +259,9 @@ public Object getFieldValue(int fieldID) {
case FORMAT:
return getFormat();

case OPTIMIZE_TIME_IN_US:
return new Integer(getOptimize_time_in_us());

default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
}
Expand All @@ -229,6 +276,8 @@ public boolean isSet(int fieldID) {
return isSetNode_index_map();
case FORMAT:
return isSetFormat();
case OPTIMIZE_TIME_IN_US:
return isSetOptimize_time_in_us();
default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
}
Expand Down Expand Up @@ -276,6 +325,15 @@ public boolean equals(PlanDescription that) {
return false;
}

boolean this_present_optimize_time_in_us = true;
boolean that_present_optimize_time_in_us = true;
if (this_present_optimize_time_in_us || that_present_optimize_time_in_us) {
if (!(this_present_optimize_time_in_us && that_present_optimize_time_in_us))
return false;
if (!TBaseHelper.equalsNobinary(this.optimize_time_in_us, that.optimize_time_in_us))
return false;
}

return true;
}

Expand All @@ -298,6 +356,11 @@ public int hashCode() {
if (present_format)
builder.append(format);

boolean present_optimize_time_in_us = true;
builder.append(present_optimize_time_in_us);
if (present_optimize_time_in_us)
builder.append(optimize_time_in_us);

return builder.toHashCode();
}

Expand Down Expand Up @@ -337,6 +400,14 @@ public int compareTo(PlanDescription other) {
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = Boolean.valueOf(isSetOptimize_time_in_us()).compareTo(other.isSetOptimize_time_in_us());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(optimize_time_in_us, other.optimize_time_in_us);
if (lastComparison != 0) {
return lastComparison;
}
return 0;
}

Expand Down Expand Up @@ -399,6 +470,14 @@ public void read(TProtocol iprot) throws TException {
TProtocolUtil.skip(iprot, field.type);
}
break;
case OPTIMIZE_TIME_IN_US:
if (field.type == TType.I32) {
this.optimize_time_in_us = iprot.readI32();
setOptimize_time_in_usIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
break;
Expand All @@ -409,6 +488,9 @@ public void read(TProtocol iprot) throws TException {


// check for required fields of primitive type, which can't be checked in the validate method
if (!isSetOptimize_time_in_us()) {
throw new TProtocolException("Required field 'optimize_time_in_us' was not found in serialized data! Struct: " + toString());
}
validate();
}

Expand Down Expand Up @@ -444,6 +526,9 @@ public void write(TProtocol oprot) throws TException {
oprot.writeBinary(this.format);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(OPTIMIZE_TIME_IN_US_FIELD_DESC);
oprot.writeI32(this.optimize_time_in_us);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
Expand Down Expand Up @@ -506,6 +591,13 @@ public String toString(int indent, boolean prettyPrint) {
if (this. getFormat().length > 128) sb.append(" ...");
}
first = false;
if (!first) sb.append("," + newLine);
sb.append(indentStr);
sb.append("optimize_time_in_us");
sb.append(space);
sb.append(":").append(space);
sb.append(TBaseHelper.toString(this. getOptimize_time_in_us(), indent + 1, prettyPrint));
first = false;
sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
sb.append(")");
return sb.toString();
Expand All @@ -522,6 +614,7 @@ public void validate() throws TException {
if (format == null) {
throw new TProtocolException(TProtocolException.MISSING_REQUIRED_FIELD, "Required field 'format' was not present! Struct: " + toString());
}
// alas, we cannot check 'optimize_time_in_us' because it's a primitive and you chose the non-beans generator.
// check that fields of type enum have valid values
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AdminCmd {
public static final int REBUILD_EDGE_INDEX = 3;
public static final int STATS = 4;
public static final int DATA_BALANCE = 5;
public static final int DOWELOAD = 6;
public static final int INGEST = 7;
public static final int UNKNOWN = 99;

public static final IntRangeSet VALID_VALUES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ErrorCode {
public static final int E_FIELD_UNSET = -22;
public static final int E_OUT_OF_RANGE = -23;
public static final int E_ATOMIC_OP_FAILED = -24;
public static final int E_DATA_CONFLICT_ERROR = -25;
public static final int E_EDGE_PROP_NOT_FOUND = -31;
public static final int E_TAG_PROP_NOT_FOUND = -32;
public static final int E_IMPROPER_DATA_TYPE = -33;
Expand Down
16 changes: 16 additions & 0 deletions client/src/main/java/com/vesoft/nebula/client/graph/data/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public List<String> tagNames() {
return tagNames;
}

/**
* Used to be compatible with older versions of interfaces
* @return the list of tag name
*/
public List<String> labels() {
return tagNames;
}

/**
* determine if node contains the given tag
* @param tagName the tag name
Expand All @@ -59,6 +67,14 @@ public boolean hasTagName(String tagName) {
return tagNames.contains(tagName);
}

/**
* Used to be compatible with older versions of interfaces
* @return tboolean
*/
public boolean hasLabel(String tagName) {
return tagNames.contains(tagName);
}

/**
* get property values from the node
* @param tagName the tag name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,26 @@ public class StorageClient {
private final List<HostAddress> addresses;
private int timeout = 10000; // ms

/**
* @param ip the ip of metad server
* @param port the port of meted server
*/
public StorageClient(String ip, int port) {
this(Arrays.asList(new HostAddress(ip, port)));
}

/**
* @param addresses the address of metad server
*/
public StorageClient(List<HostAddress> addresses) {
this.connection = new GraphStorageConnection();
this.addresses = addresses;
}

/**
* @param addresses the address of metad server
* @param timeout the timeout of scan vertex or edge
*/
public StorageClient(List<HostAddress> addresses, int timeout) {
this.connection = new GraphStorageConnection();
this.addresses = addresses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class StorageClientExample {
private static final Logger LOGGER = LoggerFactory.getLogger(StorageClientExample.class);

public static void main(String[] args) {
// input params are the metad's ip and port
StorageClient client = new StorageClient("127.0.0.1", 9559);
try {
client.connect();
Expand Down

0 comments on commit 15e2845

Please sign in to comment.