Create a DBObject from the given scalar/link column values.
768918
private DBObject createObject(TableDefinition tableDef, String objID, Iterator<DColumn> colIter) {
        DBObject dbObj = new DBObject();
        dbObj.setObjectID(objID);
        dbObj.setTableName(tableDef.getTableName());
        while (colIter.hasNext()) {
            DColumn col = colIter.next();
            Pair<String, String> linkCol = extractLinkValue(tableDef, col.getName());
            if (linkCol == null) {
                String fieldName = col.getName();
                String fieldValue = scalarValueToString(tableDef, col.getName(), col.getRawValue());
                FieldDefinition fieldDef = tableDef.getFieldDef(fieldName);
                if (fieldDef != null && fieldDef.isCollection()) {
                    // MV scalar field
                    Set<String> values = Utils.split(fieldValue, CommonDefs.MV_SCALAR_SEP_CHAR);
                    dbObj.addFieldValues(fieldName, values);
                } else {
                    dbObj.addFieldValue(col.getName(), fieldValue);
                }
            // Skip links no longer present in schema
            } else if (tableDef.isLinkField(linkCol.firstItemInPair)) {
                dbObj.addFieldValue(linkCol.firstItemInPair, linkCol.secondItemInPair);
            }
        }
        return dbObj;
    }
530311
public java.sql.Blob getBlob(final Object value) throws SQLException {
            if (value instanceof java.sql.Blob) return (java.sql.Blob) value;

            if (value instanceof byte[]) {
                return new SerialBlob((byte[]) value);
            }
581486
def convert(self, key, value):
        """"""
        if key not in self._dtypes:
            self.read_types()
            if key not in self._dtypes:
                name = utils.name(value)
                serializer = utils.serializer(name)
                deserializer = utils.deserializer(name)
                self._dtypes[key] = (name, serializer, deserializer)
                with self.db:
                    self.db.execute("replace into value_types (key, value_type) values (?, ?)", (key, name))
        return self._dtypes[key][1](value)
66169
def from_dataframe(cls, name, df, indices, primary_key=None):
        """"""

        # ordered list (column_name, column_type) pairs
        column_types = []
        # which columns have nullable values
        nullable = set()

        # tag cached database by dataframe's number of rows and columns
        for column_name in df.columns:
            values = df[column_name]
            if values.isnull().any():
                nullable.add(column_name)
            column_db_type = db_type(values.dtype)
            column_types.append((column_name.replace(" ", "_"), column_db_type))

        def make_rows():
            return list(tuple(row) for row in df.values)

        return cls(
            name=name,
            column_types=column_types,
            make_rows=make_rows,
            indices=indices,
            nullable=nullable,
            primary_key=primary_key)
1270431
def _parse_canonical_dbpointer(doc):
    """"""
    dbref = doc['$dbPointer']
    if len(doc) != 1:
        raise TypeError('Bad $dbPointer, extra field(s): %s' % (doc,))
    if isinstance(dbref, DBRef):
        dbref_doc = dbref.as_doc()
        # DBPointer must not contain $db in its value.
        if dbref.database is not None:
            raise TypeError(
                'Bad $dbPointer, extra field $db: %s' % (dbref_doc,))
        if not isinstance(dbref.id, ObjectId):
            raise TypeError(
                'Bad $dbPointer, $id must be an ObjectId: %s' % (dbref_doc,))
        if len(dbref_doc) != 2:
            raise TypeError(
                'Bad $dbPointer, extra field(s) in DBRef: %s' % (dbref_doc,))
        return dbref
    else:
        raise TypeError('Bad $dbPointer, expected a DBRef: %s' % (doc,))
1093238
def db_from_dataframe(
        db_filename,
        table_name,
        df,
        primary_key=None,
        subdir=None,
        overwrite=False,
        indices=(),
        version=1):
    
    return db_from_dataframes(
        db_filename=db_filename,
        dataframes={table_name: df},
        primary_keys={table_name: primary_key},
        indices={table_name: indices},
        subdir=subdir,
        overwrite=overwrite,
        version=version)
687510
function deserializeMember(value, columnType) {
    
    // Handle this special case first.
    // Simply return 'value' if a corresponding columnType is not defined.   
    if (!columnType) {
        return value;
    }

    // Start by checking if the specified column type is valid.
    if (!isColumnTypeValid(columnType)) {
            throw new Error('Column type ' + columnType + ' is not supported');
    }

    // Now check if the specified value can be stored in a column of type columnType.
    if (!isSqliteValueCompatibleWithColumnType(value, columnType)) {
        throw new Error('Converting value ' + JSON.stringify(value) + ' of type ' + typeof value +
                            ' to type ' + columnType + ' is not supported.');
    }

    // If we are here, it means we are good to proceed with deserialization
    
    var deserializedValue, error;

    switch (columnType) {
        case ColumnType.Object:
            deserializedValue = typeConverter.convertToObject(value);
            break;
        case ColumnType.Array:
            deserializedValue = typeConverter.convertToArray(value);
            break;
        case ColumnType.String:
        case ColumnType.Text:
            deserializedValue = typeConverter.convertToText(value);
            break;
        case ColumnType.Integer:
        case ColumnType.Int:
            deserializedValue = typeConverter.convertToInteger(value);
            break;
        case ColumnType.Boolean:
        case ColumnType.Bool:
            deserializedValue = typeConverter.convertToBoolean(value);
            break;
        case ColumnType.Date:
            deserializedValue = typeConverter.convertToDate(value);
            break;
        case ColumnType.Real:
        case ColumnType.Float:
            deserializedValue = typeConverter.convertToReal(value);
            break;
        default:
            throw new Error(_.format(Platform.getResourceString("sqliteSerializer_UnsupportedColumnType"), columnType));
    }

    return deserializedValue;
}
152120
private void indexDense(DBIDRef ref, V obj) {
    double len = 0.;
    for(int dim = 0, max = obj.getDimensionality(); dim < max; dim++) {
      final double val = obj.doubleValue(dim);
      if(val == 0. || val != val) {
        continue;
      }
      len += val * val;
      getOrCreateColumn(dim).add(val, ref);
    }
    length.put(ref, FastMath.sqrt(len));
  }
900353
def save_object_to_db(self,
                          obj: Any,
                          table: str,
                          fieldlist: Sequence[str],
                          is_new_record: bool) -> None:
        """"""
        if is_new_record:
            pkvalue = getattr(obj, fieldlist[0])
            if pkvalue is None:
                self.insert_object_into_db_pk_unknown(obj, table, fieldlist)
            else:
                self.insert_object_into_db_pk_known(obj, table, fieldlist)
        else:
            self.update_object_in_db(obj, table, fieldlist)
96614
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True):
        """"""
        if not isinstance(dictionary, Mapping):
            raise TypeError('dictionary should be mapping')
        obj = cls(values, value_filter)
        values = obj.__values
        for name, value in dictionary.items():
            if not isinstance(name, string_types):
                raise TypeError('Key %s is not a string' % str(name))
            setattr(values, name, value)
        if obj.missing and not allow_unset:
            raise ValueError('%d value(s) are unset' % len(obj.missing))
        return obj
