usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [13/52] [abbrv] git commit: abstract uuid creation
Date Wed, 03 Sep 2014 22:11:08 GMT
abstract uuid creation


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1d74ec00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1d74ec00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1d74ec00

Branch: refs/heads/two-dot-o-push-notifications
Commit: 1d74ec00ea9b8052f3fce882ccf0ad7112d34c8b
Parents: 64ad13d
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue Aug 26 16:36:18 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Thu Aug 28 09:30:23 2014 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManager.java       | 12 +++---------
 .../usergrid/corepersistence/CpRelationManager.java     |  4 ++--
 .../main/java/org/apache/usergrid/utils/UUIDUtils.java  | 11 +++++++++++
 3 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index f40bc3b..7e1f199 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -1595,7 +1595,7 @@ public class CpEntityManager implements EntityManager {
             throws Exception {
 
         UUID timestampUuid = UUIDUtils.newTimeUUID();
-        long timestamp = UUIDUtils.getTimestampInMicros( timestampUuid );
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         Map<String, Object> properties = new TreeMap<>( CASE_INSENSITIVE_ORDER
);
         properties.put( PROPERTY_TYPE, Role.ENTITY_TYPE );
@@ -2364,13 +2364,7 @@ public class CpEntityManager implements EntityManager {
             return null;
         }
 
-        long timestamp = 0;
-
-        if(UUIDUtils.isTimeBased(timestampUuid)) {
-            timestamp = UUIDUtils.getTimestampInMicros(timestampUuid);
-        }else{
-            timestamp = MurmurHash.hash64(timestampUuid);
-        }
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         UUID itemId = UUIDUtils.newTimeUUID();
 
@@ -2623,7 +2617,7 @@ public class CpEntityManager implements EntityManager {
             boolean removeFromDictionary, UUID timestampUuid )
             throws Exception {
 
-        long timestamp = UUIDUtils.getTimestampInMicros( timestampUuid );
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         // dictionaryName = dictionaryName.toLowerCase();
         if ( elementCoValue == null ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 9199d19..4131400 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -28,7 +28,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import com.clearspring.analytics.hash.MurmurHash;
+import org.apache.usergrid.utils.UUIDUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -686,7 +686,7 @@ public class CpRelationManager implements RelationManager {
                 headEntity.getType(), headEntity.getUuid(), 
                 itemRef.getType(), itemRef.getUuid() });
 
-        long uuidHash = MurmurHash.hash64( memberEntity.getId().getUuid());
+        long uuidHash =   UUIDUtils.getUUIDLong( memberEntity.getId().getUuid());
         // create graph edge connection from head entity to member entity
         Edge edge = new SimpleEdge(
             cpHeadEntity.getId(),

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java b/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
index 6d8175c..ecb1f61 100644
--- a/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantLock;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import com.fasterxml.uuid.EthernetAddress;
 import com.fasterxml.uuid.UUIDComparator;
 
@@ -379,6 +380,16 @@ public class UUIDUtils {
         return tryGetUUID( s.substring( offset, offset + 36 ) );
     }
 
+    public static long getUUIDLong(UUID id){
+        long timestamp = 0;
+        if(UUIDUtils.isTimeBased(id)) {
+            timestamp = UUIDUtils.getTimestampInMicros(id);
+        }else{
+            timestamp = MurmurHash.hash64(id);
+        }
+        return timestamp;
+    }
+
 
     public static String toBase64( UUID id ) {
         if ( id == null ) {


Mime
View raw message