Java Code Examples for com.baidu.hugegraph.util.InsertionOrderUtil#newList()
The following examples show how to use
com.baidu.hugegraph.util.InsertionOrderUtil#newList() .
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: InsertionOrderUtilTest.java From hugegraph-common with Apache License 2.0 | 6 votes |
@Test public void testListCopy() { List<Integer> list = InsertionOrderUtil.newList(); list.add(4); list.add(2); list.add(5); list.add(1); list.add(3); Assert.assertEquals(ImmutableList.of(4, 2, 5, 1, 3), ImmutableList.copyOf(list)); List<Integer> list2 = InsertionOrderUtil.newList(list); list2.add(6); list2.add(1); Assert.assertEquals(ImmutableList.of(4, 2, 5, 1, 3, 6, 1), ImmutableList.copyOf(list2)); Assert.assertEquals(ImmutableList.of(4, 2, 5, 1, 3), ImmutableList.copyOf(list)); }
Example 2
Source File: ListIterator.java From hugegraph-common with Apache License 2.0 | 5 votes |
public ListIterator(long capacity, Iterator<T> origin) { List<T> results = InsertionOrderUtil.newList(); while (origin.hasNext()) { if (capacity >= 0L && results.size() >= capacity) { throw new IllegalArgumentException( "The iterator exceeded capacity " + capacity); } results.add(origin.next()); } this.originIterator = origin; this.results = Collections.unmodifiableList(results); this.resultsIterator = this.results.iterator(); }
Example 3
Source File: BatchMapperIterator.java From hugegraph-common with Apache License 2.0 | 5 votes |
protected final List<T> nextBatch() { if (!this.originIterator.hasNext()) { return ImmutableList.of(); } List<T> list = InsertionOrderUtil.newList(); for (int i = 0; i < this.batch && this.originIterator.hasNext(); i++) { T next = this.originIterator.next(); list.add(next); } return list; }
Example 4
Source File: InsertionOrderUtilTest.java From hugegraph-common with Apache License 2.0 | 5 votes |
@Test public void testList() { List<Integer> list = InsertionOrderUtil.newList(); list.add(4); list.add(2); list.add(5); list.add(1); list.add(3); Assert.assertEquals(ImmutableList.of(4, 2, 5, 1, 3), ImmutableList.copyOf(list)); }
Example 5
Source File: InsertionOrderUtilTest.java From hugegraph-common with Apache License 2.0 | 5 votes |
@Test public void testListWithInitialCapacity() { List<Integer> list = InsertionOrderUtil.newList(3); list.add(4); list.add(2); list.add(5); list.add(1); list.add(3); Assert.assertEquals(ImmutableList.of(4, 2, 5, 1, 3), ImmutableList.copyOf(list)); }
Example 6
Source File: OffheapCache.java From hugegraph with Apache License 2.0 | 5 votes |
private List<Object> deserializeList(BytesBuffer buffer) { // Read list int length = buffer.readVInt(); List<Object> list = InsertionOrderUtil.newList(); for (int i = 0; i < length; i++) { list.add(this.deserialize(buffer)); } return list; }
Example 7
Source File: DataTypeUtil.java From hugegraph-loader with Apache License 2.0 | 5 votes |
/** * collection format: "obj1,obj2,...,objn" or "[obj1,obj2,...,objn]" ..etc * TODO: After parsing to json, the order of the collection changed * in some cases (such as list<date>) **/ private static Object parseMultiValues(String key, Object values, DataType dataType, Cardinality cardinality, InputSource source) { // JSON file should not parse again if (values instanceof Collection && checkCollectionDataType(key, (Collection<?>) values, dataType)) { return values; } E.checkState(values instanceof String, "The value(key='%s') must be String type, but got '%s'(%s)", key, values); String rawValue = (String) values; List<Object> valueColl = split(key, rawValue, source); Collection<Object> results = cardinality == Cardinality.LIST ? InsertionOrderUtil.newList() : InsertionOrderUtil.newSet(); valueColl.forEach(value -> { results.add(parseSingleValue(key, value, dataType, source)); }); E.checkArgument(checkCollectionDataType(key, results, dataType), "Not all collection elems %s match with data type %s", results, dataType); return results; }
Example 8
Source File: QueryResults.java From hugegraph with Apache License 2.0 | 4 votes |
public QueryResults(Iterator<R> results) { this.results = results; this.queries = InsertionOrderUtil.newList(); }
Example 9
Source File: TableDefine.java From hugegraph with Apache License 2.0 | 4 votes |
public TableDefine() { this.columns = InsertionOrderUtil.newMap(); this.keys = InsertionOrderUtil.newList(); this.typesMapping = ImmutableMap.of(); }
Example 10
Source File: TableDefine.java From hugegraph with Apache License 2.0 | 4 votes |
public TableDefine(Map<String, String> typesMapping) { this.columns = InsertionOrderUtil.newMap(); this.keys = InsertionOrderUtil.newList(); this.typesMapping = typesMapping; }