Examples of CQLStatementIterator


Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

    NewDefinition.getFields().put(newField.getName(),newField);
    CObjectMigrator subject = new CObjectMigrator(OldDefinition,NewDefinition);
    assertEquals(subject.getNewIndexes().size(), 2);

    CObjectCQLGenerator cqlGenerator = new CObjectCQLGenerator(OldDefinition.getName(), 1000);
    CQLStatementIterator result = subject.getMigrationCQL(cqlGenerator);
    assertEquals("ALTER TABLE \"simple\".\"simple\" add newfield varchar", result.next().getQuery());
    assertEquals("ALTER TABLE \"simple\".\"simple3886e3439cce68f6363dc8f9d39ce041\" add newfield varchar", result.next().getQuery());
    assertEquals("ALTER TABLE \"simple\".\"simple2849d92a26f695e548ccda0db2a09b00\" add newfield varchar", result.next().getQuery());


    assertEquals("CREATE TABLE \"simple\".\"simplef27e6d073810cfb7826cf964c67b383e\" (id timeuuid, shardid bigint, newfield varchar,value varchar,index_1 varchar,index_2 varchar, PRIMARY KEY ((shardid, value),id) );", result.next().getQuery());
    assertEquals("CREATE TABLE \"simple\".\"simple02a6bb2fc3293d91f31c3f6ce892fedc\" (id timeuuid, shardid bigint, newfield varchar,value varchar,index_1 varchar,index_2 varchar, PRIMARY KEY ((shardid, index_1, index_2),id) );", result.next().getQuery());
    assertEquals(false, result.hasNext());
  }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

    CKeyspaceDefinitionMigrator subject = new CKeyspaceDefinitionMigrator(OldKeyspaceDefinition, NewKeyspaceDefinition);
    assertTrue(subject.isMigratable());

    //Now verify that the correct CQL is generated for the migration
    CObjectCQLGenerator cqlGenerator = new CObjectCQLGenerator(OldKeyspaceDefinition.getName(), 1000);
    CQLStatementIterator result = subject.getMigrationCQL(cqlGenerator);
    assertEquals("ALTER TABLE \"functional\".\"testtype\" add newfield varchar", result.next().getQuery());
    assertEquals("ALTER TABLE \"functional\".\"testtype6671808f3f51bcc53ddc76d2419c9060\" add newfield varchar", result.next().getQuery());
    assertEquals("ALTER TABLE \"functional\".\"testtypef9bf3332bb4ec879849ec43c67776131\" add newfield varchar", result.next().getQuery());
    assertEquals("ALTER TABLE \"functional\".\"testtype7f9bb4e56d3cae5b11c553547cfe5897\" add newfield varchar", result.next().getQuery());

    assertEquals("CREATE TABLE \"functional\".\"testtypeb4e47a87138afd20159a6522134a3bc2\" (id timeuuid, shardid bigint, newfield varchar,filtered int,data1 varchar,data2 varchar,data3 varchar,instance bigint,type int,foreignid bigint, PRIMARY KEY ((shardid, data1, data2),id) );",result.next().getQuery());
    assertEquals("CREATE TABLE \"functional\".\"simple\" (id timeuuid PRIMARY KEY, value varchar,index_1 varchar,index_2 varchar);", result.next().getQuery());
    assertEquals("CREATE TABLE \"functional\".\"simple3886e3439cce68f6363dc8f9d39ce041\" (id timeuuid, shardid bigint, value varchar,index_1 varchar,index_2 varchar, PRIMARY KEY ((shardid, index_1),id) );", result.next().getQuery());
    assertEquals("CREATE TABLE \"functional\".\"simple053960b6738c37f489c8a629b1b7c5d5\" (id timeuuid, shardid bigint, value varchar,index_1 varchar,index_2 varchar, PRIMARY KEY ((shardid, index_1, value),id) );", result.next().getQuery());
    assertEquals("CREATE TABLE \"functional\".\"simple2849d92a26f695e548ccda0db2a09b00\" (id timeuuid, shardid bigint, value varchar,index_1 varchar,index_2 varchar, PRIMARY KEY ((shardid, index_2),id) );", result.next().getQuery());

    //That should be it
    assertFalse(result.hasNext());
  }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

    public void testMakeCQLforInsert() throws CQLGenerationException, CObjectParseException, IOException {
      String json = TestHelpers.readFileToString(this.getClass(), "CObjectCQLGeneratorTestData.js");
      CDefinition def = CDefinition.fromJsonString(json);
      Map<String, Object> data = TestHelpers.getTestObject(0);
      UUID uuid = UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43");
      CQLStatementIterator result = Subject.makeCQLforInsert(KEYSPACE_NAME, def,data,uuid,Long.valueOf(1),null);
      List<CQLStatement> actual = toList(result);

      CQLStatement expected;
      assertEquals("Should generate CQL statements for the static table plus all indexes including the filtered index", 6, actual.size());
      //static table
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

    public void testMakeCQLforCreate() throws CObjectParseException, IOException {
      String json = TestHelpers.readFileToString(this.getClass(), "CObjectCQLGeneratorTestData.js");
      CDefinition def = CDefinition.fromJsonString(json);
      Subject subject = new Subject(1000);
      CQLStatementIterator actual = subject.makeCQLforCreate(def);
      assertEquals("Should generate CQL statements for the static table plus all indexes", 4, actual.size());
    }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

      String json = TestHelpers.readFileToString(this.getClass(), "CObjectCQLGeneratorTestData.js");
      CDefinition def = CDefinition.fromJsonString(json);

      //Static Table Get
      UUID uuid = UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43");
      CQLStatementIterator actual = Subject.makeCQLforGet(KEYSPACE_NAME, def, uuid);
      assertEquals("Static gets should return bounded query iterator", true,actual.isBounded());
      assertEquals("Static gets should return an iterator with 1 statement", 1,actual.size());
      Object[] expectedValues = {uuid};
      CQLStatement expected = CQLStatement.make("SELECT * FROM \"testspace\".\"testtype\" WHERE id = ?;", TABLE_NAME, expectedValues);
      assertEquals("Should generate proper CQL for static table get by ID", expected, toList(actual).get(0));

      CObjectShardList shardIdLists = new ShardListMock(Arrays.asList(1L,2L,3L,4L,5L));
      UUID start = UUID.fromString("a8a2abe0-a251-11e2-bcbb-adf1a79a327f");
      UUID stop = UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43");
      //Wide table using shardIdList and therefore bounded
      TreeMap<String,Object> indexkeys = Maps.newTreeMap();
      indexkeys.put("foreignid","777");
      indexkeys.put("type", "5");
      indexkeys.put("instance", "222222");
      actual = CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.DESCENDING, null, UUIDs.startOf(DateTime.now().getMillis()), 10l, false, false, false);
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id < ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          arrayFromValues(Long.valueOf(1),"777","222222","5", stop)
      );
      CQLStatement result = actual.next();
      assertEquals(expected.getQuery(), result.getQuery());
      assertEquals(expected.getValues()[0], result.getValues()[0]);
      assertEquals(expected.getValues()[1], result.getValues()[1]);
      assertEquals(expected.getValues()[2], result.getValues()[2]);
      assertEquals(expected.getValues()[3], result.getValues()[3]);

      //expected = "SELECT * FROM \"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = 2 AND foreignid = 777 AND instance = 222222 AND type = 5 AND id <";
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id < ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          Arrays.asList(Long.valueOf(2),"777","222222","5", stop).toArray()
      );

      actual.nextShard();
      result = actual.next();
      assertEquals(expected.getQuery(), result.getQuery());
      assertEquals(expected.getValues()[0], result.getValues()[0]);
      assertEquals(expected.getValues()[1], result.getValues()[1]);
      assertEquals(expected.getValues()[2], result.getValues()[2]);
      assertEquals(expected.getValues()[3], result.getValues()[3]);
      assertEquals("Should be bounded query list", true, actual.isBounded());


      //Wide table exclusive slice bounded query should not use shard list
      indexkeys = Maps.newTreeMap();
      indexkeys.put("foreignid","777");
      indexkeys.put("type", "5");
      indexkeys.put("instance", "222222");
      actual = CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.DESCENDING, start, stop, 10l, false, false, false);
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id > ? AND id < ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          arrayFromValues(Long.valueOf(160),"777","222222","5", start, stop)
      );
      //"Should generate proper CQL for wide table get by index values"
      CQLStatement actualStatement = actual.next();
      assertEquals(expected, actualStatement);
      assertTrue("Should be bounded query iterator", actual.isBounded());
      assertTrue("Should be none remaining in the iterator", !actual.hasNext());


      //wide table inclusive slice ascending bounded
      start = UUID.fromString("b4c10d80-15f0-11e0-8080-808080808080"); // 1/1/2011 long startd = 1293918439000L;
      stop = UUID.fromString("2d87f48f-34c2-11e1-7f7f-7f7f7f7f7f7f"); //1/1/2012 long endd = 1325454439000L;
      actual = CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.ASCENDING, start, stop, 10l, true, false, false);
      assertEquals("Should be proper size for range", 13, actual.size()); //All of 2011 plus the first month of 2012
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id ASC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          arrayFromValues(Long.valueOf(133),"777","222222","5",start,stop)
      );
      //Should generate proper CQL for wide table get by index values"
      actualStatement = actual.next();
      assertEquals(expected, actualStatement);

      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id ASC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          Arrays.asList(Long.valueOf(134),"777","222222","5",start,stop).toArray()
      );
      actual.nextShard();
      //Should generate proper CQL for wide table get by index values
      assertEquals(expected,actual.next());

      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id ASC LIMIT 5 ALLOW FILTERING;",
          TABLE_NAME,
          Arrays.asList(Long.valueOf(135),"777","222222","5",start,stop).toArray()
      );
      assertTrue("Should have next when hinted less than the limit",actual.hasNext(5));
      actual.nextShard();
      //"Should generate proper Limit adjustment when given the amount hint"
      assertEquals(expected,actual.next());
      assertTrue("Should have no next when hinted more than or equal to the limit",!actual.hasNext(10));

      //wide table inclusive slice descending bounded
      start = UUID.fromString("b4c10d80-15f0-11e0-8080-808080808080"); // 1/1/2011 long startd = 1293918439000L;
      stop = UUID.fromString("2d87f48f-34c2-11e1-7f7f-7f7f7f7f7f7f"); //1/1/2012 long endd = 1325454439000L;
      actual = Subject.makeCQLforList(KEYSPACE_NAME, shardIdLists, def, indexkeys, CObjectOrdering.DESCENDING, start, stop, 10l, true, false, false);
      assertEquals("Descending: Should be proper size for range", 13, actual.size()); //All of 2011 plus the first month of 2012
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          arrayFromValues(Long.valueOf(145),"777","222222","5",start,stop)
      );
      //"Descending: Should generate proper CQL for wide table get by index values"
      assertEquals(expected,actual.next());
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id DESC LIMIT 10 ALLOW FILTERING;",
          TABLE_NAME,
          Arrays.asList(Long.valueOf(144),"777","222222","5",start,stop).toArray()
      );
      actual.nextShard();
      assertEquals("Descending: Should generate proper CQL for wide table get by index values",expected,actual.next());
      expected = CQLStatement.make(
          "SELECT * FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE shardid = ? AND foreignid = ? AND instance = ? AND type = ? AND id >= ? AND id <= ? ORDER BY id DESC LIMIT 5 ALLOW FILTERING;",
          TABLE_NAME,
          Arrays.asList(Long.valueOf(143),"777","222222","5",start,stop).toArray()
      );
      assertTrue("Descending: Should have next when hinted less than the limit",actual.hasNext(5));
      actual.nextShard();
      assertEquals("Descending: Should generate proper Limit adjustment when given the amount hint",expected,actual.next());
      assertTrue("Should have no next when hinted more than or equal to the limit",!actual.hasNext(10));

    }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

    public void testMakeCQLforDelete() throws CObjectParseException,CObjectParseException, CQLGenerationException, IOException {
      String json = TestHelpers.readFileToString(this.getClass(), "CObjectCQLGeneratorTestData.js");
      CDefinition def = CDefinition.fromJsonString(json);
      Map<String, Object> data = TestHelpers.getTestObject(0);
      UUID uuid = UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43");
      CQLStatementIterator result = Subject.makeCQLforDelete(KEYSPACE_NAME, def,uuid,data,Long.valueOf(111));

      CQLStatement expected;

      expected = CQLStatement.make("DELETE FROM \"testspace\".\"testtype\" WHERE id = ?;", TABLE_NAME, Arrays.asList(uuid).toArray());
      assertEquals(expected,result.next());

      expected = CQLStatement.make(
          "DELETE FROM \"testspace\".\"testtype6671808f3f51bcc53ddc76d2419c9060\" WHERE id = ? AND shardid = ? AND instance = ? AND type = ?;",
          TABLE_NAME,
          Arrays.asList(uuid,Long.valueOf(160), 222222, 5).toArray());
      assertEquals(expected,result.next());
      expected = CQLStatement.make(
          "DELETE FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE id = ? AND shardid = ? AND foreignid = ? AND instance = ? AND type = ?;",
          TABLE_NAME,
          Arrays.asList(uuid,Long.valueOf(160), 777, 222222, 5).toArray());
      assertEquals(expected,result.next());
      expected = CQLStatement.make(
          "DELETE FROM \"testspace\".\"testtype7f9bb4e56d3cae5b11c553547cfe5897\" WHERE id = ? AND shardid = ? AND foreignid = ?;",
          TABLE_NAME,
          Arrays.asList(uuid,Long.valueOf(1), 777).toArray());
      assertEquals(expected,result.next());
      assertTrue(!result.hasNext());

    }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

      CDefinition def = CDefinition.fromJsonString(json);
      Map<String, Object> data = TestHelpers.getTestObject(0);
      UUID uuid = UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43");
      Map<String,Object> newdata = Maps.newHashMap();
      newdata.put("type", Integer.valueOf(9));
      CQLStatementIterator result = Subject.makeCQLforUpdate(KEYSPACE_NAME, def,uuid,data,newdata);
      CQLStatement expected = CQLStatement.make(
          "DELETE FROM \"testspace\".\"testtype6671808f3f51bcc53ddc76d2419c9060\" WHERE id = ? AND shardid = ? AND instance = ? AND type = ?;",
          TABLE_NAME,
          Arrays.asList(UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"), Long.valueOf(160), Integer.valueOf(222222), Integer.valueOf(5)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "DELETE FROM \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" WHERE id = ? AND shardid = ? AND foreignid = ? AND instance = ? AND type = ?;",
          TABLE_NAME,
          Arrays.asList(UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"), Long.valueOf(160), Integer.valueOf(777), Integer.valueOf(222222), Integer.valueOf(5)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype6671808f3f51bcc53ddc76d2419c9060\" (id, shardid, filtered, data1, data2, data3, instance, type, foreignid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
          UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
          Long.valueOf(160),
          Integer.valueOf(1),
          "This is data one",
          "This is data two",
          "This is data three",
          Integer.valueOf(222222),
          Integer.valueOf(9),
          Integer.valueOf(777)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__shardindex\" (tablename, indexvalues, shardid, targetrowkey) VALUES (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
            "testtype6671808f3f51bcc53ddc76d2419c9060",
            "222222:9",
            Long.valueOf(160),
            "160:222222:9").toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" (id, shardid, filtered, data1, data2, data3, instance, type, foreignid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
            UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
            Long.valueOf(160),
            Integer.valueOf(1),
            "This is data one",
            "This is data two",
            "This is data three",
            Integer.valueOf(222222),
            Integer.valueOf(9),
            Integer.valueOf(777)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__shardindex\" (tablename, indexvalues, shardid, targetrowkey) VALUES (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
            "testtypef9bf3332bb4ec879849ec43c67776131",
            "777:222222:9",
            Long.valueOf(160),
            "160:777:222222:9").toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype7f9bb4e56d3cae5b11c553547cfe5897\" (id, shardid, instance, type, foreignid) VALUES (?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
            UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
            Long.valueOf(1),
            222222,
            9,
            777).toArray()
      );
      assertEquals(expected, result.next());
      //verify that this last insert was on the uneffected index (which is why it does not have a matching __shardindex insert
      assertEquals("testtype7f9bb4e56d3cae5b11c553547cfe5897",makeTableName(def,def.getIndexes().get("foreignid")));
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype\" (id, type) VALUES (?, ?);",
          TABLE_NAME,
          Arrays.asList(
            UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
            Integer.valueOf(9)).toArray()
      );
      assertEquals(expected, result.next());
      CQLStatement next = result.next();
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__index_updates\" (id, statictablename, instanceid, indexvalues) values (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              (UUID)next.getValues()[0],
              "testtype",
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              "{\"foreignid\":777,\"instance\":222222,\"type\":9}").toArray()
      );
      assertEquals(expected, next);
      //should be no results left
      assertTrue(!result.hasNext());




      //Now try the same update, but this time we dont change anything and send the same values. In this case
      //It should not generate any deletes
      newdata.put("type", Integer.valueOf(5));
       result = Subject.makeCQLforUpdate(KEYSPACE_NAME, def,uuid,data,newdata);
      //no deletes
      //Go right to the inserts
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype6671808f3f51bcc53ddc76d2419c9060\" (id, shardid, filtered, data1, data2, data3, instance, type, foreignid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              Long.valueOf(160),
              Integer.valueOf(1),
              "This is data one",
              "This is data two",
              "This is data three",
              Integer.valueOf(222222),
              Integer.valueOf(5),
              Integer.valueOf(777)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__shardindex\" (tablename, indexvalues, shardid, targetrowkey) VALUES (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              "testtype6671808f3f51bcc53ddc76d2419c9060",
              "222222:5",
              Long.valueOf(160),
              "160:222222:5").toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtypef9bf3332bb4ec879849ec43c67776131\" (id, shardid, filtered, data1, data2, data3, instance, type, foreignid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              Long.valueOf(160),
              Integer.valueOf(1),
              "This is data one",
              "This is data two",
              "This is data three",
              Integer.valueOf(222222),
              Integer.valueOf(5),
              Integer.valueOf(777)).toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__shardindex\" (tablename, indexvalues, shardid, targetrowkey) VALUES (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              "testtypef9bf3332bb4ec879849ec43c67776131",
              "777:222222:5",
              Long.valueOf(160),
              "160:777:222222:5").toArray()
      );
      assertEquals(expected, result.next());
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype7f9bb4e56d3cae5b11c553547cfe5897\" (id, shardid, instance, type, foreignid) VALUES (?, ?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              Long.valueOf(1),
              222222,
              5,
              777).toArray()
      );
      assertEquals(expected, result.next());
      //verify that this last insert was on the uneffected index (which is why it does not have a matching __shardindex insert
      assertEquals("testtype7f9bb4e56d3cae5b11c553547cfe5897",makeTableName(def,def.getIndexes().get("foreignid")));
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"testtype\" (id, type) VALUES (?, ?);",
          TABLE_NAME,
          Arrays.asList(
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              Integer.valueOf(5)).toArray()
      );
      assertEquals(expected, result.next());
      next = result.next();
      expected = CQLStatement.make(
          "INSERT INTO \"testspace\".\"__index_updates\" (id, statictablename, instanceid, indexvalues) values (?, ?, ?, ?);",
          TABLE_NAME,
          Arrays.asList(
              (UUID)next.getValues()[0],
              "testtype",
              UUID.fromString("ada375b0-a2d9-11e2-99a3-3f36d3955e43"),
              "{\"foreignid\":777,\"instance\":222222,\"type\":5}").toArray()
      );
      assertEquals(expected, next);
      //should be no results left
      assertTrue(!result.hasNext());


    }
View Full Code Here

Examples of com.pardot.rhombus.cobject.statement.CQLStatementIterator

      indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      Criteria criteria = new Criteria();
      criteria.setIndexKeys(indexValues);

      CObjectCQLGenerator cqlGenerator = om.getCqlGenerator_ONLY_FOR_TESTING();
      CQLStatementIterator unBoundedIterator = cqlGenerator.makeCQLforList(objectType, criteria, false);

      Session session = cm.getRhombusSession(definition);
      CQLExecutor cqlExecutor = new CQLExecutor(session, true, definition.getConsistencyLevel());
      CQLExecutorIterator cqlExecutorIterator = new CQLExecutorIterator(cqlExecutor, unBoundedIterator);
      cqlExecutorIterator.setPageSize(nDataItems-1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.