@Override public int eval(int index, int numPartitions) { String key = partitionKeyVector.getAccessor().getObject(index).toString(); byte[] encodedKey = IdCodec.encodeAsBytes(key);
/** * Returns ids of rowKeys to be read. * Number of rowKey ids returned will be numRowKeysToRead at the most i.e. it * will be less than numRowKeysToRead if only that many exist in the currentBatch. */ @JsonIgnore public ByteBuffer[] getRowKeyIdsToRead(int numRowKeysToRead) { int numKeys = hasRowKeys(numRowKeysToRead); if (numKeys == 0) { return null; } int index = 0; final ByteBuffer[] rowKeyIds = new ByteBuffer[numKeys]; while (index < numKeys) { Object o = rowKeyVector.getAccessor().getObject(currentIndex + index); rowKeyIds[index++] = IdCodec.encode(o.toString()); } updateRowKeysRead(numKeys); return rowKeyIds; }
@Override public Object getObject(int index) { final List<Object> list = new JsonStringArrayList<>(); final int start = offsets.getAccessor().get(index); final int until = offsets.getAccessor().get(index+1); for (int i = start; i < until; i++) { list.add(vector.getAccessor().getObject(i)); } return list; }
Object o; try{ o = vw.getValueVector().getAccessor().getObject(row); } catch (Exception e) { throw new RuntimeException("failure while trying to read column " + vw.getField().getName());
List<String> rowValues = Lists.newArrayList(); for (VectorWrapper<?> vw : va) { Object o = vw.getValueVector().getAccessor().getObject(row); if (o == null) { rowValues.add("null");
Object o = vv.getAccessor().getObject(row); String value; if (o == null) {
Object o = vv.getAccessor().getObject(row); String value; if (o == null) {
Object o = vw.getValueVectors()[sv4.get(j) >>> 16].getAccessor().getObject(sv4.get(j) & 65535); String value; if (o == null) {
/** Compose the array of partition values for the directories that are referenced by filter: * e.g suppose the dir hierarchy is year/quarter/month and the query is: * SELECT * FROM T WHERE dir0=2015 AND dir1 = 'Q1', * then for 2015/Q1/Feb, this will have ['2015', 'Q1', null] * If the query filter condition is WHERE dir1 = 'Q2' (i.e no dir0 condition) then the array will * have [null, 'Q2', null] */ private Pair<String[], Integer> composePartition(BitSet referencedDirsBitSet, Map<Integer, Integer> partitionMap, ValueVector[] vectors, int recordCount) { String[] partition = new String[vectors.length]; int maxIndex = -1; for (int referencedDirsIndex : BitSets.toIter(referencedDirsBitSet)) { int partitionColumnIndex = partitionMap.get(referencedDirsIndex); ValueVector vv = vectors[partitionColumnIndex]; if (vv.getAccessor().getValueCount() > 0 && vv.getAccessor().getObject(recordCount) != null) { String value = vv.getAccessor().getObject(recordCount).toString(); partition[partitionColumnIndex] = value; maxIndex = Math.max(maxIndex, partitionColumnIndex); } } return Pair.of(partition, maxIndex); }
@Override public Object getObject(int index) { final List<Object> list = new JsonStringArrayList<>(); final int end = offsets.getAccessor().get(index+1); String fieldName; for (int i = offsets.getAccessor().get(index); i < end; i++) { final Map<String, Object> vv = Maps.newLinkedHashMap(); for (final MaterializedField field : getField().getChildren()) { if (!field.equals(BaseRepeatedValueVector.OFFSETS_FIELD)) { fieldName = field.getName(); final Object value = getChild(fieldName).getAccessor().getObject(i); if (value != null) { vv.put(fieldName, value); } } } list.add(vv); } return list; }
@Override public Object getObject(int index) { Map<String, Object> vv = new JsonStringHashMap<>(); for (String child:getChildFieldNames()) { ValueVector v = getChild(child); // TODO(DRILL-4001): Resolve this hack: // The index/value count check in the following if statement is a hack // to work around the current fact that RecordBatchLoader.load and // MapVector.load leave child vectors with a length of zero (as opposed // to matching the lengths of siblings and the parent map vector) // because they don't remove (or set the lengths of) vectors from // previous batches that aren't in the current batch. if (v != null && index < v.getAccessor().getValueCount()) { Object value = v.getAccessor().getObject(index); if (value != null) { vv.put(child, value); } } } return vv; }
/** * Returns ids of rowKeys to be read. * Number of rowKey ids returned will be numRowKeysToRead at the most i.e. it * will be less than numRowKeysToRead if only that many exist in the currentBatch. */ @JsonIgnore public ByteBuffer[] getRowKeyIdsToRead(int numRowKeysToRead) { int numKeys = hasRowKeys(numRowKeysToRead); if (numKeys == 0) { return null; } int index = 0; final ByteBuffer[] rowKeyIds = new ByteBuffer[numKeys]; while (index < numKeys) { Object o = rowKeyVector.getAccessor().getObject(currentIndex + index); rowKeyIds[index++] = IdCodec.encode(o.toString()); } updateRowKeysRead(numKeys); return rowKeyIds; }
/** * This method create a pretty string for a record in the {@link VectorContainer}. * @param index The index of the record of interest. * @return The string representation of a record. */ public String prettyPrintRecord(int index) { final StringBuilder sb = new StringBuilder(); String separator = ""; sb.append("["); for (VectorWrapper vectorWrapper: wrappers) { sb.append(separator); separator = ", "; final String columnName = vectorWrapper.getField().getName(); final Object value = vectorWrapper.getValueVector().getAccessor().getObject(index); // "columnName" = 11 sb.append("\"").append(columnName).append("\" = ").append(value); } sb.append("]"); return sb.toString(); } }
@Override public Object getObject(int index) { if (isNull(index)) { return null; } final List<Object> vals = new JsonStringArrayList<>(); final UInt4Vector.Accessor offsetsAccessor = offsets.getAccessor(); final int start = offsetsAccessor.get(index); final int end = offsetsAccessor.get(index + 1); final ValueVector.Accessor valuesAccessor = getDataVector().getAccessor(); for(int i = start; i < end; i++) { vals.add(valuesAccessor.getObject(i)); } return vals; }
@Override public Object getObject(int index) { final List<Object> list = new JsonStringArrayList<>(); final int start = offsets.getAccessor().get(index); final int until = offsets.getAccessor().get(index+1); for (int i = start; i < until; i++) { list.add(vector.getAccessor().getObject(i)); } return list; }
@Override public Object getObject(int index) throws InvalidAccessException { return v.getAccessor().getObject(index); }
@Override public Object getObject(int index) { Map<String, Object> vv = new JsonStringHashMap<>(); for (String child:getChildFieldNames()) { ValueVector v = getChild(child); // TODO(DRILL-4001): Resolve this hack: // The index/value count check in the following if statement is a hack // to work around the current fact that RecordBatchLoader.load and // MapVector.load leave child vectors with a length of zero (as opposed // to matching the lengths of siblings and the parent map vector) // because they don't remove (or set the lengths of) vectors from // previous batches that aren't in the current batch. if (v != null && index < v.getAccessor().getValueCount()) { Object value = v.getAccessor().getObject(index); if (value != null) { vv.put(child, value); } } } return vv; }
protected Object[] getRunResult(QueryType queryType, String planString) throws Exception { List<QueryDataBatch> resultList = testRunAndReturn(queryType, planString); List<Object> res = new ArrayList<Object>(); RecordBatchLoader loader = new RecordBatchLoader(getAllocator()); for(QueryDataBatch result : resultList) { if (result.getData() != null) { loader.load(result.getHeader().getDef(), result.getData()); ValueVector v = loader.iterator().next().getValueVector(); for (int j = 0; j < v.getAccessor().getValueCount(); j++) { if (v instanceof VarCharVector) { res.add(new String(((VarCharVector) v).getAccessor().get(j))); } else { res.add(v.getAccessor().getObject(j)); } } loader.clear(); result.release(); } } return res.toArray(); }
@Override public Object getObject(int index) { final List<Object> list = new JsonStringArrayList<>(); final int end = offsets.getAccessor().get(index+1); String fieldName; for (int i = offsets.getAccessor().get(index); i < end; i++) { final Map<String, Object> vv = Maps.newLinkedHashMap(); for (final MaterializedField field : getField().getChildren()) { if (!field.equals(BaseRepeatedValueVector.OFFSETS_FIELD)) { fieldName = field.getName(); final Object value = getChild(fieldName).getAccessor().getObject(i); if (value != null) { vv.put(fieldName, value); } } } list.add(vv); } return list; }
@Override public Object getObject(int index) { if (isNull(index)) { return null; } final List<Object> vals = new JsonStringArrayList<>(); final UInt4Vector.Accessor offsetsAccessor = offsets.getAccessor(); final int start = offsetsAccessor.get(index); final int end = offsetsAccessor.get(index + 1); final ValueVector.Accessor valuesAccessor = getDataVector().getAccessor(); for(int i = start; i < end; i++) { vals.add(valuesAccessor.getObject(i)); } return vals; }