use of org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes in project ignite-3 by apache.
the class RecordViewOperationsTest method upsert.
@Test
public void upsert() {
final TestObjectWithAllTypes key = key(rnd);
final TestObjectWithAllTypes obj = randomObject(rnd, key);
final TestObjectWithAllTypes obj2 = randomObject(rnd, key);
final TestObjectWithAllTypes obj3 = randomObject(rnd, key);
RecordView<TestObjectWithAllTypes> tbl = recordView();
assertNull(tbl.get(null, key));
// Insert new row.
tbl.upsert(null, obj);
assertEquals(obj, tbl.get(null, key));
// Upsert row.
tbl.upsert(null, obj2);
assertEquals(obj2, tbl.get(null, key));
// Remove row.
tbl.delete(null, key);
assertNull(tbl.get(null, key));
// Insert new row.
tbl.upsert(null, obj3);
assertEquals(obj3, tbl.get(null, key));
}
use of org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes in project ignite-3 by apache.
the class RecordViewOperationsTest method randomObject.
@NotNull
private TestObjectWithAllTypes randomObject(Random rnd, TestObjectWithAllTypes key) {
TestObjectWithAllTypes obj = TestObjectWithAllTypes.randomObject(rnd);
obj.setPrimitiveLongCol(key.getPrimitiveLongCol());
return obj;
}
use of org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes in project ignite-3 by apache.
the class RecordViewOperationsTest method insert.
@Test
public void insert() {
final TestObjectWithAllTypes key = key(rnd);
final TestObjectWithAllTypes obj = randomObject(rnd, key);
final TestObjectWithAllTypes obj2 = randomObject(rnd, key);
RecordView<TestObjectWithAllTypes> tbl = recordView();
assertNull(tbl.get(null, key));
// Insert new row.
assertTrue(tbl.insert(null, obj));
assertEquals(obj, tbl.get(null, key));
// Ignore existed row pair.
assertFalse(tbl.insert(null, obj2));
assertEquals(obj, tbl.get(null, key));
}
use of org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes in project ignite-3 by apache.
the class RecordViewOperationsTest method replace.
@Test
public void replace() {
final TestObjectWithAllTypes key = key(rnd);
final TestObjectWithAllTypes obj = randomObject(rnd, key);
final TestObjectWithAllTypes obj2 = randomObject(rnd, key);
final TestObjectWithAllTypes obj3 = randomObject(rnd, key);
RecordView<TestObjectWithAllTypes> tbl = recordView();
// Ignore replace operation for non-existed row.
assertFalse(tbl.replace(null, obj));
assertNull(tbl.get(null, key));
// Insert new row.
tbl.upsert(null, obj);
// Replace existed row.
assertTrue(tbl.replace(null, obj2));
assertEquals(obj2, tbl.get(null, key));
// Replace existed row.
assertTrue(tbl.replace(null, obj3));
assertEquals(obj3, tbl.get(null, key));
// Remove existed row.
assertTrue(tbl.delete(null, key));
assertNull(tbl.get(null, key));
tbl.upsert(null, obj);
assertEquals(obj, tbl.get(null, key));
}
use of org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes in project ignite-3 by apache.
the class RecordViewOperationsTest method getAll.
@Test
public void getAll() {
final TestObjectWithAllTypes key1 = key(rnd);
final TestObjectWithAllTypes key2 = key(rnd);
final TestObjectWithAllTypes key3 = key(rnd);
final TestObjectWithAllTypes val1 = randomObject(rnd, key1);
final TestObjectWithAllTypes val3 = randomObject(rnd, key3);
RecordView<TestObjectWithAllTypes> tbl = recordView();
tbl.upsertAll(null, List.of(val1, val3));
Collection<TestObjectWithAllTypes> res = tbl.getAll(null, List.of(key1, key2, key3));
assertEquals(2, res.size());
assertTrue(res.contains(val1));
assertTrue(res.contains(val3));
}
Aggregations