Package org.apache.xindice.core.data

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


     *
     * @param value The Value to compare
     * @return Whether or not the value matches
     */
    public final boolean testValue(String value) {
        return testValue(new Value(value));
    }
View Full Code Here


            HashMap meta = new HashMap(2, 1.5F);
            meta.put(Record.MODIFIED, new Long(file.lastModified()));

            byte[] valueData = cache.getFile(file);
            if (valueData != null) {
                return new Record(key, new Value(valueData), meta);
            }
        } catch (IOException e) {
            throw new FilerException(FaultCodes.DBE_CANNOT_READ,
                                     "Can't read record '" + key + "': " + e.getMessage(), e);
        } finally {
View Full Code Here

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

        Value value;
        InlineMetaMap metaMap = null;
        if (inlineMetaService == null) {
            value = record.getValue();

            if (log.isTraceEnabled()) {
                log.trace(localDebugHeader + "Type is not available, Length=" + value.getLength());
            }
        } else {
            InlineMetaService.DatabaseEntry databaseEntry = inlineMetaService.readDatabaseEntry(record.getValue());
            metaMap = databaseEntry.map;
            value = databaseEntry.value;

            if (log.isTraceEnabled()) {
                log.trace(localDebugHeader + "Type=" + metaMap.get("type") + ", Length=" + value.getLength());
            }
        }

        if (inlineMetaService == null || metaMap.get("type").equals(ResourceTypeReader.XML)) {
            Document document;
            if (compressed) {
                document = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));
                flushSymbolTable();
                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader +
                              "Compressed XML document=<" + TextWriter.toString(document) + ">");
                }

                if (documentCache != null) {
                    documentCache.putDocument(this, key, value.getData());
                }
            } else {
                if (log.isTraceEnabled()) {
                    log.trace(localDebugHeader + "Pre parseDocument(): value=<" + value + ">");
                }

                document = parseDocument(key, value.toString());
            }

            DBObserver.getInstance().loadDocument(this, record, document);
            return document;
        } else {
            if (log.isTraceEnabled()) {
                log.trace(localDebugHeader + "Binary document");
            }

            return value.getData();
        }
    }
View Full Code Here

            }
        }

        InlineMetaMap map = inlineMetaService.getEmptyMap();
        map.put("type", ResourceTypeReader.BINARY);
        Value value = inlineMetaService.createValue(map, bytes, 0, bytes.length);
        filer.writeRecord(key, value);

        // update the meta for this document
        updateDocumentMeta(key.toString());
        // Not observable. DBObserver.getInstance().putDocument(this, key, document, oldDoc == null);
View Full Code Here

        indexManager.addDocument(key, document);

        /*
         * Construct the Value object that is stored in the BTree.
         */
        Value value;
        if (inlineMetaService == null) {
            value = new Value(documentBytes);
        } else {
            InlineMetaMap map = inlineMetaService.getEmptyMap();
            map.put("type", ResourceTypeReader.XML);
            value = inlineMetaService.createValue(map, documentBytes, 0, documentBytes.length);
        }
View Full Code Here

                        } catch (InterruptedException e) { /* ignored */ }
                    }

                    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(this.getName() + " done.");
                }
            };
            threads[i].setName("FilerTest" + i);
            threads[i].start();
        }

        // Start all the threads at once
        Thread.sleep(250);
        synchronized (go) {
            go.notifyAll();
        }
        for (int i = 0; i < THREADS; i++) {
            threads[i].join();
        }

        // Check results
        assertEquals(THREADS * ITERATIONS, filer.getRecordCount());
        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

       for (int i = 0; i < THREADS; i++) {
           threads[i] = new Thread() {
               public void run() {
                   for (int ii = 0; ii < ITERATIONS; ii++) {
                       Key key = new Key("key");
                       Value value = new Value("<test document/>");
                       try {
                           filer.writeRecord(key, value);
                       } catch (Exception e) {
                           e.printStackTrace();
                       }
                   }
               }
           };
           threads[i].setName("FilerTest" + i);
       }

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

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

       filer.flush();

       // Check results
       assertEquals(1, filer.getRecordCount());
       Key key = new Key("key");
       Value value = new Value("<test document/>");
       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());
       assertEquals("Expected record with value '" + value + "', found record with value '" + record.getValue() + "'",
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

        byte[] xmlData = new byte[] {
            0x03, 0x01, 0x01, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};

        InlineMetaMap map;

        map = reader.read(new Value(binaryData, 2, 1));
        assertEquals(ResourceTypeReader.BINARY, map.get("type"));

        map = reader.read(new Value(xmlData, 2, 1));
        assertEquals(ResourceTypeReader.XML, map.get("type"));
       
        try {
            reader.read(new Value(evilData, 2, 1));
            fail("failed to throw InlineMetaException on bad type value (3)");
        } catch (InlineMetaException e) {
            // expected exception
        }
    }
View Full Code Here

        byte[] metadata = new byte[] {
            0x0a, 0x0b, 0x0c};
        byte[] data = new byte[] {
            0x12, 0x11, 0x10, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};

        Value value = InlineHeaderBuilder.createValue(12, metadata, data, 2, 7);
        byte[] valueBytes = value.getData();
       
        /*
         * byte 0 is the total header length
         */
        assertEquals(5, valueBytes[0]);
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.