Package org.modeshape.jcr.query.NodeSequence

Examples of org.modeshape.jcr.query.NodeSequence.Batch


            QueryResults result = query.execute();
            if (result.isEmpty()) return false;
            if (result.getRowCount() < 0) {
                // Try to get the first row ...
                NodeSequence seq = result.getRows();
                Batch batch = seq.nextBatch();
                while (batch != null) {
                    if (batch.hasNext()) return true;
                    // It's not common for the first batch may be empty, but it's possible. So try the next batch ...
                    batch = seq.nextBatch();
                }
                return false;
            }
View Full Code Here


    protected void assertNoDuplicates( NodeSequence sequence ) {
        Set<NodeKey> keys = new HashSet<NodeKey>();
        // Iterate over the batches ...
        try {
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    CachedNode node = batch.getNode();
                    NodeKey key = node != null ? node.getKey() : null;
                    boolean added = keys.add(key);
                    print("Adding " + key);
                    assertTrue("Failed to add " + key, added);
                }
View Full Code Here

    protected List<NodeKey> nodesFrom( NodeSequence sequence,
                                       boolean closeRestartable ) {
        List<NodeKey> keys = new ArrayList<NodeKey>();
        // Iterate over the batches ...
        try {
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    CachedNode node = batch.getNode();
                    NodeKey key = node != null ? node.getKey() : null;
                    boolean added = keys.add(key);
                    print("Adding " + key);
                    assertTrue("Failed to add " + key, added);
                }
View Full Code Here

    protected void assertSorted( NodeSequence sequence,
                                 ExtractFromRow extractor ) {
        List<Object> values = new ArrayList<Object>();
        // Iterate over the batches ...
        try {
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    Object value = extractor.getValueInRow(batch);
                    values.add(value);
                    print("Found " + value);
                }
            }
View Full Code Here

    }

    protected long countRows( NodeSequence sequence ) {
        try {
            long count = 0;
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    ++count;
                }
            }
            return count;
        } finally {
View Full Code Here

                          ExtractFromRow firstExtractor,
                          ExtractFromRow... extractors ) {
        if (!print()) return;
        System.out.println(msg);
        try {
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    System.out.print(" ");
                    System.out.print(firstExtractor.getValueInRow(batch));
                    for (ExtractFromRow extractor : extractors) {
                        System.out.print(" ");
                        System.out.print(extractor.getValueInRow(batch));
View Full Code Here

                                  NodeSequence sequence,
                                  ExtractFromRow... extractors ) {
        if (!print()) return;
        System.out.println(msg);
        try {
            Batch batch = null;
            while ((batch = sequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    System.out.print(rowAsString(batch, " "));
                    for (ExtractFromRow extractor : extractors) {
                        System.out.print(" ");
                        System.out.print(extractor.getValueInRow(batch));
                    }
View Full Code Here

    protected void assertRowsSatisfy( NodeSequence nodeSequence,
                                      Verifier verifier ) {
        // Iterate over the batches ...
        try {
            Batch batch = null;
            while ((batch = nodeSequence.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    verifier.verify(batch);
                }
            }
            verifier.complete();
        } finally {
View Full Code Here

        NodeSequence seq = allNodes();
        // The sequence should not have any duplicates, since the iterator doesn't ...
        Set<NodeKey> keys = new HashSet<NodeKey>();
        try {
            // Iterate over the batches ...
            Batch batch = null;
            while ((batch = seq.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    CachedNode node = batch.getNode();
                    NodeKey key = node != null ? node.getKey() : null;
                    boolean added = keys.add(key);
                    print("Adding " + key);
                    assertTrue("Failed to add " + key, added);
                }
View Full Code Here

        NodeSequence seq = NodeSequence.append(allNodes(), allNodes());
        // The sequence should not have two duplicates of every node ...
        Set<NodeKey> keys = new HashSet<NodeKey>();
        try {
            // Iterate over the batches ...
            Batch batch = null;
            boolean shouldAdd = true;
            while ((batch = seq.nextBatch()) != null) {
                while (batch.hasNext()) {
                    batch.nextRow();
                    CachedNode node = batch.getNode();
                    NodeKey key = node != null ? node.getKey() : null;
                    if (keys.contains(key) && shouldAdd) shouldAdd = false;
                    if (shouldAdd) {
                        boolean added = keys.add(key);
                        print("Adding " + key);
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.NodeSequence.Batch

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.