Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added python-hadoop/__init__.py
Empty file.
60 changes: 60 additions & 0 deletions python-hadoop/hadoop/io/BytesWritable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
# ========================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from Writable import WritableComparable
from WritableUtils import readVInt, writeVInt

class BytesWritable(WritableComparable):
def __init__(self):
self._bytes = ''
self._length = 0

def getBytes(self):
return self._bytes

def getLength(self):
return self._length

def set(self, value):
self._bytes = value
self._length = len(self._bytes)

def append(self, value):
new_bytes = value
self._bytes += new_bytes
self._length += len(new_bytes)

def clear(self):
self._length = 0
self._bytes = ''

def write(self, data_output):
data_output.writeInt(self._length)
data_output.write(self._bytes)

def readFields(self, data_input):
self._length = data_input.readInt()
self._bytes = data_input.read(self._length)

def equal(self, other):
if not isinstance(other, BytesWritable):
return False
return self._bytes == other._bytes and self._length and other._length

def toString(self):
return self._bytes
1 change: 1 addition & 0 deletions python-hadoop/hadoop/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import MapFile
import SetFile

from BytesWritable import *
from Writable import *
from IntWritable import *
from Text import *
Expand Down
1 change: 1 addition & 0 deletions python-hadoop/hadoop/io/compress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
# limitations under the License.

from CodecPool import *
from Lz4Codec import *