Miscellaneous Java SequenceIterator Methods

The miscellaneous Java SequenceIterator methods take a variety of input sequence arguments and produce result sequences or scalar types as described in the table below:

SequenceIterator histogram(long low, long high, int nIntervals)

also

SequenceIterator histogram(double low, double high, int nIntervals)

Build a histogram for the object's sequence. Minimal (inclusive) and maximal (exclusive) values for input sequence should be specified as well as the number of intervals (histogram columns). (The number of intervals should not be greater than tile size)
void sort(Object arr, long[] permutation, Sequence.Order order) Sort the sequence elements previously extracted using get() and construct a permutation array (of positions) that can be used to access the elements of other sequences (also extracted to arrays)

Example

Following is an example code snippet demonstrating the sort method:

         
    public static void sort(Connection con)
    {
        con.startTransaction(Database.TransactionType.ReadOnly);
        System.out.println("--- SORT ----------------------");
        // Iterate through all objects
        Cursor<Quote> cursor = new Cursor<Quote>(con, Quote.class, "symbol");
        for (Quote quote : cursor) 
        {
            // Extract data into array
            int count = (int)quote.volume.count();
            int[] volumes = new int[count];
            float[] prices = new float[count];
            long permutation[] = new long[count];
            int len = quote.volume.iterator().get(volumes);
            assert(len == count);
            len = quote.close.iterator().get(prices);
            assert(len == count);
 
            // Execute query
            quote.volume.iterator().sort(volumes, permutation, Sequence.Order.Descending);
            for (int i = 0; i < count; i++) 
            {
                int j = (int)permutation[i];
                System.out.format("%s: volume=%d, price=%.3f\n", quote.symbol, volumes[j], prices[j]);
            }
        }
        con.commitTransaction();
    }