Package com.splout.db.engine

Examples of com.splout.db.engine.SQLite4JavaClient


    // Each random deployment will have a fixed random string associated with it
    String randomStr = "ID" + Math.abs(random.nextInt());

    for(int i = 0; i < N_DNODES; i++) {
      File dbData = new File(deployData, i + ".db");
      SQLite4JavaClient manager = new SQLite4JavaClient(dbData + "", null);
      // We create a foo database with one integer and one text
      manager.query("CREATE TABLE foo (intCol INT, strCol TEXT);", 100);
      // We insert as many values as the ones we defined in the partition map
      for(int j = i * 10; j < (i * 10 + 10); j++) {
        manager.query("INSERT INTO foo VALUES (" + j + ", " + "'" + randomStr + "');", 100);
      }
      manager.close();
    }

    SploutConfiguration config = SploutConfiguration.getTestConfig();
    SploutClient client = getRandomQNodeClient(random, config);
    client.deploy("p1", testTablespace.getPartitionMap(), testTablespace.getReplicationMap(),
View Full Code Here


    List totalPayments = new ArrayList();
    List totalLogs = new ArrayList();
    List<String> jsonGeoData = new ArrayList<String>();
   
    for(int i = 0; i < 3; i++) {
      SQLite4JavaClient manager = new SQLite4JavaClient(TEST_OUTPUT + "/store/" + i + ".db", null);
      List list;
      list = JSONSerDe.deSer(manager.query("SELECT * FROM payments;", 100), ArrayList.class);
      totalPayments.addAll(list);
      System.out.println(list);
      assertEquals(1, list.size()); // There is one payment per each person
      list = JSONSerDe.deSer(manager.query("SELECT * FROM logs;", 100), ArrayList.class);
      totalLogs.addAll(list);
      assertEquals(2, list.size()); // There are two log events per each person
      String geoDataStr = manager.query("SELECT * FROM geodata;", 100);
      jsonGeoData.add(geoDataStr);
      list = JSONSerDe.deSer(geoDataStr, ArrayList.class);
      assertEquals(3, list.size()); // There are 3 countries in the replicated geo data file
      manager.close();
    }
   
    assertEquals(6, totalLogs.size());
    assertEquals(3, totalPayments.size());
    assertEquals(3, jsonGeoData.size());
View Full Code Here

    List totalPayments = new ArrayList();
    List totalLogs = new ArrayList();
    List distinctKeys = new ArrayList();
   
    for(int i = 0; i < 3; i++) {
      SQLite4JavaClient manager = new SQLite4JavaClient(TEST_OUTPUT + "/store/" + i + ".db", null);
      List list;
      list = JSONSerDe.deSer(manager.query("SELECT * FROM payments;", 100), ArrayList.class);
      totalPayments.addAll(list);
      Set<String> uniqueKeysInPartition = new HashSet<String>();
      for(Object obj: list) {
        uniqueKeysInPartition.add(((Map)obj).get("name") + "" + ((Map)obj).get("commerce"));
      }
      distinctKeys.addAll(uniqueKeysInPartition);
      list = JSONSerDe.deSer(manager.query("SELECT * FROM logs;", 100), ArrayList.class);
      totalLogs.addAll(list);
      manager.close();
    }

    String keys = StringUtils.join(distinctKeys.toArray(), ", ");

    assertEquals(4, distinctKeys.size());
View Full Code Here

    runTest(new DefaultEngine());
   
    // Assert that the DB has been created successfully
   
    assertTrue(new File(OUTPUT + "/0.db").exists());
    SQLite4JavaClient manager = new SQLite4JavaClient(OUTPUT + "/0.db", null);
    @SuppressWarnings("rawtypes")
    List list = JSONSerDe.deSer(manager.query("SELECT * FROM schema1;", 100), ArrayList.class);
    assertEquals(6, list.size());
   
    manager.close();
  }
View Full Code Here

    File deployData = new File(TMP_FOLDER + "/" + "deploy-folder-" + random.nextInt());
    deployData.mkdir();

    for(int i = 0; i < N_DNODES; i++) {
      File dbData = new File(deployData, i + ".db");
      SQLite4JavaClient manager = new SQLite4JavaClient(dbData + "", null);
      // We create a foo database with one integer and one text
      manager.query("CREATE TABLE " + TABLE + " (iteration INT, dnode INT);", 100);
      // We insert as many values as the ones we defined in the partition map
      manager.query("INSERT INTO " + TABLE + " VALUES (" + iteration + ", " + i + ");", 100);
      manager.close();
    }

    log.info("Deploying deploy iteration [" + iteration + "]");
    client.deploy(TABLESPACE, testTablespace.getPartitionMap(), testTablespace.getReplicationMap(),
        deployData.getAbsoluteFile().toURI());
View Full Code Here

   
    TablespaceSpec tablespace = TablespaceSpec.of(theSchema2, "id", new Path(INPUT), new TupleInputFormat(), 1);
    TablespaceGenerator viewGenerator = new TablespaceGenerator(tablespace, new Path(OUTPUT), this.getClass());
    viewGenerator.generateView(conf, SamplingType.FULL_SCAN, new TupleSampler.RandomSamplingOptions());
   
    SQLite4JavaClient manager = new SQLite4JavaClient(OUTPUT + "/store/0.db", null);
    String results = manager.query("SELECT * FROM schema2;", 100);
    assertTrue(results.contains("null"));

    assertNull(searchRow(results, "id", "id1").get("intValue"));
    assertEquals(-1.0, searchRow(results, "id", "id1").get("doubleValue"));
    assertNull(searchRow(results, "id", "id1").get("strValue"));
View Full Code Here

    builder.add(tBuilder.build());

    TablespaceGenerator viewGenerator = new TablespaceGenerator(builder.build(), new Path(OUTPUT), this.getClass());
    viewGenerator.generateView(conf, SamplingType.FULL_SCAN, new TupleSampler.RandomSamplingOptions());

    SQLite4JavaClient manager = new SQLite4JavaClient(OUTPUT + "/store/0.db", null);
    String results = manager.query("SELECT * FROM schema1;", TUPLES_TO_GENERATE+1);

    System.out.println(results);
    for(int i=0; i<TUPLES_TO_GENERATE; i++) {
      assertEquals("id" + i + "mod", getVal(results, i, "id"));
      assertEquals("str" + i + "mod", getVal(results, i, "value"));
View Full Code Here

    File deployData = new File(TMP_FOLDER + "/" + "deploy-folder-" + random.nextInt());
    deployData.mkdir();

    for(int i = 0; i < N_DNODES; i++) {
      File dbData = new File(deployData, i + ".db");
      SQLite4JavaClient manager = new SQLite4JavaClient(dbData + "", null);
      // We create a foo database with one integer and one text
      manager.query("CREATE TABLE " + TABLE + " (iteration INT, dnode INT);", 100);
      // We insert as many values as the ones we defined in the partition map
      manager.query("INSERT INTO " + TABLE + " VALUES (" + iteration + ", " + i + ");", 100);
      manager.close();
    }

    log.info("Deploying deploy iteration [" + iteration + "]");
    client.deploy(TABLESPACE, testTablespace.getPartitionMap(), testTablespace.getReplicationMap(),
        deployData.getAbsoluteFile().toURI());
View Full Code Here

TOP

Related Classes of com.splout.db.engine.SQLite4JavaClient

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.