ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, std::shared_ptr< Query> query) { assert(schemas.size() == 1); for (Parameters::const_iterator it = _parameters.begin(); it != _parameters.end(); ++it) assert(((std::shared_ptr<OperatorParamReference>&)*it)->getParamType() == PARAM_ATTRIBUTE_REF); Attributes newAttributes; const Attributes &oldAttributes = schemas[0].getAttributes(); bool includesIndicator = false; size_t n = _parameters.size(); for (size_t i = 0; i < n; i++) { const AttributeDesc &attr = oldAttributes[((std::shared_ptr<OperatorParamReference>&)_parameters[i])->getObjectNo()]; newAttributes.push_back(AttributeDesc(i, attr.getName(), attr.getType(), attr.getFlags(), attr.getDefaultCompressionMethod(), attr.getAliases(), &attr.getDefaultValue(), attr.getDefaultValueExpr())); includesIndicator |= attr.isEmptyIndicator(); } if (!includesIndicator) { AttributeDesc const* indicator = schemas[0].getEmptyBitmapAttribute(); if (indicator != NULL) { newAttributes.push_back(AttributeDesc(n, indicator->getName(), indicator->getType(), indicator->getFlags(), indicator->getDefaultCompressionMethod(), indicator->getAliases())); } } return ArrayDesc(schemas[0].getName(), newAttributes, schemas[0].getDimensions(), defaultPartitioning()); }
ArrayDesc inferSchema(std::vector<ArrayDesc> schemas, boost::shared_ptr<Query> query) { Attributes atts; atts.push_back(AttributeDesc(0, "attribute_name", TID_STRING, 0, 0)); atts.push_back(AttributeDesc(1, "min", TID_STRING, 0, 0)); atts.push_back(AttributeDesc(2, "max", TID_STRING, 0, 0)); atts.push_back(AttributeDesc(3, "distinct_count", TID_UINT64, 0, 0)); atts.push_back(AttributeDesc(4, "non_null_count", TID_UINT64, 0, 0)); const AttributeDesc *emptyIndicator = schemas[0].getEmptyBitmapAttribute(); set<string> a_s; for (size_t i = 0; i < _parameters.size(); i++) { string attName = ((boost::shared_ptr<OperatorParamReference>&)_parameters[i])->getObjectName(); if (emptyIndicator && emptyIndicator->getName() == attName) continue; a_s.insert(attName); } size_t attsCount = (a_s.size() == 0 ? (emptyIndicator ? schemas[0].getAttributes().size() - 1 : schemas[0].getAttributes().size()) : a_s.size()) - 1; Dimensions dims; dims.push_back(DimensionDesc("attribute_number", 0, attsCount, ANALYZE_CHUNK_SIZE, 0)); return ArrayDesc(schemas[0].getName() + "_analyze", atts, dims); }
Attributes Device::GetBasicAttributes() { Attributes attributes; attributes.push_back(Attribute(B_TRANSLATE("Device name:"), GetName())); attributes.push_back(Attribute(B_TRANSLATE("Manufacturer:"), GetManufacturer())); return attributes; }
Attributes DevicePCI::GetBusAttributes() { Attributes attributes; attributes.push_back(GetAttribute(B_DEVICE_TYPE)); attributes.push_back(GetAttribute(B_DEVICE_SUB_TYPE)); attributes.push_back(GetAttribute(B_DEVICE_INTERFACE)); attributes.push_back(GetAttribute(B_DEVICE_VENDOR_ID)); attributes.push_back(GetAttribute(B_DEVICE_ID)); return attributes; }
Attributes Device::GetBusAttributes() { Attributes attributes; attributes.push_back(Attribute("None", "")); return attributes; }
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, boost::shared_ptr< Query> query) { Attributes outputAttrs; outputAttrs.push_back(AttributeDesc(0, "dummy", TID_DOUBLE, AttributeDesc::IS_NULLABLE, 0)); Dimensions outputDims; outputDims.push_back(DimensionDesc("i",0,0,1,0)); return ArrayDesc("test_cache", outputAttrs, outputDims); }
Attributes Device::GetAllAttributes() { Attributes attributes; AttributeMapIterator iter; for (iter = fAttributeMap.begin(); iter != fAttributeMap.end(); iter++) { attributes.push_back(Attribute(iter->first, iter->second)); } return attributes; }
Attributes DeviceSCSI::GetBusAttributes() { // Push back things that matter for SCSI devices Attributes attributes; attributes.push_back(GetAttribute(B_TRANSLATE("Device class"))); attributes.push_back(GetAttribute(B_TRANSLATE("Device name"))); attributes.push_back(GetAttribute(B_TRANSLATE("Manufacturer"))); attributes.push_back(GetAttribute("scsi/revision")); attributes.push_back(GetAttribute("scsi/target_id")); attributes.push_back(GetAttribute("scsi/target_lun")); return attributes; }
//static void ExpatInStream::sStartElem(void *userData, const char *name, const char **attr) { int i; LString sname(name); MB_ASSERT(sname.length()==strlen(name)); Attributes attrls; for (i=0; attr[i]; i+=2) { LString key(attr[i]); LString val(attr[i+1]); attrls.push_back(Attributes::value_type(key, val)); } ExpatInStream *pReader = (ExpatInStream *)userData; if (pReader->getError()) return; pReader->startElement(sname, attrls); pReader->incrDepth(); }
//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()); }
void DevicesView::AddDeviceAndChildren(device_node_cookie *node, Device* parent) { Attributes attributes; Device* newDevice = NULL; // Copy all its attributes, // necessary because we can only request them once from the device manager char data[256]; struct device_attr_info attr; attr.cookie = 0; attr.node_cookie = *node; attr.value.raw.data = data; attr.value.raw.length = sizeof(data); while (dm_get_next_attr(&attr) == B_OK) { BString attrString; switch (attr.type) { case B_STRING_TYPE: attrString << attr.value.string; break; case B_UINT8_TYPE: attrString << attr.value.ui8; break; case B_UINT16_TYPE: attrString << attr.value.ui16; break; case B_UINT32_TYPE: attrString << attr.value.ui32; break; case B_UINT64_TYPE: attrString << attr.value.ui64; break; default: attrString << "Raw data"; } attributes.push_back(Attribute(attr.name, attrString)); } // Determine what type of device it is and create it for (unsigned int i = 0; i < attributes.size(); i++) { // Devices Root if (attributes[i].fName == B_DEVICE_PRETTY_NAME && attributes[i].fValue == "Devices Root") { newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, B_TRANSLATE("Computer")); break; } // ACPI Controller if (attributes[i].fName == B_DEVICE_PRETTY_NAME && attributes[i].fValue == "ACPI") { newDevice = new Device(parent, BUS_ACPI, CAT_BUS, B_TRANSLATE("ACPI bus")); break; } // PCI bus if (attributes[i].fName == B_DEVICE_PRETTY_NAME && attributes[i].fValue == "PCI") { newDevice = new Device(parent, BUS_PCI, CAT_BUS, B_TRANSLATE("PCI bus")); break; } // ISA bus if (attributes[i].fName == B_DEVICE_BUS && attributes[i].fValue == "isa") { newDevice = new Device(parent, BUS_ISA, CAT_BUS, B_TRANSLATE("ISA bus")); break; } // PCI device if (attributes[i].fName == B_DEVICE_BUS && attributes[i].fValue == "pci") { newDevice = new DevicePCI(parent); break; } // ACPI device if (attributes[i].fName == B_DEVICE_BUS && attributes[i].fValue == "acpi") { newDevice = new DeviceACPI(parent); break; } // ATA / SCSI / IDE controller if (attributes[i].fName == "controller_name") { newDevice = new Device(parent, BUS_PCI, CAT_MASS, attributes[i].fValue); } // SCSI device node if (attributes[i].fName == B_DEVICE_BUS && attributes[i].fValue == "scsi") { newDevice = new DeviceSCSI(parent); break; } // Last resort, lets look for a pretty name if (attributes[i].fName == B_DEVICE_PRETTY_NAME) { newDevice = new Device(parent, BUS_NONE, CAT_NONE, attributes[i].fValue); break; } } // A completely unknown device if (newDevice == NULL) { newDevice = new Device(parent, BUS_NONE, CAT_NONE, B_TRANSLATE("Unknown device")); } // Add its attributes to the device, initialize it and add to the list. for (unsigned int i = 0; i < attributes.size(); i++) { newDevice->SetAttribute(attributes[i].fName, attributes[i].fValue); } newDevice->InitFromAttributes(); fDevices.push_back(newDevice); // Process children status_t err; device_node_cookie child = *node; if (get_child(&child) != B_OK) return; do { AddDeviceAndChildren(&child, newDevice); } while ((err = get_next_child(&child)) == B_OK); }
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, boost::shared_ptr< Query> query) { assert(schemas.size() == 1); assert(_parameters[0]->getParamType() == PARAM_ATTRIBUTE_REF); assert(_parameters[1]->getParamType() == PARAM_LOGICAL_EXPRESSION); if ( _parameters.size() % 2 != 0 ) { throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_WRONG_OPERATOR_ARGUMENTS_COUNT2) << "tile_apply"; } Attributes outAttrs; AttributeID nextAttrId =0; for (size_t i=0; i<schemas[0].getAttributes().size(); i++) { AttributeDesc const& attr = schemas[0].getAttributes()[i]; if(attr.getType()!=TID_INDICATOR) { outAttrs.push_back( AttributeDesc(nextAttrId++, attr.getName(), attr.getType(), attr.getFlags(), attr.getDefaultCompressionMethod(), attr.getAliases(), attr.getReserve(), &attr.getDefaultValue(), attr.getDefaultValueExpr(), attr.getVarSize())); } } size_t k; for (k=0; k<_parameters.size(); k+=2) { const string &attributeName = ((boost::shared_ptr<OperatorParamReference>&)_parameters[k])->getObjectName(); Expression expr; expr.compile(((boost::shared_ptr<OperatorParamLogicalExpression>&)_parameters[k+1])->getExpression(), query, _properties.tile, TID_VOID, schemas); assert(!_properties.tile); int flags = 0; if (expr.isNullable()) { flags = (int)AttributeDesc::IS_NULLABLE; } for (size_t j = 0; j < nextAttrId; j++) { AttributeDesc const& attr = outAttrs[j]; if (attr.getName() == attributeName) { throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_DUPLICATE_ATTRIBUTE_NAME) << attributeName; } } outAttrs.push_back(AttributeDesc(nextAttrId++, attributeName, expr.getType(), flags, 0)); } if(schemas[0].getEmptyBitmapAttribute()) { AttributeDesc const* emptyTag = schemas[0].getEmptyBitmapAttribute(); for (size_t j = 0; j < nextAttrId; j++) { AttributeDesc const& attr = outAttrs[j]; if (attr.getName() == emptyTag->getName()) { throw USER_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_DUPLICATE_ATTRIBUTE_NAME) << attr.getName(); } } outAttrs.push_back( AttributeDesc(nextAttrId, emptyTag->getName(), emptyTag->getType(), emptyTag->getFlags(), emptyTag->getDefaultCompressionMethod(), emptyTag->getAliases(), emptyTag->getReserve(), &emptyTag->getDefaultValue(), emptyTag->getDefaultValueExpr(), emptyTag->getVarSize())); } return ArrayDesc(schemas[0].getName(), outAttrs, schemas[0].getDimensions()); }
bool PixelBufferX11::createVisualInfo() { typedef std::vector<int> Attributes; Attributes attributes; attributes.push_back(GLX_USE_GL); attributes.push_back(GLX_RGBA); if (_traits->doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER); attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->red); attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->green); attributes.push_back(GLX_BLUE_SIZE); attributes.push_back(_traits->blue); attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->depth); if (_traits->alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->alpha); } if (_traits->stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->stencil); } #if defined(GLX_SAMPLE_BUFFERS) && defined (GLX_SAMPLES) if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLE_BUFFERS); attributes.push_back(_traits->sampleBuffers); } if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLES); attributes.push_back(_traits->samples); } #endif // TODO // GLX_AUX_BUFFERS // GLX_ACCUM_RED_SIZE // GLX_ACCUM_GREEN_SIZE attributes.push_back(None); _visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) ); return _visualInfo != 0; }
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, shared_ptr< Query> query) { assert(schemas.size() == 1); assert(_parameters.size() == 1); string arrayName = ((shared_ptr<OperatorParamReference>&)_parameters[0])->getObjectName(); ArrayDesc const& srcDesc = schemas[0]; //Ensure attributes names uniqueness. ArrayDesc dstDesc; if (!SystemCatalog::getInstance()->getArrayDesc(arrayName, dstDesc, false)) { Attributes outAttrs; map<string, uint64_t> attrsMap; BOOST_FOREACH(const AttributeDesc &attr, srcDesc.getAttributes()) { AttributeDesc newAttr; if (!attrsMap.count(attr.getName())) { attrsMap[attr.getName()] = 1; newAttr = attr; } else { while (true) { stringstream ss; ss << attr.getName() << "_" << ++attrsMap[attr.getName()]; if (attrsMap.count(ss.str()) == 0) { newAttr = AttributeDesc(attr.getId(), ss.str(), attr.getType(), attr.getFlags(), attr.getDefaultCompressionMethod(), attr.getAliases(), &attr.getDefaultValue(), attr.getDefaultValueExpr()); attrsMap[ss.str()] = 1; break; } } } outAttrs.push_back(newAttr); } Dimensions outDims; map<string, uint64_t> dimsMap; BOOST_FOREACH(const DimensionDesc &dim, srcDesc.getDimensions()) { DimensionDesc newDim; if (!dimsMap.count(dim.getBaseName())) { dimsMap[dim.getBaseName()] = 1; newDim = DimensionDesc(dim.getBaseName(), dim.getStartMin(), dim.getCurrStart(), dim.getCurrEnd(), dim.getEndMax(), dim.getChunkInterval(), dim.getChunkOverlap()); } else { while (true) { stringstream ss; ss << dim.getBaseName() << "_" << ++dimsMap[dim.getBaseName()]; if (dimsMap.count(ss.str()) == 0) { newDim = DimensionDesc(ss.str(), dim.getStartMin(), dim.getCurrStart(), dim.getCurrEnd(), dim.getEndMax(), dim.getChunkInterval(), dim.getChunkOverlap()); dimsMap[ss.str()] = 1; break; } } } outDims.push_back(newDim); } /* Notice that when storing to a non-existant array, we do not propagate the transience of the source array to to the target ...*/ return ArrayDesc(arrayName, outAttrs, outDims, srcDesc.getFlags() & (~ArrayDesc::TRANSIENT)); }