com.addthis.bundle.core.Bundle.createBundle()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中com.addthis.bundle.core.Bundle.createBundle()方法的一些代码示例,展示了Bundle.createBundle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.createBundle()方法的具体详情如下:
包路径:com.addthis.bundle.core.Bundle
类名称:Bundle
方法名:createBundle

Bundle.createBundle介绍

暂无

代码示例

代码示例来源:origin: addthis/hydra

@Override
public Bundle createBundle() {
  return mergedBundle.createBundle();
}

代码示例来源:origin: addthis/hydra

@Override
  public Bundle createBundle() {
    return new FilteredBundle(wrap.createBundle(), null, null);
  }
}

代码示例来源:origin: addthis/hydra

private static Bundle cloneBundle(Bundle input) {
  Bundle output = input.createBundle();
  Iterator<BundleField> fieldIterator = input.getFormat().iterator();
  while (fieldIterator.hasNext()) {
    BundleField field = fieldIterator.next();
    output.setValue(field, input.getValue(field));
  }
  return output;
}

代码示例来源:origin: addthis/hydra

@Override
public void send(Bundle row) throws DataChannelError {
  if (sentTitle.compareAndSet(false, true)) {
    Bundle title = row.createBundle();
    if (header.size() > 0) {
      for (Iterator<ValueObject> iter = header.iterator(); iter.hasNext(); ) {
        getSourceColumnBinder(row).appendColumn(title, iter.next());
      }
    } else {
      for (BundleField field : row) {
        title.setValue(field, ValueFactory.create(field.getName()));
      }
    }
    getNext().send(title);
  }
  getNext().send(row);
}

代码示例来源:origin: addthis/hydra

@Override
  public void sendComplete() {
    Map<Long, Long> map = histo.getSortedHistogram();
    for (Entry<Long, Long> e : map.entrySet()) {
      if (opPromise.isDone()) {
        break;
      } else {
        Bundle row = rowFactory.createBundle();
        binder.appendColumn(row, ValueFactory.create(e.getKey()));
        binder.appendColumn(row, ValueFactory.create(e.getValue()));
        getNext().send(row);
      }
    }
    super.sendComplete();
  }
}

代码示例来源:origin: addthis/hydra

@Override
public Bundle rowOp(Bundle row) {
  if (binder == null) {
    binder = getSourceColumnBinder(row);
    rowFactory = row.createBundle();
  }
  histo.update(0, ValueUtil.asNumberOrParse(binder.getColumn(row, column)).asLong().getLong());
  return null;
}

代码示例来源:origin: addthis/hydra

@Override
  public void sendComplete() {
    for(int i = 0; i < keys.length; i++) {
      if (opPromise.isDone()) {
        break;
      } else {
        Bundle row = rowFactory.createBundle();
        if (mode == Mode.FLOAT) {
          binder.appendColumn(row, ValueFactory.create(keys[i].floatValue()));
        } else {
          binder.appendColumn(row, ValueFactory.create(keys[i].intValue()));
        }
        binder.appendColumn(row, ValueFactory.create(counts[i]));
        getNext().send(row);
      }
    }
    super.sendComplete();
  }
}

代码示例来源:origin: addthis/hydra

@Override
public Bundle rowOp(Bundle row) {
  if (binder == null) {
    binder = getSourceColumnBinder(row);
    rowFactory = row.createBundle();
  }
  Numeric value = ValueUtil.asNumberOrParse(binder.getColumn(row, column));
  long increment;
  if (frequency >= 0) {
    Numeric incNumeric = ValueUtil.asNumberOrParseLong(binder.getColumn(row, frequency), 10);
    increment = (incNumeric != null) ? incNumeric.asLong().asNative() : 1;
  } else {
    increment = 1;
  }
  if (mode == Mode.FLOAT) {
    float target = (float) value.asDouble().getDouble();
    int position = Arrays.binarySearch(keys, target);
    if (position < 0) position = ~position - 1;
    counts[position] += increment;
  } else {
    int target = (int) value.asLong().getLong();
    int position = Arrays.binarySearch(keys, target);
    if (position < 0) position = ~position - 1;
    counts[position] += increment;
  }
  return null;
}

代码示例来源:origin: addthis/hydra

@Override
  public void process(Bundle bundle, StreamEmitter emitter) {
    ValueObject valueObject = bundle.getValue(bundle.getFormat().getField(field));
    if (filter != null) {
      valueObject = filter.filter(valueObject, bundle);
    }
    if (valueObject != null && valueObject.getObjectType() == ValueObject.TYPE.ARRAY) {
      ValueArray array = valueObject.asArray();
      for (ValueObject v : array) {
        Bundle newBundle = bundle.createBundle();
        for (String outputFieldString : splitOutputFields) {
          BundleField outputField = newBundle.getFormat().getField(outputFieldString);
          if (outputFieldString.equals(field)) {
            newBundle.setValue(outputField, v);
          } else {
            newBundle.setValue(outputField, bundle.getValue(outputField));
          }
        }
        emitter.emit(newBundle);
      }
    }
    if (dropFromOriginal) {
      bundle.removeValue(bundle.getFormat().getField(field));
    }
    emitter.emit(bundle);
  }
}

代码示例来源:origin: addthis/hydra

@Override
  public void process(Bundle row, StreamEmitter emitter) {
    BundleField fieldFrom = row.getFormat().getField(fromArrayField);
    BundleField fieldTo = row.getFormat().getField(toField);
    ValueObject fromObject = row.getValue(fieldFrom);
    if (fromObject == null || fromObject.getObjectType() != ValueObject.TYPE.ARRAY) {
      if (emitFilter == null || emitFilter.filter(row)) {
        emitter.emit(row);
      }
    } else {
      ValueArray fromArray = fromObject.asArray();
      for (ValueObject element : fromArray) {
        Bundle newBundle = row.createBundle();
        for (BundleField field : row.getFormat()) {
          newBundle.setValue(field, row.getValue(field));
        }
        newBundle.setValue(fieldTo, element);
        if (emitFilter == null || emitFilter.filter(newBundle)) {
          emitter.emit(newBundle);
        }
      }
    }
  }
}

代码示例来源:origin: addthis/hydra

colOut = colIn;
if (summary) {
  lastRow = row.createBundle();

相关文章