SortMergedPartitionResultIterator(Iterator<PartitionResultIterator> iterators, GTInfo info, final Comparator<GTRecord> comparator) { this.iterators = iterators; this.record = new GTRecord(info); this.comparator = comparator; }
public InputConverter(GTInfo info, RecordConsumeBlockingQueueController<T> inputController) { this.info = info; this.inputController = inputController; this.record = new GTRecord(info); }
public GTScanRange replaceGTInfo(final GTInfo gtInfo) { List<GTRecord> newFuzzyKeys = Lists.newArrayList(); for (GTRecord input : fuzzyKeys) { newFuzzyKeys.add(new GTRecord(gtInfo, input.cols)); } return new GTScanRange(new GTRecord(gtInfo, pkStart.cols), // new GTRecord(gtInfo, pkEnd.cols), // newFuzzyKeys); }
public PartitionResultIterator(byte[] data, GTInfo info, ImmutableBitSet cols) { this.buffer = ByteBuffer.wrap(data); this.cols = cols; this.record = new GTRecord(info); }
private static GTRecord newRec(GTInfo info, Object... values) { GTRecord rec = new GTRecord(info); return rec.setValues(values); }
StreamMergeGTRecordIterator(Iterator<GTRecord> input) { super(input); this.returnRecord = new GTRecord(req.getInfo()); }
@Override public GTRecord next() { GTRecord x = input.next(); return new GTRecord(info, x.getInternal()); }
public Generator(long nRows) { this.nRows = nRows; this.rand = new Random(); rec = new GTRecord(info); dist = new Distribution[colSpecs.size()]; for (int i = 0; i < colSpecs.size(); i++) { ColSpec spec = colSpecs.get(i); rec.set(i, new ByteArray(spec.length)); dist[i] = new Distribution(spec, 0); } }
private List<GTRecord> buildFuzzyKeys(Map<Integer, Set<ByteArray>> fuzzyValueSet) { ArrayList<GTRecord> result = Lists.newArrayList(); if (fuzzyValueSet.isEmpty()) return result; // debug/profiling purpose if (BackdoorToggles.getDisableFuzzyKey()) { logger.info("The execution of this query will not use fuzzy key"); return result; } List<Map<Integer, ByteArray>> fuzzyValueCombinations = FuzzyValueCombination.calculate(fuzzyValueSet, maxFuzzyKeys); for (Map<Integer, ByteArray> fuzzyValue : fuzzyValueCombinations) { GTRecord fuzzy = new GTRecord(gtInfo); for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) { fuzzy.set(entry.getKey(), entry.getValue()); } result.add(fuzzy); } return result; }
count = 0; return new Iterator<GTRecord>() { GTRecord record = new GTRecord(info); GTRecord next; ByteBuffer buf = ByteBuffer.allocate(info.getMaxRecordLength());
private GTRecord deserializeGTRecord(ByteBuffer in, GTInfo sInfo) { int colLength = BytesUtil.readVInt(in); ByteArray[] sCols = new ByteArray[colLength]; for (int i = 0; i < colLength; i++) { sCols[i] = ByteArray.importData(in); } return new GTRecord(sInfo, sCols); }
count = 0; return new Iterator<GTRecord>() { GTRecord record = new GTRecord(info); GTRecord next; ByteBuffer buf = ByteBuffer.allocate(info.getMaxRecordLength());
protected GTScanRange newScanRange(Collection<ColumnRange> andDimRanges) { GTRecord pkStart = new GTRecord(gtInfo); GTRecord pkEnd = new GTRecord(gtInfo); Map<Integer, Set<ByteArray>> fuzzyValues = Maps.newHashMap(); for (ColumnRange range : andDimRanges) { int col = range.column.getColumnDesc().getZeroBasedIndex(); if (!gtInfo.getPrimaryKey().get(col)) continue; pkStart.set(col, range.begin); pkEnd.set(col, range.end); if (range.valueSet != null && !range.valueSet.isEmpty()) { fuzzyValues.put(col, range.valueSet); } } List<GTRecord> fuzzyKeys = buildFuzzyKeys(fuzzyValues); return new GTScanRange(pkStart, pkEnd, fuzzyKeys); }
private static GridTable newTable(GTInfo info) throws IOException { GTSimpleMemStore store = new GTSimpleMemStore(info); GridTable table = new GridTable(info, store); GTRecord record = new GTRecord(info); Random rand = new Random(); GTBuilder builder = table.rebuild(); expUserRet.clear(); Map<String, List<BigDecimal>> contents = Maps.newHashMap(); for (String date : dateList) { for (String user : userList) { List<BigDecimal> innerList = contents.get(user); if (innerList == null) { innerList = Lists.newArrayList(); contents.put(user, innerList); } BigDecimal value = priceList.get(rand.nextInt(priceList.size())); innerList.add(value); builder.write(record.setValues(date, user, value, new BigDecimal(0))); } } for (String user : contents.keySet()) { BigDecimal sum = new BigDecimal(0); for (BigDecimal innerValue : contents.get(user)) { sum = sum.add(innerValue); } expUserRet.put(user, sum); } builder.close(); return table; }
private CuboidResult scanAndAggregateGridTable(GridTable gridTable, long parentId, long cuboidId, ImmutableBitSet aggregationColumns, ImmutableBitSet measureColumns) throws IOException { long startTime = System.currentTimeMillis(); logger.info("Calculating cuboid {}", cuboidId); GTAggregateScanner scanner = prepareGTAggregationScanner(gridTable, parentId, cuboidId, aggregationColumns, measureColumns); GridTable newGridTable = newGridTableByCuboidID(cuboidId); GTBuilder builder = newGridTable.rebuild(); ImmutableBitSet allNeededColumns = aggregationColumns.or(measureColumns); GTRecord newRecord = new GTRecord(newGridTable.getInfo()); int count = 0; try { for (GTRecord record : scanner) { count++; for (int i = 0; i < allNeededColumns.trueBitCount(); i++) { int c = allNeededColumns.trueBitAt(i); newRecord.set(i, record.get(c)); } builder.write(newRecord); } } finally { scanner.close(); builder.close(); } long timeSpent = System.currentTimeMillis() - startTime; logger.info("Cuboid {} has {} rows, build takes {}ms", cuboidId, count, timeSpent); return updateCuboidResult(cuboidId, newGridTable, count, timeSpent, 0); }
GTRecord newRecord = new GTRecord(newGridTable.getInfo()); int count = 0; try {
AbstractStreamMergeIterator(Iterator<GTRecord> input) { this.input = Iterators.peekingIterator(input); this.codeSystem = req.getInfo().getCodeSystem(); this.dimensions = req.getDimensions(); this.metrics = req.getAggrMetrics(); this.metricFuncs = req.getAggrMetricsFuncs(); this.measureCodec = req.createMeasureCodec(); this.first = new GTRecord(req.getInfo()); }
public static GridTable newTestTable() throws IOException { GTInfo info = newInfo(); GTSimpleMemStore store = new GTSimpleMemStore(info); GridTable table = new GridTable(info, store); GTRecord r = new GTRecord(table.getInfo()); GTBuilder builder = table.rebuild(); builder.write(r.setValues("2015-01-14", "30", "Yang", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-14", "30", "Luke", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-15", "20", "Dong", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-15", "20", "Jason", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-15", "30", "Xu", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-16", "20", "Mahone", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-16", "20", "Qianhao", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-16", "30", "George", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-16", "30", "Shaofeng", new Long(10), new BigDecimal("10.5"))); builder.write(r.setValues("2015-01-17", "10", "Kejia", new Long(10), new BigDecimal("10.5"))); builder.close(); return table; }
GridTable table = new GridTable(info, store); GTRecord r = new GTRecord(table.getInfo()); GTBuilder builder = table.rebuild();