use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItAbstractThinClientTest method beforeAll.
/**
* Before each.
*/
@BeforeAll
void beforeAll(TestInfo testInfo, @WorkDirectory Path workDir) {
this.workDir = workDir;
String node0Name = testNodeName(testInfo, 3344);
String node1Name = testNodeName(testInfo, 3345);
nodesBootstrapCfg.put(node0Name, "{\n" + " node.metastorageNodes: [ \"" + node0Name + "\" ],\n" + " network: {\n" + " port: " + 3344 + ",\n" + " nodeFinder: {\n" + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\" ]\n" + " }\n" + " }\n" + "}");
nodesBootstrapCfg.put(node1Name, "{\n" + " node.metastorageNodes: [ \"" + node0Name + "\" ],\n" + " network: {\n" + " port: " + 3345 + ",\n" + " nodeFinder: {\n" + " netClusterNodes: [ \"localhost:3344\", \"localhost:3345\" ]\n" + " }\n" + " }\n" + "}");
nodesBootstrapCfg.forEach((nodeName, configStr) -> startedNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName))));
TableDefinition schTbl = SchemaBuilders.tableBuilder(SCHEMA_NAME, TABLE_NAME).columns(SchemaBuilders.column(COLUMN_KEY, ColumnType.INT32).build(), SchemaBuilders.column(COLUMN_VAL, ColumnType.string()).asNullable(true).build()).withPrimaryKey(COLUMN_KEY).build();
startedNodes.get(0).tables().createTable(schTbl.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl, tblCh).changeReplicas(1).changePartitions(10));
client = IgniteClient.builder().addresses(getNodeAddresses().toArray(new String[0])).build();
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItSecondaryIndexTest method initTestData.
/**
* Before all.
*/
@BeforeAll
static void initTestData() {
TableDefinition schema0 = SchemaBuilders.tableBuilder("PUBLIC", "DEVELOPER").columns(SchemaBuilders.column("ID", ColumnType.INT32).build(), SchemaBuilders.column("NAME", ColumnType.string()).asNullable(true).build(), SchemaBuilders.column("DEPID", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("CITY", ColumnType.string()).asNullable(true).build(), SchemaBuilders.column("AGE", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("ID").withIndex(SchemaBuilders.sortedIndex(DEPID_IDX).addIndexColumn("DEPID").done().build()).withIndex(SchemaBuilders.sortedIndex(NAME_CITY_IDX).addIndexColumn("DEPID").desc().done().addIndexColumn("CITY").desc().done().build()).withIndex(SchemaBuilders.sortedIndex(NAME_DEPID_CITY_IDX).addIndexColumn("NAME").done().addIndexColumn("DEPID").desc().done().addIndexColumn("CITY").desc().done().build()).build();
Table dev0 = CLUSTER_NODES.get(0).tables().createTable(schema0.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schema0, tblCh).changeReplicas(2).changePartitions(10));
insertData(dev0, new String[] { "ID", "NAME", "DEPID", "CITY", "AGE" }, new Object[][] { { 1, "Mozart", 3, "Vienna", 33 }, { 2, "Beethoven", 2, "Vienna", 44 }, { 3, "Bach", 1, "Leipzig", 55 }, { 4, "Strauss", 2, "Munich", 66 }, { 5, "Vagner", 4, "Leipzig", 70 }, { 6, "Chaikovsky", 5, "Votkinsk", 53 }, { 7, "Verdy", 6, "Rankola", 88 }, { 8, "Stravinsky", 7, "Spt", 89 }, { 9, "Rahmaninov", 8, "Starorussky ud", 70 }, { 10, "Shubert", 9, "Vienna", 31 }, { 11, "Glinka", 10, "Smolenskaya gb", 53 }, { 12, "Einaudi", 11, "", -1 }, { 13, "Glass", 12, "", -1 }, { 14, "Rihter", 13, "", -1 }, { 15, "Marradi", 14, "", -1 }, { 16, "Zimmer", 15, "", -1 }, { 17, "Hasaishi", 16, "", -1 }, { 18, "Arnalds", 17, "", -1 }, { 19, "Yiruma", 18, "", -1 }, { 20, "O'Halloran", 19, "", -1 }, { 21, "Cacciapaglia", 20, "", -1 }, { 22, "Prokofiev", 21, "", -1 }, { 23, "Musorgskii", 22, "", -1 } });
TableDefinition schema1 = SchemaBuilders.tableBuilder("PUBLIC", "UNWRAP_PK").columns(SchemaBuilders.column("F1", ColumnType.string()).asNullable(true).build(), SchemaBuilders.column("F2", ColumnType.INT64).asNullable(true).build(), SchemaBuilders.column("F3", ColumnType.INT64).asNullable(true).build(), SchemaBuilders.column("F4", ColumnType.INT64).asNullable(true).build()).withPrimaryKey(SchemaBuilders.primaryKey().withColumns("F2", "F1").build()).withIndex(SchemaBuilders.sortedIndex(PK_IDX).addIndexColumn("F2").done().addIndexColumn("F1").done().build()).build();
Table dev1 = CLUSTER_NODES.get(0).tables().createTable(schema1.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schema1, tblCh).changeReplicas(2).changePartitions(10));
insertData(dev1, new String[] { "F1", "F2", "F3", "F4" }, new Object[][] { { "Petr", 1L, 2L, 3L }, { "Ivan", 2L, 2L, 4L }, { "Ivan1", 21L, 2L, 4L }, { "Ivan2", 22L, 2L, 4L }, { "Ivan3", 23L, 2L, 4L }, { "Ivan4", 24L, 2L, 4L }, { "Ivan5", 25L, 2L, 4L } });
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItSetOpTest method testSetOpBigBatch.
@Test
@Disabled
public void testSetOpBigBatch() {
TableDefinition schTbl1 = SchemaBuilders.tableBuilder("PUBLIC", "BIG_TABLE1").columns(SchemaBuilders.column("KEY", ColumnType.INT32).build(), SchemaBuilders.column("VAL", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("KEY").build();
Table tbl1 = CLUSTER_NODES.get(0).tables().createTable(schTbl1.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl1, tblCh).changeReplicas(2).changePartitions(10));
TableDefinition schTbl2 = SchemaBuilders.tableBuilder("PUBLIC", "BIG_TABLE2").columns(SchemaBuilders.column("KEY", ColumnType.INT32).build(), SchemaBuilders.column("VAL", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("KEY").build();
Table tbl2 = CLUSTER_NODES.get(0).tables().createTable(schTbl2.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl2, tblCh).changeReplicas(2).changePartitions(10));
int key = 0;
RecordView<Tuple> recordView1 = tbl1.recordView();
RecordView<Tuple> recordView2 = tbl2.recordView();
for (int i = 0; i < 5; i++) {
for (int j = 0; j < ((i == 0) ? 1 : (1 << (i * 4 - 1))); j++) {
// Cache1 keys count: 1 of "0", 8 of "1", 128 of "2", 2048 of "3", 32768 of "4".
recordView1.insert(null, Tuple.create().set("KEY", key++).set("VAL", i));
// Cache2 keys count: 1 of "5", 128 of "3", 32768 of "1".
if ((i & 1) == 0) {
recordView2.insert(null, Tuple.create().set("KEY", key++).set("VAL", 5 - i));
}
}
}
// Check 2 partitioned caches.
List<List<?>> rows = sql("SELECT val FROM BIG_TABLE1 EXCEPT SELECT val FROM BIG_TABLE2");
assertEquals(3, rows.size());
assertEquals(1, countIf(rows, r -> r.get(0).equals(0)));
assertEquals(1, countIf(rows, r -> r.get(0).equals(2)));
assertEquals(1, countIf(rows, r -> r.get(0).equals(4)));
rows = sql("SELECT val FROM BIG_TABLE1 EXCEPT ALL SELECT val FROM BIG_TABLE2");
assertEquals(34817, rows.size());
assertEquals(1, countIf(rows, r -> r.get(0).equals(0)));
assertEquals(128, countIf(rows, r -> r.get(0).equals(2)));
assertEquals(1920, countIf(rows, r -> r.get(0).equals(3)));
assertEquals(32768, countIf(rows, r -> r.get(0).equals(4)));
rows = sql("SELECT val FROM BIG_TABLE1 INTERSECT SELECT val FROM BIG_TABLE2");
assertEquals(2, rows.size());
assertEquals(1, countIf(rows, r -> r.get(0).equals(1)));
assertEquals(1, countIf(rows, r -> r.get(0).equals(3)));
rows = sql("SELECT val FROM BIG_TABLE1 INTERSECT ALL SELECT val FROM BIG_TABLE2");
assertEquals(136, rows.size());
assertEquals(8, countIf(rows, r -> r.get(0).equals(1)));
assertEquals(128, countIf(rows, r -> r.get(0).equals(3)));
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItSortAggregateTest method initTestData.
/**
* Before all.
*/
@BeforeAll
static void initTestData() {
TableDefinition schTbl1 = SchemaBuilders.tableBuilder("PUBLIC", "TEST").columns(SchemaBuilders.column("ID", ColumnType.INT32).build(), SchemaBuilders.column("GRP0", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("GRP1", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("VAL0", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("VAL1", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("ID").withIndex(SchemaBuilders.sortedIndex("IDX").addIndexColumn("GRP0").done().addIndexColumn("GRP1").done().build()).build();
TableDefinition schTbl2 = SchemaBuilders.tableBuilder("PUBLIC", "TEST_ONE_COL_IDX").columns(SchemaBuilders.column("PK", ColumnType.INT32).build(), SchemaBuilders.column("COL0", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("PK").withIndex(SchemaBuilders.sortedIndex("IDX").addIndexColumn("COL0").desc().done().build()).build();
Table table = CLUSTER_NODES.get(0).tables().createTable(schTbl1.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl1, tblCh).changeReplicas(2).changePartitions(10));
Table tblOneColIdx = CLUSTER_NODES.get(0).tables().createTable(schTbl2.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl2, tblCh));
RecordView<Tuple> view = table.recordView();
for (int i = 0; i < ROWS; i++) {
view.insert(null, Tuple.create().set("ID", i).set("GRP0", i / 10).set("GRP1", i / 100).set("VAL0", 1).set("VAL1", 2));
}
RecordView<Tuple> view1 = tblOneColIdx.recordView();
for (int i = 0; i < ROWS; i++) {
view1.insert(null, Tuple.create().set("PK", i).set("COL0", i));
}
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItMetadataTest method columnOrder.
@Test
public void columnOrder() {
TableDefinition schTbl1 = SchemaBuilders.tableBuilder("PUBLIC", "COLUMN_ORDER").columns(SchemaBuilders.column("DOUBLE_C", ColumnType.DOUBLE).asNullable(true).build(), SchemaBuilders.column("LONG_C", ColumnType.INT64).build(), SchemaBuilders.column("STRING_C", ColumnType.string()).asNullable(true).build(), SchemaBuilders.column("INT_C", ColumnType.INT32).asNullable(true).build()).withPrimaryKey("LONG_C").build();
CLUSTER_NODES.get(0).tables().createTable(schTbl1.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl1, tblCh).changeReplicas(1).changePartitions(10));
assertQuery("select * from column_order").columnNames("DOUBLE_C", "LONG_C", "STRING_C", "INT_C").check();
}
Aggregations