示例#1
0
class HBaseRow(object):
    def __init__(self, table, rowid):
        self.logger = Logger.getLogger("HBaseRow")
        # self.logger.setLevel(Level.DEBUG)
        # Must be a table object
        self.table = table
        # Must be a rowid
        self.rowid = rowid
        self.rowPut = Put(self.rowid)

    def put(self, family, column, value):
        ''' 
        For the current Table.
        Set the value of a given column-family. column.
        '''
        self.rowPut.add(family, column, value)

    def tablePut(self):
        self.table.put(self.rowPut)

    def get(self, family, column):
        ''' 
        For the current Table.
        get the value of a given column-family. column.
        '''
        row = self.table.get(Get(self.rowid))
        val = row.getValue(family, column)
        if val is not None:
            # Not sure if we would always want to do this.
            # -dgs
            return val.tostring()
示例#2
0
class HBaseRow(object):
    def __init__(self, table, rowid): 
        self.logger = Logger.getLogger("HBaseRow")
        # self.logger.setLevel(Level.DEBUG)
        # Must be a table object
        self.table = table
        # Must be a rowid
        self.rowid = rowid
        self.rowPut = Put(self.rowid)

    def put(self, family, column, value):
        ''' 
        For the current Table.
        Set the value of a given column-family. column.
        '''
        self.rowPut.add(family, column, value)

    def tablePut (self):
        self.table.put(self.rowPut)

    def get(self, family, column):
        ''' 
        For the current Table.
        get the value of a given column-family. column.
        '''
        row = self.table.get(Get(self.rowid))
        val = row.getValue(family, column)
        if val is not None:
            # Not sure if we would always want to do this.
            # -dgs
            return val.tostring()
示例#3
0
 def __init__(self, table, rowid):
     self.logger = Logger.getLogger("HBaseRow")
     # self.logger.setLevel(Level.DEBUG)
     # Must be a table object
     self.table = table
     # Must be a rowid
     self.rowid = rowid
     self.rowPut = Put(self.rowid)
示例#4
0
	def getUpdate(self, row):
		up = Put(row.getRow())
		for k, v in self.replace.items():
			(fam, col) = KeyValue.parseColumn( Bytes.toBytes( java.lang.String(k) ) )
			if isinstance(v, com.google.protobuf.Message):
				up.add(fam, col, v.toByteArray())
			else:
				up.add(fam, col, PBUtil.toBytes(v))

		return up
def update_row_proc (table,key_in,population_in):
	print	"update_row_proc"
	print	key_in
	print	population_in
	pp = Put(Bytes.toBytes(key_in))
#	ss_population = Integer.toString (population_in)
	ss_population = "%d" % population_in
	pp.add(Bytes.toBytes("population"), "",Bytes.toBytes(ss_population))
#
	today = strftime ("%Y-%m-%d",localtime ())
	pp.add(Bytes.toBytes("date_mod"), "", Bytes.toBytes(today))
	table.put (pp)
示例#6
0
 def __init__(self, table, rowid): 
     self.logger = Logger.getLogger("HBaseRow")
     # self.logger.setLevel(Level.DEBUG)
     # Must be a table object
     self.table = table
     # Must be a rowid
     self.rowid = rowid
     self.rowPut = Put(self.rowid)
示例#7
0
    def save(self, rowkey, vals, ts=None):
        key = java_str(rowkey)

        rowup = Put(Bytes.toBytes(key))
        if ts is not None:
            rowup.setTimestamp(ts)

        for k, v in vals.items():
            (fam, col) = KeyValue.parseColumn(Bytes.toBytes(java_str(k)))
            if isinstance(v, com.google.protobuf.Message):
                rowup.add(fam, col, v.toByteArray())
            else:
                rowup.add(fam, col, PBUtil.toBytes(v))

        self.table.put(rowup)
示例#8
0
    def getUpdate(self, row):
        up = Put(row.getRow())
        for k, v in self.replace.items():
            (fam,
             col) = KeyValue.parseColumn(Bytes.toBytes(java.lang.String(k)))
            if isinstance(v, com.google.protobuf.Message):
                up.add(fam, col, v.toByteArray())
            else:
                up.add(fam, col, PBUtil.toBytes(v))

        return up
示例#9
0
	def save(self, rowkey, vals, ts=None):
		key = java_str(rowkey)

		rowup = Put( Bytes.toBytes(key) )
		if ts is not None:
			rowup.setTimestamp(ts)

		for k, v in vals.items():
			(fam, col) = KeyValue.parseColumn( Bytes.toBytes( java_str(k) ) )
			if isinstance(v, com.google.protobuf.Message):
				rowup.add(fam, col, v.toByteArray())
			else:
				rowup.add(fam, col, PBUtil.toBytes(v))

		self.table.put(rowup)
示例#10
0
	def endElement(self, name):
		if name == 'modify':
			self.isModify = False
		if name =='create':
			self.isCreate = False
		if name == 'delete':
			self.isDelete = False 
		if name == 'node':
			if self.isDelete:
				d = Delete(self.nodeId)
				nodesTable.delete(d)
			else:
				row = Put(self.nodeId)
				row.add('nodeData','user',self.nodeUser)
				row.add('nodeData','lat',self.nodeLat)
				row.add('nodeData','lon',self.nodeLon)
				if len(self.nodeTags) > 0:
					row.add('nodeData','tags',"#".join("(%s,%s)" % tup for tup in self.nodeTags))
					self.nodeTags = []
				nodesTable.put(row)
				self.nodeId = 0
				self.nodeLat = 0.0
				self.nodeLon = 0.0
				self.isNode = False
		if name == 'way':
			if self.isDelete:
				d = Delete(self.wayId)
				waysTable.delete(d)
			else:
				row = Put(self.wayId)
				row.add('wayData','user',self.wayUser)
				if len(self.wayNodes) > 0:
					row.add('wayData','nodes',"#".join("%s" % tag for tag in self.wayNodes))
					self.wayNodes = []
				if len(self.wayTags) > 0:
					row.add('wayData','wayTags', "#".join("(%s,%s)" % tup for tup in self.wayTags))
					self.wayTags = []
				waysTable.put(row)
				self.isWay = False