Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.Result


    KeyValue kv1 = new KeyValue(HConstants.EMPTY_START_ROW,
        HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
    KeyValue [] expected = {kv1};
   
    //Test from memstore
    Result res = region.get(get, null);
   
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }
   
    //flush
    region.flushcache();
   
    //test2
    res = region.get(get, null);
   
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }
   
    //Scan
    Scan scan = new Scan();
    scan.addFamily(HConstants.CATALOG_FAMILY);
    InternalScanner s = region.getScanner(scan);
    List<KeyValue> result = new ArrayList<KeyValue>();
    s.next(result);
   
    assertEquals(expected.length, result.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), result.get(i).getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), result.get(i).getFamily()));
      assertEquals(0,
View Full Code Here


    long result = region.incrementColumnValue(row, fam1, qual3, amount, true);
    assertEquals(amount, result);

    Get get = new Get(row);
    get.addColumn(fam1, qual3);
    Result rr = region.get(get, null);
    assertEquals(1, rr.size());

    // ensure none of the other cols were incremented.
    assertICV(row, fam1, qual1, value);
    assertICV(row, fam1, qual2, value);
    assertICV(row, fam1, qual3, amount);
View Full Code Here

                         byte[] qualifier,
                         long amount) throws IOException {
    // run a get and see?
    Get get = new Get(row);
    get.addColumn(familiy, qualifier);
    Result result = region.get(get, null);
    assertEquals(1, result.size());

    KeyValue kv = result.raw()[0];
    long r = Bytes.toLong(kv.getValue());
    assertEquals(amount, r);
  }
View Full Code Here

    putThread.start();
    FlushThread flushThread = new FlushThread();
    flushThread.start();

    Get get = new Get(Bytes.toBytes("row0"));
    Result result = null;

    int expectedCount = numFamilies * numQualifiers;

    long prevTimestamp = 0L;
    for (int i = 0; i < testCount; i++) {

      if (i != 0 && i % compactInterval == 0) {
        region.compactStores(true);
      }

      if (i != 0 && i % flushInterval == 0) {
        //System.out.println("iteration = " + i);
        flushThread.flush();
      }

      boolean previousEmpty = result == null || result.isEmpty();
      result = region.get(get, null);
      if (!result.isEmpty() || !previousEmpty || i > compactInterval) {
        Assert.assertEquals("i=" + i, expectedCount, result.size());
        long timestamp =
          result.getCellValue(families[0], qualifiers[0]).getTimestamp();
        Assert.assertTrue(timestamp >= prevTimestamp);
        prevTimestamp = timestamp;
      }
    }

View Full Code Here

      byte [] row = Bytes.toBytes("" + i);
      Get get = new Get(row);
      for(byte [] family : families) {
        get.addColumn(family, qf);
      }
      Result result = newReg.get(get, null);
      KeyValue [] raw = result.sorted();
      assertEquals(families.length, result.size());
      for(int j=0; j<families.length; j++) {
        assertEquals(0, Bytes.compareTo(row, raw[j].getRow()));
        assertEquals(0, Bytes.compareTo(families[j], raw[j].getFamily()));
        assertEquals(0, Bytes.compareTo(qf, raw[j].getQualifier()));
      }
View Full Code Here

    byte[] firstRowInTable = Bytes.toBytes(tableName + ",,");
    Scan scan = new Scan(firstRowInTable);
    scan.addColumn(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
    long scannerid = srvr.openScanner(metaRegionName, scan);
    try {
      Result data = srvr.next(scannerid);
      if (data != null && data.size() > 0) {
        HRegionInfo info = Writables.getHRegionInfo(
            data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
        if (info.getTableDesc().getNameAsString().equals(tableName)) {
          // A region for this table already exists. Ergo table exists.
          throw new TableExistsException(tableName);
        }
      }
View Full Code Here

      scan.addColumn(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
      scan.addColumn(CATALOG_FAMILY, SERVER_QUALIFIER);
      long scannerid = srvr.openScanner(metaRegionName, scan);
      try {
        while (true) {
          Result data = srvr.next(scannerid);
          if (data == null || data.size() <= 0)
            break;
          HRegionInfo info = Writables.getHRegionInfo(
              data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
          if (Bytes.compareTo(info.getTableDesc().getName(), tableName) == 0) {
            byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
            if (value != null) {
              HServerAddress server =
                new HServerAddress(Bytes.toString(value));
              result.add(new Pair<HRegionInfo,HServerAddress>(info, server));
            }
View Full Code Here

      scan.addColumn(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
      scan.addColumn(CATALOG_FAMILY, SERVER_QUALIFIER);
      long scannerid = srvr.openScanner(metaRegionName, scan);
      try {
        while (true) {
          Result data = srvr.next(scannerid);
          if (data == null || data.size() <= 0)
            break;
          HRegionInfo info = Writables.getHRegionInfo(
              data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
          if (Bytes.compareTo(info.getTableDesc().getName(), tableName) == 0) {
            if ((Bytes.compareTo(info.getStartKey(), rowKey) >= 0) &&
                (Bytes.compareTo(info.getEndKey(), rowKey) < 0)) {
                byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
                if (value != null) {
                  HServerAddress server =
                    new HServerAddress(Bytes.toString(value));
                  return new Pair<HRegionInfo,HServerAddress>(info, server);
                }
View Full Code Here

      byte [] metaRegionName = m.getRegionName();
      HRegionInterface srvr = connection.getHRegionConnection(m.getServer());
      Get get = new Get(regionName);
      get.addColumn(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
      get.addColumn(CATALOG_FAMILY, SERVER_QUALIFIER);
      Result data = srvr.get(metaRegionName, get);
      if(data == null || data.size() <= 0) continue;
      HRegionInfo info = Writables.getHRegionInfo(
          data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
      byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
      if(value != null) {
        HServerAddress server =
          new HServerAddress(Bytes.toString(value));
        return new Pair<HRegionInfo,HServerAddress>(info, server);
      }
View Full Code Here

      String servername = null;
      if (args.length == 2) {
        servername = Bytes.toString(((ImmutableBytesWritable)args[1]).get());
      }
      // Need hri
      Result rr = getFromMETA(regionname, HConstants.CATALOG_FAMILY);
      HRegionInfo hri = getHRegionInfo(rr.getRow(), rr);
      if (servername == null) {
        // Get server from the .META. if it wasn't passed as argument
        servername =
          Bytes.toString(rr.getValue(CATALOG_FAMILY, SERVER_QUALIFIER));
      }
      // Take region out of the intransistions in case it got stuck there doing
      // an open or whatever.
      this.regionManager.clearFromInTransition(regionname);
      // If servername is still null, then none, exit.
      if (servername == null) break;
      // Need to make up a HServerInfo 'servername' for that is how
      // items are keyed in regionmanager Maps.
      HServerAddress addr = new HServerAddress(servername);
      long startCode =
        Bytes.toLong(rr.getValue(CATALOG_FAMILY, STARTCODE_QUALIFIER));
      String name = HServerInfo.getServerName(addr, startCode);
      LOG.info("Marking " + hri.getRegionNameAsString() +
        " as closing on " + name + "; cleaning SERVER + STARTCODE; " +
          "master will tell regionserver to close region on next heartbeat");
      this.regionManager.setClosing(name, hri, hri.isOffline());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.Result

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.