@Override public void deserialize(Entry<Key, Value> entry) { if (!columnValues.containsKey(rowIdName)) { entry.getKey().getRow(rowId); columnValues.put(rowIdName, rowId.copyBytes()); } if (rowOnly) { return; } entry.getKey().getColumnFamily(family); entry.getKey().getColumnQualifier(qualifier); if (family.equals(ROW_ID_COLUMN) && qualifier.equals(ROW_ID_COLUMN)) { return; } value.set(entry.getValue().get()); columnValues.put(familyQualifierColumnMap.get(family.toString()).get(qualifier.toString()), value.copyBytes()); }
private static void assertKeyValuePair(Entry<Key, Value> e, byte[] row, String cf, String cq, String value) { assertEquals(row, e.getKey().getRow().copyBytes()); assertEquals(cf, e.getKey().getColumnFamily().toString()); assertEquals(cq, e.getKey().getColumnQualifier().toString()); assertEquals(value, e.getValue().toString()); }
private static void assertKeyValuePair(Entry<Key, Value> e, byte[] row, String cf, String cq, String cv, String value) { assertEquals(row, e.getKey().getRow().copyBytes()); assertEquals(cf, e.getKey().getColumnFamily().toString()); assertEquals(cq, e.getKey().getColumnQualifier().toString()); assertEquals(cv, e.getKey().getColumnVisibility().toString()); assertEquals(value, e.getValue().toString()); }
byte[] keyBytes = entry.getKey().getRow().copyBytes();
return text.copyBytes();
private static byte[] copy(Text data) { return data == null ? null : data.copyBytes(); }
@SuppressWarnings("deprecation") public byte[][] getSplits(Configuration conf, Path path) { List<byte[]> rowkeyList = new ArrayList<byte[]>(); SequenceFile.Reader reader = null; try { reader = new SequenceFile.Reader(path.getFileSystem(conf), path, conf); Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf); Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf); while (reader.next(key, value)) { byte[] tmp = ((Text) key).copyBytes(); if (rowkeyList.contains(tmp) == false) { rowkeyList.add(tmp); } } } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeStream(reader); } byte[][] retValue = rowkeyList.toArray(new byte[rowkeyList.size()][]); return retValue; } }
@SuppressWarnings("deprecation") public byte[][] getSplits(Configuration conf, Path path) throws Exception { FileSystem fs = path.getFileSystem(conf); if (fs.exists(path) == false) { System.err.println("Path " + path + " not found, no region split, HTable will be one region"); return null; } List<byte[]> rowkeyList = new ArrayList<byte[]>(); SequenceFile.Reader reader = null; try { reader = new SequenceFile.Reader(fs, path, conf); Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf); Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf); while (reader.next(key, value)) { rowkeyList.add(((Text) key).copyBytes()); } } catch (Exception e) { e.printStackTrace(); throw e; } finally { IOUtils.closeStream(reader); } logger.info((rowkeyList.size() + 1) + " regions"); logger.info(rowkeyList.size() + " splits"); for (byte[] split : rowkeyList) { System.out.println(StringUtils.byteToHexString(split)); } byte[][] retValue = rowkeyList.toArray(new byte[rowkeyList.size()][]); return retValue.length == 0 ? null : retValue; }
public byte[] getStoreKey() { assert !queryMode : "must be in store Mode, store keys are not initialized."; return storeKey.copyBytes(); }
public byte[] getStoreKey() { assert !queryMode : "must be in store Mode, store keys are not initialized."; return storeKey.copyBytes(); }
private static ByteString getFixedByteString(Text key) { ByteString value = fixedByteStringCache.get(key); if (value == null) { value = ByteString.copyFromUtf8(key.toString()); fixedByteStringCache.put(new Text(key.copyBytes()), value); } return value; }
public static String toHumanString(final Text text) { return toHumanString(text==null?null:text.copyBytes()); } public static String toHumanString(final byte[] bytes) {
public static String toHumanString(final Text text) { return toHumanString(text==null?null:text.copyBytes()); } public static String toHumanString(final byte[] bytes) {
@Override protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { for (Text value : values) { byte[] bytes = value.copyBytes(); context.write(bytes, bytes); } } }
@Nullable public Boolean evaluate(@Nullable Text bloomStr, @Nullable Text keyStr) throws HiveException { if (bloomStr == null) { return null; } if (keyStr == null) { return Boolean.FALSE; } Filter bloom = getFilter(bloomStr); key.set(keyStr.copyBytes(), 1.0d); return Boolean.valueOf(bloom.membershipTest(key)); }
/** * Query key is the prefix plus the datetime, but no uniqueness at the end. * * @return the row key for range queries. */ public Text getQueryKey(final TemporalInstant theInstant) { assert queryMode : "must be in query Mode, query keys are not initialized."; final Text keyText = new Text(); if (constraintPrefix != null) { appendBytes(constraintPrefix.copyBytes(), keyText); } appendInstant(theInstant, keyText); return keyText; };
public boolean iterate(@Nullable Text keyStr) { if (keyStr == null) { return true; } if (filter == null) { init(); } key.set(keyStr.copyBytes(), 1.0d); filter.add(key); return true; }
public void testTextText() throws CharacterCodingException { Text a=new Text("abc"); Text b=new Text("a"); b.set(a); assertEquals("abc", b.toString()); a.append("xdefgxxx".getBytes(), 1, 4); assertEquals("modified aliased string", "abc", b.toString()); assertEquals("appended string incorrectly", "abcdefg", a.toString()); // add an extra byte so that capacity = 14 and length = 8 a.append(new byte[]{'d'}, 0, 1); assertEquals(14, a.getBytes().length); assertEquals(8, a.copyBytes().length); }
public void testTextText() throws CharacterCodingException { Text a=new Text("abc"); Text b=new Text("a"); b.set(a); assertEquals("abc", b.toString()); a.append("xdefgxxx".getBytes(), 1, 4); assertEquals("modified aliased string", "abc", b.toString()); assertEquals("appended string incorrectly", "abcdefg", a.toString()); // add an extra byte so that capacity = 14 and length = 8 a.append(new byte[]{'d'}, 0, 1); assertEquals(14, a.getBytes().length); assertEquals(8, a.copyBytes().length); }