From 4aae65cd4d4fd6a84d9b45df1398435d641ea463 Mon Sep 17 00:00:00 2001 From: liningrui Date: Wed, 20 Jun 2018 17:06:55 +0800 Subject: [PATCH] HugeGraph-81: Small optimization of package structure Change-Id: I84109719a0064ea0d53c26843fbe435b84655912 --- pom.xml | 4 +- .../hugegraph/{type => func}/TriFunction.java | 2 +- .../com/baidu/hugegraph/perf/PerfUtil.java | 2 +- .../java/com/baidu/hugegraph/type/Shard.java | 71 ------------------- .../hugegraph/util/InsertionOrderUtil.java | 54 ++++++++++++++ 5 files changed, 58 insertions(+), 75 deletions(-) rename src/main/java/com/baidu/hugegraph/{type => func}/TriFunction.java (96%) delete mode 100644 src/main/java/com/baidu/hugegraph/type/Shard.java create mode 100644 src/main/java/com/baidu/hugegraph/util/InsertionOrderUtil.java diff --git a/pom.xml b/pom.xml index e3a096892..ce3ed0651 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidu.hugegraph hugegraph-common - 1.4.4-SNAPSHOT + 1.4.5-SNAPSHOT @@ -169,7 +169,7 @@ - 1.4.4.0 + 1.4.5.0 diff --git a/src/main/java/com/baidu/hugegraph/type/TriFunction.java b/src/main/java/com/baidu/hugegraph/func/TriFunction.java similarity index 96% rename from src/main/java/com/baidu/hugegraph/type/TriFunction.java rename to src/main/java/com/baidu/hugegraph/func/TriFunction.java index 58a345455..555a0ee46 100644 --- a/src/main/java/com/baidu/hugegraph/type/TriFunction.java +++ b/src/main/java/com/baidu/hugegraph/func/TriFunction.java @@ -17,7 +17,7 @@ * under the License. */ -package com.baidu.hugegraph.type; +package com.baidu.hugegraph.func; public interface TriFunction { public R apply(T1 v1, T2 v2, T3 v3); diff --git a/src/main/java/com/baidu/hugegraph/perf/PerfUtil.java b/src/main/java/com/baidu/hugegraph/perf/PerfUtil.java index 2b6c13ac5..7335e984e 100644 --- a/src/main/java/com/baidu/hugegraph/perf/PerfUtil.java +++ b/src/main/java/com/baidu/hugegraph/perf/PerfUtil.java @@ -38,7 +38,7 @@ import java.util.stream.Stream; import org.slf4j.Logger; -import com.baidu.hugegraph.type.TriFunction; +import com.baidu.hugegraph.func.TriFunction; import com.baidu.hugegraph.util.Log; import com.baidu.hugegraph.util.ReflectionUtil; import com.google.common.reflect.ClassPath.ClassInfo; diff --git a/src/main/java/com/baidu/hugegraph/type/Shard.java b/src/main/java/com/baidu/hugegraph/type/Shard.java deleted file mode 100644 index 406550c4a..000000000 --- a/src/main/java/com/baidu/hugegraph/type/Shard.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2017 HugeGraph Authors - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package com.baidu.hugegraph.type; - -/** - * Shard is used for backend storage (like cassandra, hbase) scanning - * operations. Each shard represents a range of tokens for a node. - * Reading data from a given shard does not cross multiple nodes. - */ -public class Shard { - - // token range start - private String start; - // token range end - private String end; - // partitions count in this range - private long length; - - public Shard(String start, String end, long length) { - this.start = start; - this.end = end; - this.length = length; - } - - public String start() { - return this.start; - } - - public void start(String start) { - this.start = start; - } - - public String end() { - return this.end; - } - - public void end(String end) { - this.end = end; - } - - public long length() { - return this.length; - } - - public void length(long length) { - this.length = length; - } - - @Override - public String toString() { - return String.format("Shard{start=%s, end=%s, length=%s}", - this.start, this.end, this.length); - } -} \ No newline at end of file diff --git a/src/main/java/com/baidu/hugegraph/util/InsertionOrderUtil.java b/src/main/java/com/baidu/hugegraph/util/InsertionOrderUtil.java new file mode 100644 index 000000000..3f235a485 --- /dev/null +++ b/src/main/java/com/baidu/hugegraph/util/InsertionOrderUtil.java @@ -0,0 +1,54 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package com.baidu.hugegraph.util; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public final class InsertionOrderUtil { + + public static Map newMap() { + return new LinkedHashMap<>(); + } + + public static Map newMap(Map origin) { + return new LinkedHashMap<>(origin); + } + + public static Set newSet() { + return new LinkedHashSet<>(); + } + + public static Set newSet(Set origin) { + return new LinkedHashSet<>(origin); + } + + public static List newList() { + return new ArrayList<>(); + } + + public static List newList(List origin) { + return new ArrayList<>(origin); + } +}