summaryrefslogtreecommitdiffstats
path: root/document/src/main
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-08-09 14:50:24 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-08-09 14:50:24 +0000
commitdc5c52264607691021c9bc70aed8955d05d7af9d (patch)
tree18fb94c8cf0e89c36e92f49f22cdeae4b29eb6fd /document/src/main
parent840aacbbae61a4d0162d2decb534a6fe5fae030a (diff)
Remove legacy orderdoc, groupdoc, userdoc documentids
Diffstat (limited to 'document/src/main')
-rw-r--r--document/src/main/java/com/yahoo/document/BucketIdFactory.java7
-rw-r--r--document/src/main/java/com/yahoo/document/idstring/DocIdString.java2
-rw-r--r--document/src/main/java/com/yahoo/document/idstring/GroupDocIdString.java64
-rw-r--r--document/src/main/java/com/yahoo/document/idstring/IdString.java101
-rw-r--r--document/src/main/java/com/yahoo/document/idstring/OrderDocIdString.java116
-rw-r--r--document/src/main/java/com/yahoo/document/idstring/UserDocIdString.java59
6 files changed, 9 insertions, 340 deletions
diff --git a/document/src/main/java/com/yahoo/document/BucketIdFactory.java b/document/src/main/java/com/yahoo/document/BucketIdFactory.java
index 7ff09dd62e9..8ae769dbb11 100644
--- a/document/src/main/java/com/yahoo/document/BucketIdFactory.java
+++ b/document/src/main/java/com/yahoo/document/BucketIdFactory.java
@@ -89,15 +89,8 @@ public class BucketIdFactory {
public BucketId getBucketId(DocumentId doc) {
long location = doc.getScheme().getLocation();
byte[] gid = doc.getGlobalId();
-
long gidContribution = getGidContribution(gid);
- IdString.GidModifier gm = doc.getScheme().getGidModifier();
- if (gm != null && gm.usedBits != 0) {
- gidContribution &= (0xFFFFFFFFFFFFFFFFl << (gm.usedBits + getLocationBitCount()));
- gidContribution |= (gm.value << getLocationBitCount());
- }
-
return new BucketId(64 - BucketId.COUNT_BITS, initialCount | (gidMask & gidContribution) | (locationMask & location));
}
diff --git a/document/src/main/java/com/yahoo/document/idstring/DocIdString.java b/document/src/main/java/com/yahoo/document/idstring/DocIdString.java
index 7ce9d6150e2..09cc27d2c89 100644
--- a/document/src/main/java/com/yahoo/document/idstring/DocIdString.java
+++ b/document/src/main/java/com/yahoo/document/idstring/DocIdString.java
@@ -12,6 +12,8 @@ import java.security.NoSuchAlgorithmException;
*
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
*/
+//TODO Remove no later than Vespa 8
+@Deprecated
public class DocIdString extends IdString {
/**
* Create a doc scheme object.
diff --git a/document/src/main/java/com/yahoo/document/idstring/GroupDocIdString.java b/document/src/main/java/com/yahoo/document/idstring/GroupDocIdString.java
deleted file mode 100644
index ff975efa274..00000000000
--- a/document/src/main/java/com/yahoo/document/idstring/GroupDocIdString.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.document.idstring;
-
-import com.yahoo.collections.MD5;
-import com.yahoo.text.Utf8;
-
-import java.security.MessageDigest;
-
-/**
- * Representation of groupdoc scheme in document IDs.
- *
- * @author <a href="mailto:humbe@yahoo-inc.com">H&aring;kon Humberset</a>
- */
-public class GroupDocIdString extends IdString {
- String group;
-
- /**
- * Create a groupdoc scheme object.
- * <code>groupdoc:&lt;namespace&gt;:&lt;group&gt;:&lt;namespaceSpecific&gt;</code>
- *
- * @param namespace The namespace of this document id.
- * @param group The groupname of this groupdoc id.
- * @param namespaceSpecific The namespace specific part.
- */
- public GroupDocIdString(String namespace, String group, String namespaceSpecific) {
- super(Scheme.groupdoc, namespace, namespaceSpecific);
- this.group = group;
- }
-
- /**
- * Get the location of this document id. The location is used for distribution
- * in clusters. For the groupdoc scheme, the location is a hash of the groupname.
- *
- * @return The 64 bit location.
- */
- public long getLocation() {
- long result = 0;
- try{
- byte[] md5sum = MD5.md5.get().digest(Utf8.toBytes(group));
- for (int i=0; i<8; ++i) {
- result |= (md5sum[i] & 0xFFl) << (8*i);
- }
- } catch (Exception e) {
- e.printStackTrace(); // TODO: FIXME!
- }
- return result;
- }
-
- /** Get the scheme specific part. Which is for a groupdoc, is the groupdoc and a colon. */
- public String getSchemeSpecific() {
- return group + ":";
- }
-
- @Override
- public boolean hasGroup() {
- return true;
- }
-
- /** @return Get the groupname of this id. */
- @Override
- public String getGroup() {
- return group;
- }
-}
diff --git a/document/src/main/java/com/yahoo/document/idstring/IdString.java b/document/src/main/java/com/yahoo/document/idstring/IdString.java
index 0ca26f29e86..d988de60cdf 100644
--- a/document/src/main/java/com/yahoo/document/idstring/IdString.java
+++ b/document/src/main/java/com/yahoo/document/idstring/IdString.java
@@ -4,9 +4,6 @@ package com.yahoo.document.idstring;
import com.yahoo.text.Text;
import com.yahoo.text.Utf8String;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.util.OptionalInt;
/**
@@ -40,42 +37,11 @@ public abstract class IdString {
return "";
}
- public class GidModifier {
- public int usedBits;
- public long value;
- }
-
- public enum Scheme { doc, userdoc, groupdoc, orderdoc, id }
- final Scheme scheme;
- final String namespace;
- final String namespaceSpecific;
- Utf8String cache;
-
- public static int[] generateOrderDocParams(String scheme) {
- int parenPos = scheme.indexOf("(");
- int endParenPos = scheme.indexOf(")");
-
- if (parenPos == -1 || endParenPos == -1) {
- throw new IllegalArgumentException("Unparseable scheme " + scheme + ": Must be on the form orderdoc(width, division)");
- }
-
- String params = scheme.substring(parenPos + 1, endParenPos);
- String[] vals = params.split(",");
-
- if (vals.length != 2) {
- throw new IllegalArgumentException("Unparseable scheme " + scheme + ": Must be on the form orderdoc(width, division)");
- }
-
- int[] retVal = new int[2];
-
- try {
- retVal[0] = Integer.parseInt(vals[0]);
- retVal[1] = Integer.parseInt(vals[1]);
- return retVal;
- } catch (Exception e) {
- throw new IllegalArgumentException("Unparseable scheme " + scheme + ": Must be on the form orderdoc(width, division)");
- }
- }
+ public enum Scheme { doc, id }
+ private final Scheme scheme;
+ private final String namespace;
+ private final String namespaceSpecific;
+ private Utf8String cache;
/**
* Creates a IdString based on the given document id string.
@@ -113,11 +79,9 @@ public abstract class IdString {
}
}
+ @SuppressWarnings("deprecation")
private static IdString parseAndCreate(String id) {
String namespace;
- long userId;
- String group;
- long ordering;
int schemePos = id.indexOf(":");
if (schemePos < 0) {
@@ -158,58 +122,8 @@ public abstract class IdString {
currPos = colonPos + 1;
return new IdIdString(namespace, type, keyValues, id.substring(currPos));
- } if (schemeStr.equals("doc")) {
+ } else if (schemeStr.equals("doc")) {
return new DocIdString(namespace, id.substring(currPos));
- } else if (schemeStr.equals("userdoc")) {
- colonPos = id.indexOf(":", currPos);
- if (colonPos < 0) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': User id missing");
- }
-
- try {
- userId = new BigInteger(id.substring(currPos, colonPos)).longValue();
- } catch (IllegalArgumentException iae) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': " + iae.getMessage(), iae.getCause());
- }
-
- currPos = colonPos + 1;
- return new UserDocIdString(namespace, userId, id.substring(currPos));
- } else if (schemeStr.equals("groupdoc")) {
- colonPos = id.indexOf(":", currPos);
-
- if (colonPos < 0) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': Group id missing");
- }
-
- group = id.substring(currPos, colonPos);
- currPos = colonPos + 1;
- return new GroupDocIdString(namespace, group, id.substring(currPos));
- } else if (schemeStr.indexOf("orderdoc") == 0) {
- int[] params = generateOrderDocParams(schemeStr);
-
- colonPos = id.indexOf(":", currPos);
-
- if (colonPos < 0) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': Group id missing");
- }
-
- group = id.substring(currPos, colonPos);
-
- currPos = colonPos + 1;
-
- colonPos = id.indexOf(":", currPos);
- if (colonPos < 0) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': Ordering missing");
- }
-
- try {
- ordering = Long.parseLong(id.substring(currPos, colonPos));
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Unparseable id '" + id + "': " + e.getMessage(), e.getCause());
- }
-
- currPos = colonPos + 1;
- return new OrderDocIdString(namespace, group, params[0], params[1], ordering, id.substring(currPos));
} else {
throw new IllegalArgumentException("Unknown id scheme '" + schemeStr + "'");
}
@@ -228,7 +142,6 @@ public abstract class IdString {
public abstract long getLocation();
public String getSchemeParameters() { return ""; }
public abstract String getSchemeSpecific();
- public GidModifier getGidModifier() { return null; }
public boolean equals(Object o) {
return (o instanceof IdString && o.toString().equals(toString()));
diff --git a/document/src/main/java/com/yahoo/document/idstring/OrderDocIdString.java b/document/src/main/java/com/yahoo/document/idstring/OrderDocIdString.java
deleted file mode 100644
index 8c9ec506249..00000000000
--- a/document/src/main/java/com/yahoo/document/idstring/OrderDocIdString.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.document.idstring;
-
-import com.yahoo.collections.MD5;
-import com.yahoo.text.Utf8;
-
-import java.security.MessageDigest;
-
-/**
- * Representation of groupdoc scheme in document IDs.
- *
- * @author <a href="mailto:humbe@yahoo-inc.com">H&aring;kon Humberset</a>
- */
-public class OrderDocIdString extends IdString {
- String group;
- int widthBits;
- int divisionBits;
- long ordering;
- long location;
-
- /**
- * Create a groupdoc scheme object.
- * <code>groupdoc:&lt;namespace&gt;:&lt;group&gt;:&lt;namespaceSpecific&gt;</code>
- *
- * @param namespace The namespace of this document id.
- * @param group The groupname of this groupdoc id.
- * @param widthBits The number of bits used for the width of the data set
- * @param divisionBits The number of bits used for the smalles partitioning of the data set
- * @param ordering A value used to order documents of this type.
- * @param namespaceSpecific The namespace specific part.
- */
- public OrderDocIdString(String namespace, String group, int widthBits, int divisionBits, long ordering, String namespaceSpecific) {
- super(Scheme.orderdoc, namespace, namespaceSpecific);
- this.group = group;
- this.widthBits = widthBits;
- this.divisionBits = divisionBits;
- this.ordering = ordering;
-
- try {
- this.location = Long.parseLong(group);
- } catch (Exception foo) {
- location = 0;
- byte[] md5sum = MD5.md5.get().digest(Utf8.toBytes(group));
- for (int i=0; i<8; ++i) {
- location |= (md5sum[i] & 0xFFl) << (8*i);
- }
- }
- }
-
- /**
- * Get the location of this document id. The location is used for distribution
- * in clusters. For the orderdoc scheme, the location is a hash of the groupname or just the number specified.
- *
- * @return The 64 bit location.
- */
- public long getLocation() {
- return location;
- }
-
- public String getSchemeParameters() {
- return "(" + widthBits + "," + divisionBits + ")";
- }
-
- /** Get the scheme specific part. */
- public String getSchemeSpecific() {
- return group + ":" + ordering + ":";
- }
-
- public GidModifier getGidModifier() {
- GidModifier gm = new GidModifier();
- gm.usedBits = widthBits - divisionBits;
- long gidBits = (ordering << (64 - widthBits));
- gidBits = Long.reverse(gidBits);
- long gidMask = (0xFFFFFFFFFFFFFFFFl >>> (64 - gm.usedBits));
- gidBits &= gidMask;
- gm.value = gidBits;
- return gm;
- }
-
- @Override
- public boolean hasGroup() {
- return true;
- }
-
- /** @return Get the groupname of this id. */
- @Override
- public String getGroup() {
- return group;
- }
-
- @Override
- public boolean hasNumber() {
- return true;
- }
-
- @Override
- public long getNumber() {
- return location;
- }
-
- public long getUserId() {
- return location;
- }
-
- public int getWidthBits() {
- return widthBits;
- }
-
- public int getDivisionBits() {
- return divisionBits;
- }
-
- public long getOrdering() {
- return ordering;
- }
-}
diff --git a/document/src/main/java/com/yahoo/document/idstring/UserDocIdString.java b/document/src/main/java/com/yahoo/document/idstring/UserDocIdString.java
deleted file mode 100644
index 4da56bfbb6e..00000000000
--- a/document/src/main/java/com/yahoo/document/idstring/UserDocIdString.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.document.idstring;
-
-import java.math.BigInteger;
-
-/**
- * Representation of userdoc scheme in document IDs. A user id is any 64 bit
- * number. Note that internally, these are handled as unsigned values.
- *
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-public class UserDocIdString extends IdString {
- long userId;
-
- /**
- * Create a userdoc scheme object.
- * <code>userdoc:&lt;namespace&gt;:&lt;userid&gt;:&lt;namespaceSpecific&gt;</code>
- *
- * @param namespace The namespace of this document id.
- * @param userId 64 bit user id of this userdoc id.
- * @param namespaceSpecific The namespace specific part.
- */
- public UserDocIdString(String namespace, long userId, String namespaceSpecific) {
- super(Scheme.userdoc, namespace, namespaceSpecific);
- this.userId = userId;
- }
-
- @Override
- public boolean hasNumber() {
- return true;
- }
-
- @Override
- public long getNumber() {
- return userId;
- }
-
- /**
- * Get the location of this document id. The location is used for distribution
- * in clusters. For the userdoc scheme, the location equals the user id.
- *
- * @return The 64 bit location.
- */
- public long getLocation() { return userId; }
-
- /** Get the scheme specific part. Which for a userdoc, is the userid and a colon. */
- public String getSchemeSpecific() {
- BigInteger uid = BigInteger.ZERO;
- for (int i=0; i<64; i++) {
- if ((userId >>> i & 0x1) == 1) {
- uid = uid.setBit(i);
- }
- }
- return uid.toString() + ":";
- }
-
- /** @return Get the user id of this id. */
- public long getUserId() { return userId; }
-}