Search in sources :

Example 1 with SortedIndexStorage

use of org.apache.ignite.internal.storage.index.SortedIndexStorage in project ignite-3 by apache.

the class IndexRowWrapper method randomRow.

/**
 * Creates an Entry with a random key that satisfies the given schema and a random value.
 */
static IndexRowWrapper randomRow(SortedIndexStorage indexStorage) {
    var random = new Random();
    Object[] columns = indexStorage.indexDescriptor().indexRowColumns().stream().map(ColumnDescriptor::column).map(column -> generateRandomValue(random, column.type())).toArray();
    var primaryKey = new ByteArraySearchRow(randomBytes(random, 25));
    IndexRow row = indexStorage.indexRowFactory().createIndexRow(columns, primaryKey);
    return new IndexRowWrapper(indexStorage, row, columns);
}
Also used : ComparatorUtils.comparingNull(org.apache.ignite.internal.storage.rocksdb.index.ComparatorUtils.comparingNull) IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) Array(java.lang.reflect.Array) SchemaTestUtils(org.apache.ignite.internal.schema.SchemaTestUtils) SortedIndexDescriptor(org.apache.ignite.internal.storage.index.SortedIndexDescriptor) Random(java.util.Random) IgniteTestUtils.randomBytes(org.apache.ignite.internal.testframework.IgniteTestUtils.randomBytes) Function(java.util.function.Function) Objects(java.util.Objects) ColumnDescriptor(org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor) IndexRowPrefix(org.apache.ignite.internal.storage.index.IndexRowPrefix) SortedIndexStorage(org.apache.ignite.internal.storage.index.SortedIndexStorage) SchemaTestUtils.generateRandomValue(org.apache.ignite.internal.schema.SchemaTestUtils.generateRandomValue) Comparator.comparing(java.util.Comparator.comparing) BitSet(java.util.BitSet) Comparator(java.util.Comparator) NotNull(org.jetbrains.annotations.NotNull) IndexRow(org.apache.ignite.internal.storage.index.IndexRow) Random(java.util.Random) IndexRow(org.apache.ignite.internal.storage.index.IndexRow) ColumnDescriptor(org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor)

Aggregations

Array (java.lang.reflect.Array)1 Arrays (java.util.Arrays)1 BitSet (java.util.BitSet)1 Comparator (java.util.Comparator)1 Comparator.comparing (java.util.Comparator.comparing)1 Objects (java.util.Objects)1 Random (java.util.Random)1 Function (java.util.function.Function)1 IntStream (java.util.stream.IntStream)1 SchemaTestUtils (org.apache.ignite.internal.schema.SchemaTestUtils)1 SchemaTestUtils.generateRandomValue (org.apache.ignite.internal.schema.SchemaTestUtils.generateRandomValue)1 IndexRow (org.apache.ignite.internal.storage.index.IndexRow)1 IndexRowPrefix (org.apache.ignite.internal.storage.index.IndexRowPrefix)1 SortedIndexDescriptor (org.apache.ignite.internal.storage.index.SortedIndexDescriptor)1 ColumnDescriptor (org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor)1 SortedIndexStorage (org.apache.ignite.internal.storage.index.SortedIndexStorage)1 ComparatorUtils.comparingNull (org.apache.ignite.internal.storage.rocksdb.index.ComparatorUtils.comparingNull)1 IgniteTestUtils.randomBytes (org.apache.ignite.internal.testframework.IgniteTestUtils.randomBytes)1 NotNull (org.jetbrains.annotations.NotNull)1