本文整理汇总了C++中ArrayDesc::getDimensions方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayDesc::getDimensions方法的具体用法?C++ ArrayDesc::getDimensions怎么用?C++ ArrayDesc::getDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayDesc
的用法示例。
在下文中一共展示了ArrayDesc::getDimensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: desc
TupleArray::TupleArray(ArrayDesc const& schema, vector< boost::shared_ptr<Tuple> > const& data, Coordinate offset)
: desc(schema),
start(schema.getDimensions()[0].getStart() + offset),
end(start + offset + schema.getDimensions()[0].getLength() - 1),
tuples(data), chunkSize(schema.getDimensions()[0].getChunkInterval())
{
desc.cutOverlap();
if (Coordinate(start + tuples.size()) <= end) {
end = start + tuples.size() - 1;
}
}
示例2: fillUsedPlugins
void fillUsedPlugins(const ArrayDesc& desc, vector<string>& plugins) const
{
for (size_t i = 0; i < desc.getAttributes().size(); i++) {
const string& libName = TypeLibrary::getTypeLibraries().getObjectLibrary(desc.getAttributes()[i].getType());
if (libName != "scidb")
plugins.push_back(libName);
}
for (size_t i = 0; i < desc.getDimensions().size(); i++) {
const string& libName = TypeLibrary::getTypeLibraries().getObjectLibrary(desc.getDimensions()[i].getType());
if (libName != "scidb")
plugins.push_back(libName);
}
}
示例3: DelegateArray
SplitArray::SplitArray(ArrayDesc const& desc,
const boost::shared_array<char>& src,
Coordinates const& from,
Coordinates const& till,
shared_ptr<Query>const& query)
: DelegateArray(desc, shared_ptr<Array>(), true),
_startingChunk(from),
_from(from),
_till(till),
_size(from.size()),
_src(src),
_empty(false)
{
assert(query);
_query = query;
desc.getChunkPositionFor(_startingChunk);
Dimensions const& dims = desc.getDimensions();
for (size_t i = 0, n = dims.size(); i < n; i++) {
_size[i] = _till[i] - _from[i] + 1;
if (_size[i] == 0) {
_empty = true;
}
if (_till[i] > dims[i].getEndMax()) {
_till[i] = dims[i].getEndMax();
}
}
}
示例4: USER_EXCEPTION
TupleArray::TupleArray(ArrayDesc const& schema, vector< boost::shared_ptr<ConstArrayIterator> > const& arrayIterators, size_t shift, size_t step)
: desc(schema),
start(schema.getDimensions()[0].getStart()),
end(schema.getDimensions()[0].getEndMax()),
chunkSize(schema.getDimensions()[0].getChunkInterval())
{
if (schema.getDimensions().size() != 1)
throw USER_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_MULTIDIMENSIONAL_ARRAY_NOT_ALLOWED);
append(arrayIterators, shift, step);
if (start == MIN_COORDINATE || end == MAX_COORDINATE) {
start = 0;
end = tuples.size()-1;
} else if (Coordinate(start + tuples.size()) <= end) {
end = start + tuples.size() - 1;
}
}
示例5: generateShadowArraySchema
ArrayDesc InputArray::generateShadowArraySchema(ArrayDesc const& targetArray, string const& shadowArrayName)
{
Attributes const& srcAttrs = targetArray.getAttributes(true);
size_t nAttrs = srcAttrs.size();
Attributes dstAttrs(nAttrs+2);
for (size_t i = 0; i < nAttrs; i++) {
dstAttrs[i] = AttributeDesc(i, srcAttrs[i].getName(), TID_STRING, AttributeDesc::IS_NULLABLE, 0);
}
dstAttrs[nAttrs] = AttributeDesc(nAttrs, "row_offset", TID_INT64, 0, 0);
dstAttrs[nAttrs+1] = AttributeDesc(nAttrs+1, DEFAULT_EMPTY_TAG_ATTRIBUTE_NAME,
TID_INDICATOR, AttributeDesc::IS_EMPTY_INDICATOR, 0);
return ArrayDesc(shadowArrayName, dstAttrs, targetArray.getDimensions());
}
示例6: createWindowDesc
//param desc --> the input array schema
ArrayDesc createWindowDesc(ArrayDesc const& desc)
{
//get dimensions for output array
Attributes const &attrs = desc.getAttributes();
/*
Dimensions aggrDims(dims.size());
for (size_t i = 0; i < dims.size(); i++)
{
DimensionDesc const& srcDim = dims[i];
aggrDims[i] = DimensionDesc(srcDim.getBaseName(),
srcDim.getNamesAndAliases(),
srcDim.getStartMin(),
srcDim.getCurrStart(),
srcDim.getCurrEnd(),
srcDim.getEndMax(),
srcDim.getChunkInterval(),
0);
}
*/
Attributes newAttributes;
size_t n = 0;
for (size_t i=desc.getDimensions().size()*2; i < _parameters.size()-1; i=i+2)
{
const AttributeDesc &attr = attrs[((boost::shared_ptr<OperatorParamReference>&)_parameters[i])->getObjectNo()];
newAttributes.push_back(AttributeDesc(n, attr.getName(),
attr.getType(),
attr.getFlags(),
attr.getDefaultCompressionMethod(),
attr.getAliases()));
}
return ArrayDesc(desc.getName(), newAttributes, desc.getDimensions());
}
示例7: createWindowDesc
//param desc --> the input array schema
inline ArrayDesc createWindowDesc(ArrayDesc const& desc)
{
//get dimensions for output array
Dimensions const& dims = desc.getDimensions();
Dimensions aggrDims(dims.size());
for (size_t i = 0; i < dims.size(); i++)
{
DimensionDesc const& srcDim = dims[i];
aggrDims[i] = DimensionDesc(srcDim.getBaseName(),
srcDim.getNamesAndAliases(),
srcDim.getStartMin(),
srcDim.getCurrStart(),
srcDim.getCurrEnd(),
srcDim.getEndMax(),
srcDim.getChunkInterval(),
0);
}
ArrayDesc output(desc.getName(), Attributes(), aggrDims);
//get the aggregates, check if they make sense, make attributes for output array
//_parameters[0~dims.size()*2-1] --> window boundaries, already get in inferSchema
for (size_t i = dims.size()*2; i < _parameters.size(); i++)
{
boost::shared_ptr<scidb::OperatorParam> param = _parameters[i];
if ( param->getParamType() != PARAM_AGGREGATE_CALL) {
throw USER_QUERY_EXCEPTION(SCIDB_SE_INFER_SCHEMA,
SCIDB_LE_OP_WINDOW_ERROR5,
_parameters[i]->getParsingContext());
}
addAggregatedAttribute( (shared_ptr<OperatorParamAggregateCall> &) param, desc, output, true);
}
if ( desc.getEmptyBitmapAttribute()) //?
{
AttributeDesc const* eAttr = desc.getEmptyBitmapAttribute();
output.addAttribute(AttributeDesc(output.getAttributes().size(),
eAttr->getName(),
eAttr->getType(),
eAttr->getFlags(),
eAttr->getDefaultCompressionMethod()));
}
return output;
}
示例8: parser
FITSInputArray::FITSInputArray(ArrayDesc const& array, string const& filePath, uint32_t hdu, std::shared_ptr<Query>& query)
: parser(filePath),
hdu(hdu),
desc(array),
dims(array.getDimensions()),
nDims(dims.size()),
nAttrs(array.getAttributes(true).size()),
values(nAttrs),
chunks(nAttrs),
chunkIterators(nAttrs),
chunkIndex(0),
chunkPos(nDims),
query(query)
{
initValueHolders();
// Most initialization steps are only done later, when the first
// chunk is requested by an iterator. See getChunkByIndex()
}
示例9: createWindowDesc
inline ArrayDesc createWindowDesc(ArrayDesc const& desc)
{
Dimensions const& dims = desc.getDimensions();
Dimensions aggDims(dims.size());
for (size_t i = 0, n = dims.size(); i < n; i++)
{
DimensionDesc const& srcDim = dims[i];
aggDims[i] = DimensionDesc(srcDim.getBaseName(),
srcDim.getNamesAndAliases(),
srcDim.getStartMin(),
srcDim.getCurrStart(),
srcDim.getCurrEnd(),
srcDim.getEndMax(),
srcDim.getChunkInterval(),
0,
srcDim.getType(),
srcDim.getFlags(),
srcDim.getMappingArrayName(),
srcDim.getComment(),
srcDim.getFuncMapOffset(),
srcDim.getFuncMapScale());
}
ArrayDesc output (desc.getName(), Attributes(), aggDims);
for (size_t i = dims.size() * 2, size = _parameters.size(); i < size; i++)
{
addAggregatedAttribute( (shared_ptr <OperatorParamAggregateCall> &) _parameters[i], desc, output);
}
if ( desc.getEmptyBitmapAttribute())
{
AttributeDesc const* eAtt = desc.getEmptyBitmapAttribute();
output.addAttribute(AttributeDesc(output.getAttributes().size(), eAtt->getName(),
eAtt->getType(), eAtt->getFlags(), eAtt->getDefaultCompressionMethod()));
}
return output;
}
示例10: inferSchema
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, boost::shared_ptr< Query> query)
{
assert(schemas.size() == 1);
ArrayDesc const& srcDesc = schemas[0];
ArrayDesc dstDesc = ((boost::shared_ptr<OperatorParamSchema>&)_parameters[0])->getSchema();
//Compile a desc of all possible attributes (aggregate calls first) and source dimensions
ArrayDesc aggregationDesc (srcDesc.getName(), Attributes(), srcDesc.getDimensions());
vector<string> aggregatedNames;
//add aggregate calls first
for (size_t i = 1; i < _parameters.size(); i++)
{
addAggregatedAttribute( (shared_ptr <OperatorParamAggregateCall>&) _parameters[i], srcDesc, aggregationDesc);
aggregatedNames.push_back(aggregationDesc.getAttributes()[aggregationDesc.getAttributes().size()-1].getName());
}
//add other attributes
BOOST_FOREACH(const AttributeDesc &srcAttr, srcDesc.getAttributes())
{
//if there's an attribute with same name as an aggregate call - skip the attribute
bool found = false;
BOOST_FOREACH(const AttributeDesc &aggAttr, aggregationDesc.getAttributes())
{
if( aggAttr.getName() == srcAttr.getName())
{
found = true;
}
}
if (!found)
{
aggregationDesc.addAttribute(AttributeDesc( aggregationDesc.getAttributes().size(),
srcAttr.getName(),
srcAttr.getType(),
srcAttr.getFlags(),
srcAttr.getDefaultCompressionMethod(),
srcAttr.getAliases(),
&srcAttr.getDefaultValue(),
srcAttr.getDefaultValueExpr(),
srcAttr.getComment(),
srcAttr.getVarSize()));
}
}
//Ensure attributes names uniqueness.
if (!dstDesc.getEmptyBitmapAttribute())
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_OP_REDIMENSION_ERROR1);
BOOST_FOREACH(const AttributeDesc &dstAttr, dstDesc.getAttributes())
{
BOOST_FOREACH(const AttributeDesc &srcAttr, aggregationDesc.getAttributes())
{
if (srcAttr.getName() == dstAttr.getName())
{
if (srcAttr.getType() != dstAttr.getType())
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_ATTRIBUTE_TYPE)
<< srcAttr.getName() << srcAttr.getType() << dstAttr.getType();
}
if (!dstAttr.isNullable() && srcAttr.isNullable())
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_ATTRIBUTE_FLAGS)
<< srcAttr.getName();
}
goto NextAttr;
}
}
BOOST_FOREACH(const DimensionDesc &srcDim, aggregationDesc.getDimensions())
{
if (srcDim.hasNameOrAlias(dstAttr.getName()))
{
if (dstAttr.getType() != TID_INT64)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_DESTINATION_ATTRIBUTE_TYPE)
<< dstAttr.getName() << TID_INT64;
}
if (srcDim.getType() != TID_INT64)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_SOURCE_DIMENSION_TYPE)
<< dstAttr.getName() << TID_INT64;
}
if (dstAttr.getFlags() != 0)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_DESTINATION_ATTRIBUTE_FLAGS)
<< dstAttr.getName();
}
goto NextAttr;
}
}
if (dstAttr.isEmptyIndicator() == false)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_UNEXPECTED_DESTINATION_ATTRIBUTE)
<< dstAttr.getName();
}
//.........这里部分代码省略.........
示例11: nCol
inline size_t nCol(const ArrayDesc& desc, bool transpose=false) { return nCol(desc.getDimensions(), transpose); }
示例12: inferSchema
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, boost::shared_ptr< Query> query)
{
assert(schemas.size() == 1);
ArrayDesc const& srcDesc = schemas[0];
ArrayDesc dstDesc = ((boost::shared_ptr<OperatorParamSchema>&)_parameters[0])->getSchema();
//Compile a desc of all possible attributes (aggregate calls first) and source dimensions
ArrayDesc aggregationDesc (srcDesc.getName(), Attributes(), srcDesc.getDimensions());
vector<string> aggregatedNames;
//add aggregate calls first
for (size_t i = 1; i < _parameters.size(); i++)
{
addAggregatedAttribute( (shared_ptr <OperatorParamAggregateCall>&) _parameters[i], srcDesc, aggregationDesc);
string aggName = aggregationDesc.getAttributes()[aggregationDesc.getAttributes().size()-1].getName();
bool aggFound = false;
BOOST_FOREACH(const AttributeDesc &dstAttr, dstDesc.getAttributes()) {
if (dstAttr.getName() == aggName) {
aggFound = true;
break;
}
}
if (!aggFound) {
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_ATTRIBUTE_DOESNT_EXIST) << aggName << dstDesc.getName();
}
aggregatedNames.push_back(aggName);
}
//add other attributes
BOOST_FOREACH(const AttributeDesc &srcAttr, srcDesc.getAttributes())
{
//if there's an attribute with same name as an aggregate call - skip the attribute
bool found = false;
BOOST_FOREACH(const AttributeDesc &aggAttr, aggregationDesc.getAttributes())
{
if( aggAttr.getName() == srcAttr.getName())
{
found = true;
}
}
if (!found)
{
aggregationDesc.addAttribute(AttributeDesc( aggregationDesc.getAttributes().size(),
srcAttr.getName(),
srcAttr.getType(),
srcAttr.getFlags(),
srcAttr.getDefaultCompressionMethod(),
srcAttr.getAliases(),
&srcAttr.getDefaultValue(),
srcAttr.getDefaultValueExpr(),
srcAttr.getVarSize()));
}
}
//Ensure attributes names uniqueness.
if (!dstDesc.getEmptyBitmapAttribute())
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_OP_REDIMENSION_ERROR1);
BOOST_FOREACH(const AttributeDesc &dstAttr, dstDesc.getAttributes())
{
BOOST_FOREACH(const AttributeDesc &srcAttr, aggregationDesc.getAttributes())
{
if (srcAttr.getName() == dstAttr.getName())
{
if (srcAttr.getType() != dstAttr.getType())
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_ATTRIBUTE_TYPE)
<< srcAttr.getName() << srcAttr.getType() << dstAttr.getType();
}
if (!dstAttr.isNullable() && srcAttr.isNullable())
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_ATTRIBUTE_FLAGS)
<< srcAttr.getName();
}
goto NextAttr;
}
}
BOOST_FOREACH(const DimensionDesc &srcDim, aggregationDesc.getDimensions())
{
if (srcDim.hasNameAndAlias(dstAttr.getName()))
{
if (dstAttr.getType() != TID_INT64)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_DESTINATION_ATTRIBUTE_TYPE)
<< dstAttr.getName() << TID_INT64;
}
if (dstAttr.getFlags() != 0)
{
throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_DESTINATION_ATTRIBUTE_FLAGS)
<< dstAttr.getName();
}
goto NextAttr;
}
}
if (dstAttr.isEmptyIndicator() == false)
//.........这里部分代码省略.........
示例13: execute
shared_ptr< Array > execute(vector< shared_ptr< Array> >& inputArrays, shared_ptr<Query> query)
{
// I maintain the log of the operator in a local file named after Correlation_N.log, N is the instance ID.
stringstream logFileName;
logFileName << "/home/scidb/preselect_" << query->getInstanceID() << ".log";
FILE *logFile;
logFile = fopen(logFileName.str().c_str(), "w");
shared_ptr<Array> originalArray = inputArrays[0];
shared_ptr<Array> correlationArray = inputArrays[1];
ArrayDesc originalSchema = originalArray->getArrayDesc();
ArrayDesc corrSchema = correlationArray->getArrayDesc();
Dimensions originalDims = originalSchema.getDimensions();
Dimensions corrDims = corrSchema.getDimensions();
DimensionDesc originalDimsP = originalDims[1];
DimensionDesc corrDimsP = corrDims[0];
// Note the correlation array doesn't have Y column.
Coordinate p = corrDimsP.getCurrLength();
fprintf(logFile, "p = %ld\n # of chunk = %ld\n", p, corrSchema.getNumberOfChunks());
fflush(logFile);
shared_ptr<ConstArrayIterator> corrArrayIter = correlationArray->getIterator(0);
if(! corrArrayIter->end() )
{
correlation *corr = new correlation[p];
// The correlation array will always have only 1 chunk (we designed correlation array like this), so no loops here.
shared_ptr<ConstChunkIterator> corrChunkIter = corrArrayIter->getChunk().getConstIterator();
for(Coordinate i=0; i<p; ++i)
{
corr[i].id = i+1;
corr[i].corr = corrChunkIter->getItem().getDouble();
//fprintf(logFile, "%d, %f\n", corr[i].id, corr[i].corr);
++(*corrChunkIter);
}
//fflush(logFile);
qsort(corr, p, sizeof(correlation), &comp);
for(Coordinate i=0; i<p; ++i)
{
fprintf(logFile, "%d, %f\n", corr[i].id, corr[i].corr);
}
fflush(logFile);
Coordinate d = ((boost::shared_ptr<OperatorParamPhysicalExpression>&)_parameters[0])->getExpression()->evaluate().getInt64();
fprintf(logFile, "d=%ld\n", d);
stringstream ss;
vector<string> names;
names.push_back("j");
vector<TypeId> types;
types.push_back(TID_INT64);
for(Coordinate i=0; i<d; ++i)
{
ss << "j=" << corr[i].id << " or ";
}
ss << "j=" << p+1;
fprintf(logFile, "%s\n", ss.str().c_str());
fflush(logFile);
Expression e;
e.compile(ss.str(), names, types);
fclose(logFile);
boost::shared_ptr<scidb::Query> emptyQuery;
return boost::shared_ptr<Array>(new FilterArray(_schema, inputArrays[0], boost::make_shared<Expression>(e), emptyQuery, _tileMode));
}
else
{
shared_ptr<Array> outputArray(new MemArray(_schema, query));
fclose(logFile);
return outputArray;
}
}
示例14: chunkCol
inline unsigned int chunkCol(const ArrayDesc& desc, bool transpose=false) { return chunkCol(desc.getDimensions(), transpose); }
示例15: DelegateArray
ReshapeArray::ReshapeArray(ArrayDesc const& desc, boost::shared_ptr<Array> const& array)
: DelegateArray(desc, array),
inDims(array->getArrayDesc().getDimensions()),
outDims(desc.getDimensions())
{
}