[GitHub] [lucene-solr] jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of triangle info to ShapeField encoding

2020-01-03 Thread GitBox
jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of 
triangle info to ShapeField encoding
URL: https://github.com/apache/lucene-solr/pull/927#discussion_r362770851
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/document/ShapeField.java
 ##
 @@ -260,111 +379,249 @@ public static void encodeTriangle(byte[] bytes, int 
aLat, int aLon, boolean abFr
   /** Decode a triangle encoded by {@link ShapeField#encodeTriangle(byte[], 
int, int, boolean, int, int, boolean, int, int, boolean)}.
*/
   public static void decodeTriangle(byte[] t, DecodedTriangle triangle) {
-final int aX, aY, bX, bY, cX, cY;
-final boolean ab, bc, ca;
-int bits = NumericUtils.sortableBytesToInt(t, 6 * BYTES);
-//extract the first three bits
+final int bits = NumericUtils.sortableBytesToInt(t, 6 * BYTES);
+final boolean bit6 = (bits & 1 << 6) == 1 << 6;
+final boolean bit7 = (bits & 1 << 7) == 1 << 7;
+if (bit6) {
+  if (bit7) {
+triangle.type = DecodedTriangle.TYPE.TRIANGLE;
+decodeTriangle(t, triangle, bits);
+  } else {
+triangle.type = DecodedTriangle.TYPE.POINT;
+decodePoint(t,  triangle);
+  }
+} else if (bit7) {
+  triangle.type = DecodedTriangle.TYPE.LINE;
+  decodeLine(t, triangle, bits);
+} else {
+  // for backwards compatibility
+  triangle.type = DecodedTriangle.TYPE.UNKNOWN;
+  decodeTriangle(t, triangle, bits);
+}
 
 Review comment:
   Let's read the two bits at once? E.g.
   
   ```java
   final int typeBits = (bits >>> 6) & 0x03;
   switch (typeBits) {
 case 0:
   triangle.type = DecodedTriangle.TYPE.UNKNOWN;
   decodeTriangle(t, triangle, bits);
   break; 
 [...]
 case 3:
   triangle.type = DecodedTriangle.TYPE.TRIANGLE;
   decodeTriangle(t, triangle, bits);
   break;
   }
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org



[GitHub] [lucene-solr] jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of triangle info to ShapeField encoding

2020-01-02 Thread GitBox
jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of 
triangle info to ShapeField encoding
URL: https://github.com/apache/lucene-solr/pull/927#discussion_r362555275
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/document/ShapeField.java
 ##
 @@ -101,21 +143,95 @@ protected void setTriangleValue(int aX, int aY, boolean 
abFromShape, int bX, int
   private static final int MAXY_MINX_MINY_X_Y_MAXX = 6;
   private static final int MINY_MINX_Y_MAXX_MAXY_X = 7;
 
 Review comment:
   Indeed this change needs to be backward compatible, but is it really an 
issue here? My understanding is that with old segments you would get points 
reported as triangles, but in practice that wouldn't be an issue? And new 
indices with this change should never get queried with old versions of Lucene 
that don't know about these constants (Lucene doesn't guarantee any forward 
compatibility) so that wouldn't be an issue either?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org



[GitHub] [lucene-solr] jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of triangle info to ShapeField encoding

2020-01-02 Thread GitBox
jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of 
triangle info to ShapeField encoding
URL: https://github.com/apache/lucene-solr/pull/927#discussion_r362555275
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/document/ShapeField.java
 ##
 @@ -101,21 +143,95 @@ protected void setTriangleValue(int aX, int aY, boolean 
abFromShape, int bX, int
   private static final int MAXY_MINX_MINY_X_Y_MAXX = 6;
   private static final int MINY_MINX_Y_MAXX_MAXY_X = 7;
 
 Review comment:
   Indeed this change needs to be backward compatible, but is it really an 
issue here? My understanding is that with all segments you would get points 
reported as triangles, but in practice that wouldn't be an issue? And new 
indices with this change should never get queried with old versions of Lucene 
that don't know about these constants (Lucene doesn't guarantee any forward 
compatibility) so that wouldn't be an issue either?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org



[GitHub] [lucene-solr] jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of triangle info to ShapeField encoding

2019-11-14 Thread GitBox
jpountz commented on a change in pull request #927: LUCENE-8997: : Add type of 
triangle info to ShapeField encoding
URL: https://github.com/apache/lucene-solr/pull/927#discussion_r346564941
 
 

 ##
 File path: lucene/sandbox/src/java/org/apache/lucene/document/ShapeField.java
 ##
 @@ -101,21 +143,95 @@ protected void setTriangleValue(int aX, int aY, boolean 
abFromShape, int bX, int
   private static final int MAXY_MINX_MINY_X_Y_MAXX = 6;
   private static final int MINY_MINX_Y_MAXX_MAXY_X = 7;
 
 Review comment:
   What would be the pros/cons vs. adding new triangle types, e.g. as below?
   
   ```
   private static final int POINT_Y_X = 8;
   private static final int LINE_MAXY_MINX_MINY_MAXX = 9;
   private static final int LINE_MINY_MINX_MAXY_MAXX = 10;
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org