List of usage examples for org.apache.hadoop.io Text append
public void append(byte[] utf8, int start, int len)
From source file:org.apache.accumulo.core.client.impl.TabletLocatorImpl.java
License:Apache License
private static Text rowAfterPrevRow(KeyExtent nke) { Text row = new Text(nke.getPrevEndRow()); row.append(new byte[] { 0 }, 0, 1); return row;/*from w w w .j a v a 2 s . c om*/ }
From source file:org.apache.accumulo.core.client.impl.TabletLocatorImpl.java
License:Apache License
protected TabletLocation _locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry, boolean lock, LockCheckerSession lcSession) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (skipRow) { row = new Text(row); row.append(new byte[] { 0 }, 0, 1); }// w w w . j av a2 s . c o m TabletLocation tl; if (lock) { rLock.lock(); try { tl = processInvalidatedAndCheckLock(context, lcSession, row); } finally { rLock.unlock(); } } else { tl = processInvalidatedAndCheckLock(context, lcSession, row); } if (tl == null) { // not in cache, so obtain info if (lock) { wLock.lock(); try { tl = lookupTabletLocationAndCheckLock(context, row, retry, lcSession); } finally { wLock.unlock(); } } else { tl = lookupTabletLocationAndCheckLock(context, row, retry, lcSession); } } return tl; }
From source file:org.apache.accumulo.core.client.mock.MockTableOperations.java
License:Apache License
@Override public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); MockTable t = acu.tables.get(tableName); Text startText = start != null ? new Text(start) : new Text(); if (startText.getLength() == 0 && end == null) { t.table.clear();/*w w w .j ava2 s . co m*/ return; } Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes()); startText.append(ZERO, 0, 1); endText.append(ZERO, 0, 1); Set<Key> keep = new TreeSet<>(t.table.subMap(new Key(startText), new Key(endText)).keySet()); t.table.keySet().removeAll(keep); }
From source file:org.apache.accumulo.core.client.mock.MockTableOperationsImpl.java
License:Apache License
@Override public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (!exists(tableName)) throw new TableNotFoundException(tableName, tableName, ""); MockTable t = acu.tables.get(tableName); Text startText = start != null ? new Text(start) : new Text(); Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes()); startText.append(ZERO, 0, 1); endText.append(ZERO, 0, 1);//w w w .ja v a 2s.c o m Set<Key> keep = new TreeSet<Key>(t.table.subMap(new Key(startText), new Key(endText)).keySet()); t.table.keySet().removeAll(keep); }
From source file:org.apache.accumulo.core.clientImpl.bulk.BulkImport.java
License:Apache License
private static Text nextRow(Text row) { Text next = new Text(row); next.append(byte0, 0, byte0.length); return next;/*from w ww . j a v a2 s . c o m*/ }
From source file:org.apache.accumulo.core.clientImpl.TabletLocatorImpl.java
License:Apache License
private void lookupTabletLocation(ClientContext context, Text row, boolean retry, LockCheckerSession lcSession) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { Text metadataRow = new Text(tableId.canonical()); metadataRow.append(new byte[] { ';' }, 0, 1); metadataRow.append(row.getBytes(), 0, row.getLength()); TabletLocation ptl = parent.locateTablet(context, metadataRow, false, retry); if (ptl != null) { TabletLocations locations = locationObtainer.lookupTablet(context, ptl, metadataRow, lastTabletRow, parent);/*w ww . ja v a 2s . c o m*/ while (locations != null && locations.getLocations().isEmpty() && locations.getLocationless().isEmpty()) { // try the next tablet, the current tablet does not have any tablets that overlap the row Text er = ptl.tablet_extent.getEndRow(); if (er != null && er.compareTo(lastTabletRow) < 0) { // System.out.println("er "+er+" ltr "+lastTabletRow); ptl = parent.locateTablet(context, er, true, retry); if (ptl != null) locations = locationObtainer.lookupTablet(context, ptl, metadataRow, lastTabletRow, parent); else break; } else { break; } } if (locations == null) return; // cannot assume the list contains contiguous key extents... so it is probably // best to deal with each extent individually Text lastEndRow = null; for (TabletLocation tabletLocation : locations.getLocations()) { KeyExtent ke = tabletLocation.tablet_extent; TabletLocation locToCache; // create new location if current prevEndRow == endRow if ((lastEndRow != null) && (ke.getPrevEndRow() != null) && ke.getPrevEndRow().equals(lastEndRow)) { locToCache = new TabletLocation(new KeyExtent(ke.getTableId(), ke.getEndRow(), lastEndRow), tabletLocation.tablet_location, tabletLocation.tablet_session); } else { locToCache = tabletLocation; } // save endRow for next iteration lastEndRow = locToCache.tablet_extent.getEndRow(); updateCache(locToCache, lcSession); } } }
From source file:org.apache.accumulo.core.data.impl.KeyExtent.java
License:Apache License
public Range toMetadataRange() { Text metadataPrevRow = new Text(getTableId()); metadataPrevRow.append(new byte[] { ';' }, 0, 1); if (getPrevEndRow() != null) { metadataPrevRow.append(getPrevEndRow().getBytes(), 0, getPrevEndRow().getLength()); }/*w ww . ja va 2 s . c o m*/ Range range = new Range(metadataPrevRow, getPrevEndRow() == null, getMetadataEntry(), true); return range; }
From source file:org.apache.accumulo.core.iterators.aggregation.conf.AggregatorConfigurationTest.java
License:Apache License
@Test public void testBinary() { Text colf = new Text(); Text colq = new Text(); for (int i = 0; i < 256; i++) { colf.append(new byte[] { (byte) i }, 0, 1); colq.append(new byte[] { (byte) (255 - i) }, 0, 1); }/*www . j a v a2 s . c o m*/ runTest(colf, colq); runTest(colf); }
From source file:org.apache.accumulo.core.iterators.conf.ColumnSet.java
License:Apache License
static Text decode(String s) { Text t = new Text(); byte[] sb = s.getBytes(UTF_8); // very inefficient code for (int i = 0; i < sb.length; i++) { if (sb[i] != '%') { t.append(new byte[] { sb[i] }, 0, 1); } else {// www. j a va 2 s . c o m byte hex[] = new byte[] { sb[++i], sb[++i] }; String hs = new String(hex, UTF_8); int b = Integer.parseInt(hs, 16); t.append(new byte[] { (byte) b }, 0, 1); } } return t; }
From source file:org.apache.accumulo.core.iterators.user.IndexedDocIterator.java
License:Apache License
@Override protected Key buildKey(Text partition, Text term, Text docID) { Text colq = new Text(term); colq.append(nullByte, 0, 1); colq.append(docID.getBytes(), 0, docID.getLength()); colq.append(nullByte, 0, 1);/*from www.ja v a 2 s.com*/ return new Key(partition, indexColf, colq); }