jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1163506 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java main/java/org/apache/jackrabbit/mk/util/IOUtils.java test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
Date Wed, 31 Aug 2011 06:56:26 GMT
Author: thomasm
Date: Wed Aug 31 06:56:25 2011
New Revision: 1163506

URL: http://svn.apache.org/viewvc?rev=1163506&view=rev
Log:
Index mechanism (WIP)

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/IOUtils.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java?rev=1163506&r1=1163505&r2=1163506&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/PropertyIndex.java
Wed Aug 31 06:56:25 2011
@@ -83,8 +83,11 @@ public class PropertyIndex implements In
         if (!c.hasNext()) {
             return null;
         }
-        c.next();
-        return c.getValue();
+        String key = c.next();
+        if (key.equals(propertyValue)) {
+            return c.getValue();
+        }
+        return null;
     }
 
     /**

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/IOUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/IOUtils.java?rev=1163506&r1=1163505&r2=1163506&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/IOUtils.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/IOUtils.java
Wed Aug 31 06:56:25 2011
@@ -31,10 +31,10 @@ public class IOUtils {
      * until the maximum number of bytes have been read or until the end of
      * file.
      *
-     * @param in     the input stream
+     * @param in the input stream
      * @param buffer the output buffer
-     * @param off    the offset in the buffer
-     * @param max    the number of bytes to read at most
+     * @param off the offset in the buffer
+     * @param max the number of bytes to read at most
      * @return the number of bytes read, 0 meaning EOF
      */
     public static int readFully(InputStream in, byte[] buffer, int off, int max) throws IOException
{
@@ -55,11 +55,11 @@ public class IOUtils {
     /**
      * Skip a number of bytes in an input stream.
      *
-     * @param in   the input stream
+     * @param in the input stream
      * @param skip the number of bytes to skip
      * @throws EOFException if the end of file has been reached before all bytes
      *                      could be skipped
-     * @throws IOException  if an IO exception occurred while skipping
+     * @throws IOException if an IO exception occurred while skipping
      */
     public static void skipFully(InputStream in, long skip) throws IOException {
         while (skip > 0) {
@@ -76,7 +76,7 @@ public class IOUtils {
      * UTF-8 encoded string.
      *
      * @param out the data output stream
-     * @param s   the string (maximum length about 2 GB)
+     * @param s the string (maximum length about 2 GB)
      */
     public static void writeString(OutputStream out, String s) throws IOException {
         byte[] data = s.getBytes("UTF-8");
@@ -105,11 +105,10 @@ public class IOUtils {
     }
 
     /**
-     * Write a variable size integer.
-     * Negative values need 5 bytes.
+     * Write a variable size integer. Negative values need 5 bytes.
      *
      * @param out the output stream
-     * @param x   the value
+     * @param x the value
      */
     public static void writeVarInt(OutputStream out, int x) throws IOException {
         while ((x & ~0x7f) != 0) {
@@ -145,7 +144,7 @@ public class IOUtils {
      * Negative values need 10 bytes.
      *
      * @param out the output stream
-     * @param x   the value
+     * @param x the value
      */
     public static void writeVarLong(OutputStream out, long x) throws IOException {
         while ((x & ~0x7f) != 0) {
@@ -156,6 +155,53 @@ public class IOUtils {
     }
 
     /**
+     * Write a long (8 bytes).
+     *
+     * @param out the output stream
+     * @param x the value
+     */
+    public static void writeLong(OutputStream out, long x) throws IOException {
+        writeInt(out, (int) (x >>> 32));
+        writeInt(out, (int) x);
+    }
+
+    /**
+     * Read a long (8 bytes).
+     *
+     * @param in the input stream
+     * @return the value
+     */
+    public static long readLong(InputStream in) throws IOException {
+        return ((long) (readInt(in)) << 32) + (readInt(in) & 0xffffffffL);
+    }
+
+    /**
+     * Write an integer (4 bytes).
+     *
+     * @param out the output stream
+     * @param x the value
+     */
+    public static void writeInt(OutputStream out, int x) throws IOException {
+        out.write((byte) (x >> 24));
+        out.write((byte) (x >> 16));
+        out.write((byte) (x >> 8));
+        out.write((byte) x);
+    }
+
+    /**
+     * Read an integer (4 bytes).
+     *
+     * @param in the input stream
+     * @return the value
+     */
+    public static int readInt(InputStream in) throws IOException {
+        return ((in.read() & 0xff) << 24) +
+            ((in.read() & 0xff) << 16) +
+            ((in.read() & 0xff) << 8) +
+            (in.read() & 0xff);
+    }
+
+    /**
      * Read a variable size long.
      *
      * @param in the input stream

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java?rev=1163506&r1=1163505&r2=1163506&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
Wed Aug 31 06:56:25 2011
@@ -60,6 +60,7 @@ public class PropertyIndexTest extends T
         index = indexer.createPropertyIndex("id", true);
         head = mk.getHeadRevision();
         assertEquals("/test/test", index.getPath("3", head));
+        assertEquals(null, index.getPath("0", head));
         mk.dispose();
     }
 



Mime
View raw message