Package com.youtube.vitess.vtgate

Examples of com.youtube.vitess.vtgate.Row$Cell


      }
    }
    if (!cursor.hasNext()) {
      return false;
    }
    Row row = cursor.next();
    rowWritable = new RowWritable(row);
    rowsProcessed++;
    try {
      KeyspaceId keyspaceId = KeyspaceId.valueOf(row.getULong(KeyspaceId.COL_NAME));
      kidWritable = new KeyspaceIdWritable(keyspaceId);
    } catch (InvalidFieldException e) {
      throw new RuntimeException(e);
    }
    return true;
View Full Code Here


    int size = in.readInt();
    LinkedList<Cell> cells = new LinkedList<>();
    for (int i = 0; i < size; i++) {
      cells.add(readCell(in));
    }
    row = new Row(cells);
  }
View Full Code Here

        byte[] val = col != null ? (byte[]) col : null;
        Field field = fieldsIter.next();
        FieldType ft = field.getType();
        cells.add(new Cell(field.getName(), ft.convert(val), ft.javaType));
      }
      rowList.add(new Row(cells));
    }
    return rowList;
  }
View Full Code Here

    String selectSql = "select * from vtocc_ints where tiny = -128";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getInt("tiny").equals(-128));
    Assert.assertTrue(row.getInt("tinyu").equals(255));
    Assert.assertTrue(row.getInt("small").equals(-32768));
    Assert.assertTrue(row.getInt("smallu").equals(65535));
    Assert.assertTrue(row.getInt("medium").equals(-8388608));
    Assert.assertTrue(row.getInt("mediumu").equals(16777215));
    Assert.assertTrue(row.getLong("normal").equals(-2147483648L));
    Assert.assertTrue(row.getLong("normalu").equals(4294967295L));
    Assert.assertTrue(row.getLong("big").equals(-9223372036854775808L));
    Assert.assertTrue(row.getULong("bigu").equals(UnsignedLong.valueOf("18446744073709551615")));
    Assert.assertTrue(row.getShort("year").equals((short) 2012));
    vtgate.close();
  }
View Full Code Here

    String selectSql = "select * from vtocc_fracts where id = 1";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getLong("id").equals(1L));
    Assert.assertTrue(row.getBigDecimal("deci").equals(new BigDecimal("1.99")));
    Assert.assertTrue(row.getBigDecimal("num").equals(new BigDecimal("2.99")));
    Assert.assertTrue(row.getFloat("f").equals(3.99F));
    Assert.assertTrue(row.getDouble("d").equals(4.99));
    vtgate.close();
  }
View Full Code Here

    String selectSql = "select * from vtocc_strings where vb = 'a'";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(Arrays.equals(row.getBytes("vb"), "a".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("c"), "b".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("vc"), "c".getBytes()));
    // binary(4) column will be suffixed with three 0 bytes
    Assert.assertTrue(
        Arrays.equals(row.getBytes("b"), ByteBuffer.allocate(4).put((byte) 'd').array()));
    Assert.assertTrue(Arrays.equals(row.getBytes("tb"), "e".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("bl"), "f".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("ttx"), "g".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("tx"), "h".getBytes()));
    // Assert.assertTrue(row.getString("en").equals("a"));
    // Assert.assertTrue(row.getString("s").equals("a,b"));
    vtgate.close();
  }
View Full Code Here

    String selectSql = "select * from vtocc_misc where id = 1";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getLong("id").equals(1L));
    Assert.assertTrue(
        Arrays.equals(row.getBytes("b"), ByteBuffer.allocate(1).put((byte) 1).array()));
    Assert.assertTrue(row.getDateTime("d").equals(DateTime.parse("2012-01-01")));
    Assert.assertTrue(row.getDateTime("dt").equals(DateTime.parse("2012-01-01T15:45:45")));
    Assert.assertTrue(row.getDateTime("t").equals(
        DateTime.parse("15:45:45", ISODateTimeFormat.timeElementParser())));
    vtgate.close();
  }
View Full Code Here

    Query query =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyspaceId(firstKid).build();
    cursor = vtgate.execute(query);

    // Check field types and values
    Row row = cursor.next();
    Cell idCell = row.next();
    Assert.assertEquals("id", idCell.getName());
    Assert.assertEquals(UnsignedLong.class, idCell.getType());
    UnsignedLong id = row.getULong(idCell.getName());

    Cell nameCell = row.next();
    Assert.assertEquals("name", nameCell.getName());
    Assert.assertEquals(byte[].class, nameCell.getType());
    Assert.assertTrue(
        Arrays.equals(("name_" + id.toString()).getBytes(), row.getBytes(nameCell.getName())));

    Cell ageCell = row.next();
    Assert.assertEquals("age", ageCell.getName());
    Assert.assertEquals(Integer.class, ageCell.getType());
    Assert.assertEquals(Integer.valueOf(2 * id.intValue()), row.getInt(ageCell.getName()));

    vtgate.close();
  }
View Full Code Here

    DateTime dt = DateTime.now().minusDays(2).withMillisOfSecond(0);
    Util.insertRows(testEnv, 10, 1, dt);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    Query allRowsQuery = new QueryBuilder("select * from vtgate_test", testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).build();
    Row row = vtgate.execute(allRowsQuery).next();
    Assert.assertTrue(dt.equals(row.getDateTime("timestamp_col")));
    Assert.assertTrue(dt.equals(row.getDateTime("datetime_col")));
    Assert.assertTrue(dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0)
        .equals(row.getDateTime("date_col")));
    Assert.assertTrue(
        dt.withYear(1970).withMonthOfYear(1).withDayOfMonth(1).equals(row.getDateTime("time_col")));

    vtgate.close();
  }
View Full Code Here

TOP

Related Classes of com.youtube.vitess.vtgate.Row$Cell

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.