Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.Value


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

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

      try {
         BTreeRootInfo root = findBTreeRoot(v);
         Value cv = getCombinedValue(key, pos, len, elemID, attrID);
         removeValue(root, cv);
      }
      catch ( DBException e ) {
         throw e;
      }
View Full Code Here


         }
      }
   }

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

      try {
         BTreeRootInfo root;

         try {
            root = findBTreeRoot(v);
         }
         catch ( BTreeNotFoundException e ) {
            root = createBTreeRoot(v);
         }

         Value cv = getCombinedValue(key, pos, len, elemID, attrID);
         addValue(root, cv, MATCH_INFO);
      }
      catch ( DBException e ) {
         throw e;
      }
View Full Code Here

         DBDocument dbDoc = (DBDocument)document;
         if ( dbDoc.getSource() == null )
            dbDoc.setSource(new NodeSource(this, key));
      }

      Value value =  null;
      if ( compressed ) {
         try {
            byte[] b = DOMCompressor.Compress(document, symbols);
            value = new Value(b);

            document = new DocumentImpl(b, symbols, new NodeSource(this, key));
         }
         catch ( Exception e ) {
            throw new DBException(FaultCodes.COL_CANNOT_STORE, "Error storing Document '"+key+"'", e);
         }
      } else {
         value = new Value( TextWriter.toString( document ) );
      }

      flushSymbolTable();

      // Temporary until insert and update are separate
      Document oldDoc = getDocument(key);
      if ( oldDoc != null )
         indexManager.removeDocument(key, oldDoc);
      indexManager.addDocument(key, document);

      filer.writeRecord(key, value);

      // Cache Stuff
      if ( documentCache != null ) {
         if ( compressed )
            documentCache.putDocument(this, key, value.getData());
         else
            documentCache.putDocument(this, key, document);
      }

      DBObserver.getInstance().putDocument(this, key, document,
View Full Code Here

      if ( doc == null ) {
         Record record = filer.readRecord(key);
         if ( record == null )
            return null;

         Value value = record.getValue();

         if ( compressed ) {
            doc = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));

            if ( documentCache != null )
               documentCache.putDocument(this, key, value.getData());
         }
         else
            doc = parseDocument(key, value.toString());

         flushSymbolTable();

         DBObserver.getInstance().loadDocument(this, record, doc);
      }
View Full Code Here

      public Container getNextContainer() throws DBException {
         if (set.hasMoreRecords()) {
            Record rec = set.getNextRecord();
            Key key = rec.getKey();
            Value val = rec.getValue();
            if ( val.getData() != null ) {
               try {
                  if ( compressed ) {
                     Document doc = new DocumentImpl(val.getData(), symbols, new NodeSource(Collection.this, key));
                     return new ColContainer(key, doc);
                  }
                  else
                     return new ColContainer(key, DOMParser.toDocument(val));
               }
View Full Code Here

            final int threadID = i;
            threads[i] = new Thread() {
                public void run() {
                    for (int ii = 0; ii < ITERATIONS; ii++) {
                        Key key = new Key("T" + threadID + "I" + ii);
                        Value value = new Value("<test thread=\"" + threadID + "\" iteration=\"" + ii + "\"/>");
                        try {
                            filer.writeRecord(key, value);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    // System.out.println(getName() + " done.");
                }
            };
            threads[i].setName("FilerTest" + i);
        }

        // Start all the threads at once
        for (int i = 0; i < THREADS; i++) {
            threads[i].start();
        }
        Thread.sleep(1000);

        for (int i = 0; i < THREADS; i++) {
            threads[i].join();
        }

        filer.flush();

        // Check results
        assertEquals(filer.getRecordCount(), THREADS * ITERATIONS);
        for (int i = 0; i < THREADS; i++) {
            for (int ii = 0; ii < ITERATIONS; ii++) {
                Key key = new Key("T" + i + "I" + ii);
                Value value = new Value("<test thread=\"" + i + "\" iteration=\"" + ii + "\"/>");
                Record record = filer.readRecord(key);
                assertNotNull("Record with key '" + key + "' was not found",
                              record);
                assertEquals("Expected record with key '" + key + "', found record with key '" + record.getKey() + "'",
                             key, record.getKey());
View Full Code Here

        sb.append("KEY");
        for (int k = 0; k < LARGE_KEY_SIZE - 3; k++) {
            sb.append('0');
        }
        final Key key = new Key(sb.toString());
        final Value value = new Value("<test/>");

        assertTrue(filer.writeRecord(key, value));

        assertEquals(filer.getRecordCount(), 1);
        Record record = filer.readRecord(key);
View Full Code Here

        public Container getNextContainer() throws DBException {
            if (set.hasMoreRecords()) {
                Record rec = set.getNextRecord();
                Key key = rec.getKey();
                Value val = rec.getValue();
                if (val.getData() != null) {
                    try {
                        if (compressed) {
                            Document doc = new DocumentImpl(val.getData(), symbols, new NodeSource(Collection.this, key));
                            return new ColContainer(key, doc);
                        } else {
                            return new ColContainer(key, DOMParser.toDocument(val));
                        }
                    } catch (Exception e) {
View Full Code Here

        private final Value name;
        private long page;

        public BTreeRootInfo(BTreeRootInfo parent, String name, long page) {
            this.parent = parent;
            this.name = new Value(name);
            this.page = page;
        }
View Full Code Here

            this.page = page;
        }

        public BTreeRootInfo(String name, long page) {
            this.parent = rootInfo;
            this.name = new Value(name);
            this.page = page;
        }
View Full Code Here

TOP

Related Classes of org.apache.xindice.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.