366537
def from_raw(self, rval: RawScalar, jptr: JSONPointer = "") -> ScalarValue:
        """"""
        res = self.type.from_raw(rval)
        if res is None:
            raise RawTypeError(jptr, self.type.yang_type() + " value")
        return res
841311
def insert_object_into_db_pk_known(self,
                                       obj: Any,
                                       table: str,
                                       fieldlist: Sequence[str]) -> None:
        """"""
        pkvalue = getattr(obj, fieldlist[0])
        if pkvalue is None:
            raise AssertionError("insert_object_intoto_db_pk_known called "
                                 "without PK")
        valuelist = []
        for f in fieldlist:
            valuelist.append(getattr(obj, f))
        self.db_exec(
            get_sql_insert(table, fieldlist, self.get_delims()),
            *valuelist
        )
564415
public static Object convertBlob(Connection conn, byte[] value) throws SQLException {
        Object result = createBlob(conn);

        result = convertBlob(result, value);

        return result;
    }
683897
public static Object getObjectFromColumn(ResultSet rs, Integer jdbcType, int columnId)
            throws SQLException
    {
        return getObjectFromColumn(rs, null, jdbcType, null, columnId);
    }
387101
def create(cls, data, **kwargs):
        """"""
        with db.session.begin_nested():
            model = cls.dbmodel(**kwargs)
            model.data = data
            obj = cls(model)
            db.session.add(obj.model)
        return obj
836335
def _encode_dbref(name, value, check_keys, opts):
    """"""
    buf = bytearray(b"\x03" + name + b"\x00\x00\x00\x00")
    begin = len(buf) - 4

    buf += _name_value_to_bson(b"$ref\x00",
                               value.collection, check_keys, opts)
    buf += _name_value_to_bson(b"$id\x00",
                               value.id, check_keys, opts)
    if value.database is not None:
        buf += _name_value_to_bson(
            b"$db\x00", value.database, check_keys, opts)
    for key, val in iteritems(value._DBRef__kwargs):
        buf += _element_to_bson(key, val, check_keys, opts)

    buf += b"\x00"
    buf[begin:begin + 4] = _PACK_INT(len(buf) - begin)
    return bytes(buf)
150720
def from_dict(cls, d):
        """"""
        read = lambda cls: (lambda pair: (pair[0], cls.from_dict(pair[1])))
        return cls(
            variables=map(read(Variable), d.get('variables', {}).items()),
            properties=map(read(Property), d.get('properties', {}).items()),
            roles=map(read(Role), d.get('roles', {}).items()),
            predicates=map(read(Predicate), d.get('predicates', {}).items())
        )