Package com.dbxml.db.core.data

Examples of com.dbxml.db.core.data.Value


      if ( c == null ) {
         c = w;
         c.valID = nextValID++;
         map.put(c, c);

         Value v = new Value(c.data);
         ValueTableEntry e = new ValueTableEntry(dataSize, c.data.length);
         values.add(new ValueInfo(v, e));
         dataSize += c.data.length;
      }
      entries.add(new DocumentTableEntry(typeID, c.valID));
View Full Code Here


      ValueTableEntry vte = getValueEntry(idx);
      return getValue(vte);
   }

   public Value getValue(ValueTableEntry vte) {
      return new Value(data, dataOffset+vte.getOffset(), vte.getLength());
   }
View Full Code Here

                     b[0] = 0;
                  else
                     return EmptyValue;
                  break;
            }
            return new Value(b);
         }
         catch ( Exception e ) {
            return EmptyValue;
         }
      }

      if ( type == TRIMMED )
         value = QueryEngine.normalizeString(value);

      return new Value(value);
   }
View Full Code Here

      return new Value(value);
   }

   private Value getCombinedValue(Value value, Key key, int pos, int elemID, int attrID) {
      Value result;
      try {
         int valSize = value.getLength();
         int keySize = key.getLength();
         int totalSize = valSize+keySize+16;

         byte[] b = new byte[totalSize];

         System.arraycopy(value.getRawData(), value.getOffset(), b, 0, valSize);
         System.arraycopy(key.getRawData(), key.getOffset(), b, valSize+1, keySize);

         int l = valSize+keySize+2;

         ByteArray.writeInt(b, l, pos);    // Write the pos
         ByteArray.writeInt(b, l+4, elemID); // Write the elemID
         ByteArray.writeInt(b, l+8, attrID); // Write the attrID
         ByteArray.writeShort(b, l+12, (short)valSize);

         result = new Value(b);
      }
      catch ( Exception e ) {
         result = null; // This will never happen
      }
      return result;
View Full Code Here

      return new IndexMatch(key, pos, elemID, attrID);
   }

   public void remove(Transaction tx, String value, Key key, int pos, int elemID, int attrID) throws DBException {
      Value v = getTypedValue(value);
      if ( type != STRING && type != TRIMMED && v.getLength() == 0 )
         return;

      try {
         Value cv = getCombinedValue(v, key, pos, elemID, attrID);
         removeValue(tx, cv);
      }
      catch ( DBException d ) {
         throw d;
      }
View Full Code Here

         e.printStackTrace(System.err);
      }
   }

   public void add(Transaction tx, String value, Key key, int pos, int elemID, int attrID) throws DBException {
      Value v = getTypedValue(value);
      if ( type != STRING && type != TRIMMED && v.getLength() == 0 )
         return;

      try {
         Value cv = getCombinedValue(v, key, pos, elemID, attrID);
         addValue(tx, cv, MATCH_INFO);
      }
      catch ( DBException d ) {
         throw d;
      }
View Full Code Here

      private synchronized void setLoaded(boolean loaded) {
         this.loaded = loaded;
      }

      public synchronized void read(Transaction tx) throws DBException, IOException {
         Value v = readValue(tx, page);
         DataInputStream is = new DataInputStream(v.getInputStream());

         // Read in the common prefix (if any)
         short pfxLen = ph.getPrefixLength();
         byte[] pfxBytes;
         if ( pfxLen > 0 ) {
            pfxBytes = new byte[pfxLen];
            is.read(pfxBytes);
         }
         else {
            prefix = EmptyValue;
            pfxBytes = EmptyBytes;
         }

         // Read in the pointers
         ptrs = new long[ph.getPointerCount()];
         for ( int i = 0; i < ptrs.length; i++ )
            ptrs[i] = is.readLong();

         // Read in the Values
         values = new Value[ph.getValueCount()];
         for ( int i = 0; i < values.length; i++ ) {
            short len = is.readShort();
            byte[] b = new byte[pfxLen+len];

            if ( pfxLen > 0 )
               System.arraycopy(pfxBytes, 0, b, 0, pfxLen);

            if ( len > 0 )
               is.read(b, pfxLen, len);
            values[i] = new Value(b);
         }

         cache.put(new Long(page.getPageNum()), this);
      }
View Full Code Here

         for ( int i = 0; i < ptrs.length; i++ )
            os.writeLong(ptrs[i]);

         // Write out the Values
         for ( int i = 0; i < values.length; i++ ) {
            Value v = values[i];
            byte[] b = v.getRawData();
            int pos = v.getOffset();
            int len = v.getLength();
            os.writeShort(len-pfxLen);
            if ( len-pfxLen > 0 )
               os.write(b, pos+pfxLen, len-pfxLen);
         }

         writeValue(tx, page, new Value(bos.toByteArray()));

         cache.put(new Long(page.getPageNum()), this);
      }
View Full Code Here

      private Value getPrefix(Value value1, Value value2) {
         int idx = Math.abs(value1.compareTo(value2))-1;
         if ( idx > 0 ) {
            byte[] b = value2.getRawData();
            int pos = value2.getOffset();
            return new Value(b, pos, idx);
         }
         else
            return EmptyValue;
      }
View Full Code Here

      private Value getSeparator(Value value1, Value value2) {
         int idx = Math.abs(value1.compareTo(value2));
         byte[] b = value2.getRawData();
         int pos = value2.getOffset();
         return new Value(b, pos, idx);
      }
View Full Code Here

TOP

Related Classes of com.dbxml.db.core.data.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.