Package org.apache.accumulo.core.data

Examples of org.apache.accumulo.core.data.Key


    private ColumnSliceFilter columnSliceFilter = new ColumnSliceFilter();
    private IteratorSetting is;

    private static Key nkv(SortedMap<Key,Value> tm, String row, String cf, String cq, String val) {
        Key k = nk(row, cf, cq);
        tm.put(k, new Value(val.getBytes()));
        return k;
    }
View Full Code Here


        tm.put(k, new Value(val.getBytes()));
        return k;
    }

    private static Key nk(String row, String cf, String cq) {
        return new Key(new Text(row), new Text(cf), new Text(cq));
    }
View Full Code Here

      bw.addMutation(m);
    }
    bw.close();
    BatchScanner s = c.createBatchScanner("test", Constants.NO_AUTHS, 2);
    s.setRanges(Collections.singletonList(new Range()));
    Key key = null;
    int count = 0;
    for (Entry<Key,Value> entry : s) {
      if (key != null)
        assertTrue(key.compareTo(entry.getKey()) < 0);
      assertEquals(entry.getKey().getRow(), new Text(entry.getValue().get()));
      key = entry.getKey();
      count++;
    }
    assertEquals(100, count);
View Full Code Here

    Map<String,Long> totalBlocks = new HashMap<String,Long>();
    Map<String,Long> localBlocks = new HashMap<String,Long>();
    ArrayList<String> files = new ArrayList<String>();
   
    for (Entry<Key,Value> entry : scanner) {
      Key key = entry.getKey();
      if (key.compareColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY) == 0) {
        String location = entry.getValue().toString();
        String[] parts = location.split(":");
        String host = parts[0];
        addBlocks(fs, host, files, totalBlocks, localBlocks);
        files.clear();
      } else if (key.compareColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY) == 0) {
        files.add(new String(KeyExtent.tableOfMetadataRow(key.getRow()), Constants.UTF8) + slash(key.getColumnQualifier().toString()));
      }
    }
    System.out.println(" Server         %local  total blocks");
    for (Entry<String,Long> entry : totalBlocks.entrySet()) {
      final String host = entry.getKey();
View Full Code Here

   
    int count = 10;
   
    Scanner scanner = c.createScanner("test", Constants.NO_AUTHS);
    for (Entry<Key,Value> entry : scanner) {
      Key key = entry.getKey();
      Mutation m = new Mutation(key.getRow());
      m.put(key.getColumnFamily().toString(), key.getColumnQualifier().toString(), key.getTimestamp() + 1, "v" + (count));
      count++;
      bw.addMutation(m);
    }
   
    bw.flush();
View Full Code Here

 
  private static final byte ROW_PREFIX[] = new byte[] {'r'};
  private static final byte COL_PREFIX[] = new byte[] {'c'};
 
  static Key nk(int r, int c) {
    return new Key(new Text(FastFormat.toZeroPaddedString(r, 9, 10, ROW_PREFIX)), new Text(FastFormat.toZeroPaddedString(c, 6, 10, COL_PREFIX)));
  }
View Full Code Here

    } else {
      for (int i = 0; i < numRows; i++) {
        int row = rand.nextInt(1000000000);
        for (int j = 0; j < numCols; j++) {
          int col = rand.nextInt(1000000);
          Key key = nk(row, col);
          Value val = new Value("test".getBytes(Constants.UTF8));
          tm.put(key, val);
        }
      }
    }
   
    long tpe = System.currentTimeMillis();
   
    // Iteration
    Iterator<Entry<Key,Value>> iter;
    if (nm != null) {
      iter = nm.iterator();
    } else {
      iter = tm.entrySet().iterator();
    }
   
    long tis = System.currentTimeMillis();
   
    while (iter.hasNext()) {
      iter.next();
    }
   
    long tie = System.currentTimeMillis();
   
    rand = new Random(19);
    int rowsToLookup[] = new int[numLookups];
    int colsToLookup[] = new int[numLookups];
    for (int i = 0; i < Math.min(numLookups, numRows); i++) {
      int row = rand.nextInt(1000000000);
      int col = -1;
      for (int j = 0; j < numCols; j++) {
        col = rand.nextInt(1000000);
      }
     
      rowsToLookup[i] = row;
      colsToLookup[i] = col;
    }
   
    // get
   
    long tgs = System.currentTimeMillis();
    if (nm != null) {
      for (int i = 0; i < numLookups; i++) {
        Key key = nk(rowsToLookup[i], colsToLookup[i]);
        if (nm.get(key) == null) {
          throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
        }
      }
    } else {
      for (int i = 0; i < numLookups; i++) {
        Key key = nk(rowsToLookup[i], colsToLookup[i]);
        if (tm.get(key) == null) {
          throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
        }
      }
    }
View Full Code Here

    if (interruptFlag != null && interruptFlag.get())
      throw new IterationInterruptedException();
   
    this.range = range;
   
    Key key = range.getStartKey();
    if (key == null) {
      key = new Key();
    }
   
    iter = map.tailMap(key).entrySet().iterator();
    if (iter.hasNext()) {
      entry = iter.next();
View Full Code Here

      while (source.hasTop() && source.getTopKey().getRowData().equals(currentRow) && source.getTopKey().getColumnFamilyData().equals(currentColf)) {
        count++;
        source.next();
      }
     
      this.key = new Key(currentRow.toArray(), currentColf.toArray(), new byte[0], new byte[0], ts);
      this.value = new Value(Integer.toString(count).getBytes(Constants.UTF8));
     
    } else {
      this.key = null;
      this.value = null;
View Full Code Here

     * @param source
     *          The SortedKeyValueIterator<Key,Value> from which to read data.
     */
    public ValueIterator(SortedKeyValueIterator<Key,Value> source) {
      this.source = source;
      topKey = new Key(source.getTopKey());
      hasNext = _hasNext();
    }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.data.Key

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.