public static void assertColumns(ColumnFamily cf, String... columnNames) {
   Collection<IColumn> columns = cf == null ? new TreeSet<IColumn>() : cf.getSortedColumns();
   List<String> L = new ArrayList<String>();
   for (IColumn column : columns) {
     L.add(new String(column.name()));
   }
   assert Arrays.equals(L.toArray(new String[columns.size()]), columnNames)
       : "Columns ["
           + ((cf == null) ? "" : cf.getComparator().getColumnsString(columns))
           + "]"
           + " is not expected ["
           + StringUtils.join(columnNames, ",")
           + "]";
 }
Exemplo n.º 2
0
 @Test
 public void downloadAsInputStream() throws IOException {
   InputStream byteStream = object.downloadObjectAsInputStream();
   assertTrue(Arrays.equals(bytes, IOUtils.toByteArray(byteStream)));
 }
Exemplo n.º 3
0
 @Test
 public void downloadAsByteArray() {
   byte[] result = object.downloadObject();
   assertTrue(Arrays.equals(bytes, result));
 }
  private void validateSliceLarge(ColumnFamilyStore cfStore) throws IOException {
    String key = "row3";
    ColumnFamily cf;
    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col1000".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            false,
            3);
    assertColumns(cf, "col1000", "col1001", "col1002");
    assertEquals(new String(cf.getColumn("col1000".getBytes()).value()), "v1000");
    assertEquals(new String(cf.getColumn("col1001".getBytes()).value()), "v1001");
    assertEquals(new String(cf.getColumn("col1002".getBytes()).value()), "v1002");

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col1195".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            false,
            3);
    assertColumns(cf, "col1195", "col1196", "col1197");
    assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "v1195");
    assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "v1196");
    assertEquals(new String(cf.getColumn("col1197".getBytes()).value()), "v1197");

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col1996".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            true,
            1000);
    IColumn[] columns = cf.getSortedColumns().toArray(new IColumn[0]);
    for (int i = 1000; i < 1996; i++) {
      String expectedName = "col" + i;
      IColumn column = columns[i - 1000];
      assert Arrays.equals(column.name(), expectedName.getBytes())
          : cfStore.getComparator().getString(column.name()) + " is not " + expectedName;
      assert Arrays.equals(column.value(), ("v" + i).getBytes());
    }

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col1990".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            false,
            3);
    assertColumns(cf, "col1990", "col1991", "col1992");
    assertEquals(new String(cf.getColumn("col1990".getBytes()).value()), "v1990");
    assertEquals(new String(cf.getColumn("col1991".getBytes()).value()), "v1991");
    assertEquals(new String(cf.getColumn("col1992".getBytes()).value()), "v1992");

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            ArrayUtils.EMPTY_BYTE_ARRAY,
            true,
            3);
    assertColumns(cf, "col1997", "col1998", "col1999");
    assertEquals(new String(cf.getColumn("col1999".getBytes()).value()), "v1999");
    assertEquals(new String(cf.getColumn("col1998".getBytes()).value()), "v1998");
    assertEquals(new String(cf.getColumn("col1997".getBytes()).value()), "v1997");

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col9000".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            true,
            3);
    assertColumns(cf, "col1997", "col1998", "col1999");

    cf =
        cfStore.getColumnFamily(
            key,
            new QueryPath("Standard1"),
            "col9000".getBytes(),
            ArrayUtils.EMPTY_BYTE_ARRAY,
            false,
            3);
    assertColumns(cf);
  }